xxxxxxxxxx
31
let spaceX = 20, spaceY = 20, diam = 100;
function setup() {
createCanvas(600, 600);
noStroke();
}
function draw() {
background(0);
for (let x = 20; x < width; x += spaceX) {
for (let y = 20; y < height; y += spaceY) {
drawEllipse(x, y);
}
}
}
function drawEllipse(x, y) {
let d = dist(mouseX, mouseY, x, y);
if (d < 100) {
fill(255, 0, 0, 100);
diam = map(d, 0, 100, 50, 1);
} else {
fill(255, 30);
diam = 15;
}
ellipse(x, y, diam);
}