xxxxxxxxxx
100
let words = [
"Anxiety",
"Pressure",
"Tension",
"Overwhelmed",
"Stress",
"Worry",
"Panic",
"Fear",
"Nervous",
"Chaos",
"Rushed",
"Restless",
"Doubt",
"Unease",
"Frantic",
"Frustration",
"Fatigue",
"Hurry",
"Jittery",
"Numb",
];
let wordObjects = [];
let timer = 0;
let redValue = 0;
let increasing = true;
let speed = 200;
let lastClickTime = 0;
function setup() {
createCanvas(windowWidth, windowHeight);
textSize(30);
textAlign(CENTER, CENTER);
// the words
for (let i = 0; i < 150; i++) {
wordObjects.push({
word: random(words),
x: random(width),
y: random(height),
color: color(random(100, 150), random(100, 150), random(100, 150)),
});
}
}
function draw() {
// red background changing
if (increasing) {
redValue += 0.5; //increase
if (redValue >= 255) {
redValue = 255;
increasing = false;
}
} else {
redValue -= 0.5; //decrease
if (redValue <= 0) {
redValue = 0;
increasing = true;
}
}
background(redValue, 0, 0);
for (let wordObj of wordObjects) {
fill(wordObj.color);
text(wordObj.word, wordObj.x, wordObj.y);
}
// timer
if (millis() - timer > speed) {
updateWordsAndPositions();
timer = millis();
}
if (millis() - lastClickTime > 500 && speed < 200) {
speed += 1;
}
}
// randomize everything
function updateWordsAndPositions() {
for (let wordObj of wordObjects) {
wordObj.word = random(words);
wordObj.x = random(width);
wordObj.y = random(height);
}
}
function mousePressed() {
if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) {
speed = max(20, speed - 20);
lastClickTime = millis();
}
}
function windowResized() {
resizeCanvas(windowWidth, windowHeight);
}