31 lines
560 B
Plaintext
31 lines
560 B
Plaintext
|
const circles = [];
|
||
|
|
||
|
function setup() {
|
||
|
createCanvas(600, 400);
|
||
|
strokeWeight(1);
|
||
|
stroke(0);
|
||
|
}
|
||
|
|
||
|
function draw() {
|
||
|
background(255);
|
||
|
circles.forEach((o, i, circles) => {
|
||
|
fill(o.color);
|
||
|
circle(o.x, o.y, o.size);
|
||
|
o.y += 5;
|
||
|
if (o.y > 420) {
|
||
|
circles.splice(i, 1);
|
||
|
}
|
||
|
});
|
||
|
|
||
|
text(circles.length, 40, 40);
|
||
|
}
|
||
|
|
||
|
function mousePressed() {
|
||
|
circles.push({
|
||
|
x: mouseX,
|
||
|
y: mouseY,
|
||
|
color: Math.floor((random(100, 201))),
|
||
|
size: Math.floor((random(20, 41)))
|
||
|
});
|
||
|
}
|