kaqw/glaze

🚀 WebGL wrapper written in Rust, compiled to WASM

Vitrail

Introduction

Vitrail is a text generator using context-free grammars, inspired by projects like Tracery, or Grammy.

It can be used on the spot by providing a grammar as a JSON file, and following the default syntax, and can also be used as a library.

I also have a Kotlin version here ;)

Features

  • Read grammar from JSON file
  • Shared variables, available through all symbol expansions
  • Customisable grammar syntax/operators (when used as a library)
  • Potential for custom modifiers (when used as a library)

JSON Grammar file

Rust Code

Example output

Grammar features

Symbol expansion (default: { })

Looks up the rules corresponding to the symbol, and picks one randomly as a replacement

Variable capture (default: [symbol>variableName])

Creates a variableName symbol with a static value. The rules corresponding to symbol determine the value of variableName. This value never changes once it's initialized.

In the example above, both subject symbols will expand with the value coming from person.

Note: The placement of the variable capture matters!

The algorithm expands symbols from left to right. This means that a symbol expansion captured inside a variable is only available for expressions on its right side.

Otherwise, placement is free.

Note (expanding on the previous note):

While placement is free for now, future plans involve allowing for more granularity regarding the scope of variables.

One possibility would be to declare captures inside a symbol to make it available only inside the scope of this symbol's expansion:

In the example above, subject could have different values in the expansion of part1 and part2.

Do keep this in mind when writing your grammars.

Modifiers (default: :modifierName)

Applies a modification on the expanded value of a symbol.

Note: while a Modifier interface exists, and modifiers added to the Grammar at runtime are applied, the library does not provide any modifier yet.

Considering that the Grammar has a modifier with the name capitalize, that capitalizes the first letter of the value passed to it, the result of the example above would be:

License

Vitrail is released under MIT License

Information - Updated Jul 13, 2022

Stars: 1
Forks: 1
Issues: 0

Repositories & Extras

wasm-bindgen-console-logger

This small utility crate integrates the wasm-bindgen

wasm-bindgen-console-logger

Wasm template for Rust hosting without npm-deploy on github pages using Travis script

It automatically hosts your wasm projects on gh-pages using a travis script on the latest commit

Wasm template for Rust hosting without npm-deploy on github pages using Travis script

wasm-pack-template

A template for kick starting a Rust and WebAssembly project using Tutorial

wasm-pack-template

wasm-pack-template

A template for kick starting a Rust and WebAssembly project using Tutorial

wasm-pack-template

wasm-pack build executed in remote deployment, use with vite-plugin-rsw

wasm-pack build executed in remote deployment, use with rust

wasm-pack build executed in remote deployment, use with vite-plugin-rsw

wasm/linalg 📏

Linear Algebra powered by Web Assembly

wasm/linalg 📏

wasm-pack-template

A template for kick starting a Rust and WebAssembly project using Tutorial

wasm-pack-template

wasm-pack-template

A template for kick starting a Rust and WebAssembly project using Tutorial

wasm-pack-template

wasm/supervised 📏

Linear Algebra powered by Web Assembly

wasm/supervised 📏

wasm-pack-template

A template for kick starting a Rust and WebAssembly project using Tutorial

wasm-pack-template

WASM / Rust / D3 example

Fetch data with Rust + WASM and show it with JS + D3

WASM / Rust / D3 example

wasm-pack-template

A template for kick starting a Rust and WebAssembly project using Tutorial

wasm-pack-template
Facebook Instagram Twitter GitHub Dribbble
Privacy