xxxxxxxxxx
54
// rules = {
// start: "$subject $verb $object.",
// subject: "I | You | They | Your brother | εγω ",
// object: "coffee | bread | milk",
// verb: "want | hate | like | love | know | don't know"
// }
rules = {
"start": "$line1 % $line2 % $line3",
"line1": "$hero $verbs $object.",
"line2": "he has $object $bodyParts ",
"line3": "I love my $hero",
"$hero": "Tzoutzou | zouzouno | tzoutz",
"verbs": " is | feels like",
"bodyParts": "ass | neck | face | back ",
"object": "the sweetest | the softest | the cutest"
}
let result='click to unfold';
let lines = ["click to", "generate", "a haiku"];
let rg = RiTa.grammar(rules); // load our grammar
function setup() {
createCanvas(windowWidth, windowHeight);
textSize(24);
textAlign(CENTER);
}
function draw() {
background(220);
// text(result, 200, 200);
text(lines[0], width / 2, 75);
text(lines[1], width / 2, 110);
text(lines[2], width / 2, 145);
}
function mouseReleased() {
result = rg.expand();
let haiku = result.split("%");
for (let i = 0; i < lines.length; i++) {
lines[i] = haiku[i];
}
}