xxxxxxxxxx
89
let size = 0;
let rand1 = 0;
let rand2 = 0;
let bar = 0;
function setup() {
createCanvas(500, 500);
}
function draw() {
background(255 - rand1 * 2.2);
print(rand1);
stroke(
125 + random(rand1, rand2),
125 + random(rand1, rand2),
125 + random(rand1, rand2)
);
strokeWeight(4);
fill(255 - rand1 * 2.2);
noCursor();
rectMode(CENTER);
if (mouseIsPressed && frameCount % 1 == 0 && size < 255) {
rand1 = rand1 + 2;
rand2 = rand2 - 2;
size = size + 1;
bar = bar + 3.5;
} else if (frameCount % 1 == 0 && size > 0) {
rand1 = rand1 - 2;
rand2 = rand2 + 2;
size = size - 1;
bar = bar - 3.5;
}
for (let i = 0; i < 10; i++) {
triangle(
mouseX + random(rand1, rand2)*0.7,
mouseY + random(rand1, rand2)*0.7,
mouseX + random(rand1, rand2)*0.5,
mouseY + random(rand1, rand2)*0.5,
mouseX + random(rand1, rand2)*0.4,
mouseY + random(rand1, rand2)*0.4
);
square(
mouseX + random(rand1, rand2)*0.7,
mouseY + random(rand1, rand2)*0.7,
32 + size
);
square(
mouseX + random(rand1, rand2)*0.5,
mouseY + random(rand1, rand2)*0.5,
16 + size
);
square(
mouseX + random(rand1, rand2)*0.4,
mouseY + random(rand1, rand2)*0.4,
4 + size
);
circle(
mouseX + random(rand1, rand2)*0.7,
mouseY + random(rand1, rand2)*0.7,
32 + size
);
circle(
mouseX + random(rand1, rand2)*0.5,
mouseY + random(rand1, rand2)*0.5,
16 + size
);
circle(
mouseX + random(rand1, rand2)*0.4,
mouseY + random(rand1, rand2)*0.4,
4 + size
);
}
fill(
125 + random(rand1, rand2),
125 + random(rand1, rand2),
125 + random(rand1, rand2)
);
rectMode(CORNER);
rect(10 + random(rand1, rand2)*0.03, 10 + random(rand1, rand2)*0.03, bar, 20);
noStroke();
textSize(18);
text("Creativity Meter", 190, 60);
}