Skip to content

Instantly share code, notes, and snippets.

@kmancher
Created September 16, 2017 16:45
Show Gist options
  • Select an option

  • Save kmancher/5a465fbba7948b0b8ede74396d98539e to your computer and use it in GitHub Desktop.

Select an option

Save kmancher/5a465fbba7948b0b8ede74396d98539e to your computer and use it in GitHub Desktop.
Get data from verse
var x = 'I saw a cat outside';
var text;
function setup() {
createCanvas(500, 300);
text = createP(x);
console.log('string length = ' + x.length);
console.log('uses word I = ' + x.indexOf("I"));
console.log('string includes word ME: ' + x.includes("me"));
}
function draw() {
var letters = x.length;
if (x.includes("me") || x.includes("I") === true) {
background(255, 0, 0);
} else if (x.includes("you") === true) {
background(0, 255, 0);
} else {
background(0, 0, 255);
}
for (var i = 0; i <= letters * 10; i += 10){
stroke(255);
line(i, 0, i*3, height);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment