xxxxxxxxxx
26
let colNum = 10;
let rowNum = 5;
let colW;
let rowH;
function setup() {
createCanvas(500, 500);
colW = width / colNum;
rowH = height / rowNum;
}
function draw() {
background(220);
for (let col = 0; col <= colNum; col++) {
for (let row = 0; row <= rowNum; row++) {
let x = col * colW;
let y = row * rowH;
let d = dist(mouseX, mouseY, x, y);
d = map(d, 0, dist(0, 0, width, height) / 2, 200, 0)
// if (mouseX > col * colW && mouseX < (col + 1) * colW && mouseY > row * rowH && mouseY < (row + 1) * rowH) {
fill(d);
rect(x, y, colW, rowH);
// }
}
}
}