xxxxxxxxxx
39
let words = [];
let str = "";
currentIndex = 0;
let p;
function preload() {
loadStrings('cant-stop.txt', process);
}
function setup() {
createCanvas(windowWidth, windowHeight);
p = createP();
p.position(0, 0);
}
function draw() {
if (frameCount % 30 === 0) {
print(true);
str += words[currentIndex] + " ";
p.html(str);
currentIndex = (currentIndex + 1) % words.length;
}
}
function process(lines) {
for (let line of lines) {
let tokens = splitTokens(line);
words = words.concat(tokens);
}
for (let i = 0; i < words.length; i+=1) {
words[i] = words[i].toLowerCase();
words[i] = words[i].replace(/[-_:;.,!?\(\)]/g, "");
}
// now we have all of the words
words = shuffle(words);
}