xxxxxxxxxx
33
// array with history of messages
let textHistory = [];
function setup() {
createCanvas(windowWidth, windowHeight);
}
function draw() {
background(220);
if (frameCount % 20 === 0){
textHistory.reverse();
textHistory.push(randomText());
textHistory.reverse();
textHistory = textHistory.slice(0, 10);
}
fill(0);
textSize(32);
textAlign(LEFT, TOP);
for (var i=0; i<textHistory.length; i++){
text(textHistory[i], 30, i * 30 + 30);
}
}
function randomText(){
var t = "";
for (var i=0; i<20; i++){
t += (random(0, 3) < 1) ? " " : String.fromCharCode(random(97, 122));
}
return t;
}