xxxxxxxxxx
function setup() {
createCanvas(600,600);
frameRate(6);
}
function draw() {
background(255,255,255);
noStroke();
let circleSize = 25;
let spacing = 50;
for (let x = 0; x <= width; x += spacing) {
for (let y = 0; y <= height; y += spacing) {
// Calculate distance from mouse to current circle
let distance = dist(x, y, mouseX, mouseY);
// Map the distance to a color value
let col = map(distance, 0, width, 0, 255);
// Fill the circle with the mapped color
fill(col, random(255), random(255));
ellipse(x, y, circleSize, circleSize);
}
}
}