Created
September 16, 2017 16:45
-
-
Save kmancher/5a465fbba7948b0b8ede74396d98539e to your computer and use it in GitHub Desktop.
Get data from verse
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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