xxxxxxxxxx
128
//key Q W E R /Q = calmness /W = anger /E = joy /R = sadness
let shape = 0;
let a = 0;
let b = 0;
let rand1 = [];
function setup() {
createCanvas(500, 500);
for (let i = 0; i < 5; i++) {
rand1.push(random(2));
}
}
function draw() {
background(0);
noStroke();
if (shape === 1) { //calmness
push();
for (let c = 0; c < 50; c++) {
for (let d = 0; d < 50; d++) {
if (rand1[0] > 1) {
fill(0, 218, (c * 10));
rect(20 * c, 20 * d, 20, 20);
} else {
fill(119, 243, (d * 10));
rect(20 * c, 20 * d, 20, 20);
}
}
}
pop();
} else if (shape === 2) { //anger
push();
background(0, 20, 0);
fill(255, random(0, 100), random(0, 150))
quad(
random(0, width), random(0, height),
random(0, width), random(0, height),
random(0, width), random(0, height),
random(0, width), random(0, height)
);
fill(random(255, 100))
quad(
random(-20, 520), random(-20, 520),
random(-20, 520), random(-20, 520),
random(-20, 520), random(-20, 520),
random(-20, 520), random(-20, 520)
);
pop();
} else if (shape === 3) { //joyful
push();
let from = color(250, 88, 20);
let to = color(244, 246, 143);
let colorA = lerpColor(from, to, 0.2);
let colorB = lerpColor(from, to, 0.4);
let colorC = lerpColor(from, to, 0.6);
let colorD = lerpColor(from, to, 0.8);
background(255, 210, 201);
translate(180 - b, 150 + a);
fill(to);
circle(width / 2, height / 2, 550);
fill(colorD);
circle(width / 2, height / 2, 450);
fill(colorC);
circle(width / 2, height / 2, 350);
fill(colorB);
circle(width / 2, height / 2, 250);
fill(colorA);
circle(width / 2, height / 2, 150);
fill(from);
circle(width / 2, height / 2, 50);
pop();
push();
translate(b, 300 - a);
fill(from);
circle(width / 2, height / 2, 550);
fill(colorA);
circle(width / 2, height / 2, 450);
fill(colorB);
circle(width / 2, height / 2, 350);
fill(colorC);
circle(width / 2, height / 2, 250);
fill(colorD);
circle(width / 2, height / 2, 150);
fill(to);
circle(width / 2, height / 2, 50);
pop();
} else if (shape === 4) { //sadness
push();
background(34, 0, 89);
translate(-100, -160);
for (let i = 1; i < 15; i++) {
noFill();
strokeWeight(5)
stroke(i * 10, 82, 220);
bezier(10 * i - 100, 40 * i + 30,
120 * i, 70 * i + 5,
200 * i + 15, 150 * i,
10 * i, 20 * i)
stroke(180 - i * 10, 82, 220);
bezier(i * 20, 500,
i * 20 + 200, 500 - i * 20,
i * 20 + 400, 700 - i * 20,
i * 20 + 400, 900 - i * 20);
}
pop();
}
}
function keyPressed() {
if (keyCode === 81) {
shape = 1;
} else if (keyCode === 87) {
shape = 2;
} else if (keyCode === 69) {
shape = 3;
} else if (keyCode === 82) {
shape = 4;
}
}