xxxxxxxxxx
30
let r = 40; // radius for circles
function setup() {
createCanvas(600, 400);
frameRate(4);
}
function draw() {
background(0);
noStroke();
for (let y = 0; y <= height; y += 50) {
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); // 2.5 times the normal size
} else {
// If the mouse is not over the circle, draw it normally
ellipse(x, y, 8);
}
}
r = random(30, 30); // Randomize the radius for the next set of circles
}
}