xxxxxxxxxx
37
/*
Note that this is a bare-bones example.
For a more complete example, see https://observablehq.com/@dhowe/rita-grammars
For more advanced grammar and riscript features, see:
https://observablehq.com/@dhowe/tut-rita-ngrams#advanced
*/
let font, grammar, json;
let lines = ["click to", "generate", "a haiku"];
function setup() {
createCanvas(650, 300);
textAlign(CENTER);
loadFont('Bootzy Font.ttf', f => textFont(f, 30));
grammar = RiTa.grammar(texxt); // from grammar.js
}
function draw() {
background(230, 240, 255);
text(lines[0], width / 2, 75);
text(lines[1], width / 2, 110);
text(lines[2], width / 2, 145);
}
function mouseReleased() {
let result = grammar.expand();
// split on the % char output from the grammar
lines = result.split("%");
}