xxxxxxxxxx
let circles = [];
function setup() {
createCanvas(windowWidth, windowHeight);
}
function draw() {
background(0);
noFill();
stroke(255);
strokeWeight(random(0,5));
// Create new circle with random position and size
if (random(1) < 0.03) {
let newCircle = {
x: random(width),
y: random(height),
diameter: random(20, 50),
shakeFactor: 0
};
circles.push(newCircle);
}
// Update and display circles
for (let i = circles.length - 1; i >= 0; i--) {
let circle = circles[i];
// Calculate shake factor based on mouse position
let shakeAmount = map(mouseX, 0, width, 0, 20);
// Update circle position with random shake
circle.x += random(-shakeAmount, shakeAmount);
circle.y += random(-shakeAmount, shakeAmount);
// Draw circle
ellipse(circle.x, circle.y, circle.diameter);
// Remove circles that go off screen
if (circle.x < -circle.diameter || circle.x > width + circle.diameter || circle.y < -circle.diameter || circle.y > height + circle.diameter) {
circles.splice(i, 1);
}
}
}