xxxxxxxxxx
168
let outputP;
let genButton;
function setup() {
noCanvas();
background(255);
textAlign(LEFT, TOP);
textSize(24);
genButton = createButton("Click to generate");
genButton.mousePressed(generate);
outputP = createP("");
}
function draw() {
}
function generate() {
var grammar = tracery.createGrammar(grammarSource);
grammar.addModifiers(tracery.baseEngModifiers);
var output = grammar.flatten("#origin#");
outputP.html(output);
}
// cut and paste your grammar below (as the value for variable "grammarSource")
//how do you use page breaks?
var grammarSource = {
"scene1": [" There is a #subject#, amongst our #groups#. '#interjection.capitalize#, #hero#!' 'We are missing #vegetable.s#!' Who will travel to the #destination#? 'Why don't we #vote# to figure out who does the deed?' said #hero#. #interjection.capitalize# #interjection# said #sidekick# as they started to have #extremeAction.a#. The #groups# #verb# #adjective#. 'We have to embrace the #force#.' said #hero#. "],
"scene2": ["An absurd amount of #badperson.s# has gathered nearby. #hero# is leading a V formation with the group heavily armed in #weapon.s#. 'This #weapon# is the #badperson.s# ultimate weakness.' said #sidekick#. Unknown to the group was the #badperson.s# had grown immune. The #badperson.s# spoke in reaction to the #weapon.s# being waved at their faces. 'we #badperson.s# come from #destination#. It has been a long journey.'"],
"subject": [
"walrus",
"hippo",
"banana",
"rental vehicle",
"gasoline station",
"destination wedding",
],
"groups":[
"pack",
"flock",
"arrangement",
"cohort",
"round table",
"dinner table",
"breakfast club",
],
"vote":[
"hold a deathmatch",
"get a tarot reading",
"play strip poker",
"race in our underwear",
"eat a ton of fortune cookies",
"joust",
"play Settlers of Catan",
],
"force":[
"pudding",
"our inner love demon",
"skin regiments",
"faith",
"beloveds",
"Northern Lights",
],
//no present tense?
"verb":[
"collaborates",
"vacates",
"satisfies",
"massages",
"feels",
"rubs",
"squeezes",
],
//is there a command for -ly -ing endings? Forget the proper vocab for it
"adjective":[
"hard",
"gently",
"passionately",
"aggressively",
"angerly",
"slowly",
"reluctantly",
],
"interjection": [
"shit",
"fuck",
"damn",
"balls to the wall",
"my feet are too big",
],
"name": [
"Oscar Meyer",
"Banana Boat",
"Big Tuna",
"Sky Flake",
"Cookie",
],
"name2" :[
"Flyswatter",
"Kombucha",
"Coffee Cup",
"Spamyerd",
"Colono",
],
"name3":[
"Analog-in",
"Arduino",
"MKR",
"Zero",
"Cereal",
],
"vegetable": [
"asparugus",
"corn",
"celery",
"potatoe",
"tomatoe",
"carrot",
],
"destination":[
"Florence",
"Paris",
"kitchen",
"garage",
"garden",
"church",
"dungeon",
"boonies",
],
"extremeAction":[
"seizure",
"aneurysm",
"heartache",
"butterflies",
"baby alien",
],
"origin": ["#[hero:#name#][sidekick:#name2#]scene1#, #[hero:#name#][sidekick:#name2#][badperson:#subject#][weapon:#vegetable#]scene2#"]
};