xxxxxxxxxx
81
// I made a haiku generator (though they don't make much sense). I set the variables based on the structure: I [verb] a [adjective] [noun]
// And I [verb] a [adjective] [noun] too
// I feel like a [noun]
// While it does follow the rhytmic stucture of a Haiku, it is neither deep/thought-provoking or artistic
let NOUN1 = 0;
let VERB1 = 1;
let ADJ1 = 2;
let NOUN2 = 3;
let VERB2 = 4;
let ADJ2 = 5;
let NOUN3 = 6;
let strings = [];
function setup() {
strings = loadStrings("words.csv");
createCanvas(400, 400);
background(
random(150, 255),
random(150, 255),
random(150, 255),
random(50, 100)
);
textSize(20);
for (let i = 0; i < 200; i++) {
push();
noStroke();
fill(255, 255, 255);
ellipse(random(0, width), random(0, height / 2 - 40), random(2, 5));
pop();
}
}
let csvRowNumber = 0;
function draw() {
let singleRow = [];
fill(0);
// First message/rhyme
singleRow = split(strings[int(random(strings.length))], ",");
let verb1 = singleRow[VERB1];
singleRow = split(strings[int(random(strings.length))], ",");
let adj1 = singleRow[ADJ1];
singleRow = split(strings[int(random(strings.length))], ",");
let noun1 = singleRow[NOUN1];
text("I " + verb1 + " a " + adj1 + " " + noun1, 0, height / 2);
// Second message//
message = "And I ";
singleRow = split(strings[int(random(strings.length))], ",");
message += singleRow[VERB2];
message += " a ";
singleRow = split(strings[int(random(strings.length))], ",");
message += singleRow[ADJ2];
message += " ";
singleRow = split(strings[int(random(strings.length))], ",");
message += singleRow[NOUN2];
message += " too";
text(message, 0, height / 2 + 25);
//Third message//
singleRow = split(strings[int(random(strings.length))], ",");
let noun3 = singleRow[NOUN3];
text("I feel like a " + noun3, 0, height / 2 + 50);
noLoop();
}
function mouseClicked() {
background(random(150, 255), random(150, 255), random(150, 255)); //refreshes the background
for (let i = 0; i < 200; i++) {
push();
noStroke();
fill(255, 255, 255);
ellipse(random(0, width), random(0, height / 2 - 40), random(2, 5));
}
loop();
}