xxxxxxxxxx
36
let r = 40; // radius for circles
function setup() {
createCanvas(600, 400);
frameRate(4);
}
function draw() {
background(0);
noStroke();
// Loop through rows of circles
for (let y = 0; y <= height; y += 50) {
// Loop through columns of circles
for (let x = 0; x <= width; x += 50) {
// Random color fill for the circles
fill(random(250), random(250), random(250));
// Check if the mouse is inside the current circle
let d = dist(mouseX, mouseY, x, y);
// Distance from mouse to circle center
if (d < r / 2) {
// If mouse is inside circle, make the circle bigger
ellipse(x, y, r * 1.5);
// 1.5 times the normal size
} else {
// If the mouse is not over the circle, draw it normally
ellipse(x, y, 8);
}
}
r = random(5, 50); // Randomize the radius for the next set of circles
}
}