Skip to content

Instantly share code, notes, and snippets.

@ff6347
Forked from vogelino/wordColors.js
Created July 27, 2016 10:18
Show Gist options
  • Select an option

  • Save ff6347/10c775675f61e264c594359a3b44bd1f to your computer and use it in GitHub Desktop.

Select an option

Save ff6347/10c775675f61e264c594359a3b44bd1f to your computer and use it in GitHub Desktop.
var actualCharacter = -1;
var alphabet = 'abcdefghijklmnopqrstuvwxyz!?1234567890 ';
var word = window.prompt('Please a word or sentence you think is funny',
'badibaduba');
function setup() {
colorMode(HSB, alphabet.length, word.length, 1, 1);
createCanvas(windowWidth, windowHeight);
}
function colorizeByCharacter(character) {
var positionInAlphabet = alphabet.indexOf(character);
var positionInWord = actualCharacter;
background(positionInAlphabet, positionInWord, 1, 0.3);
}
function draw() {
actualCharacter = actualCharacter < word.length - 1 ? actualCharacter + 1 : -1;
colorizeByCharacter(word.split('')[actualCharacter]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment