xxxxxxxxxx
32
var x;
var y;
var spacing;
function setup() {
createCanvas(400,400);
}
function draw() {
background(0);
stroke(255);
strokeWeight(2);
fill(0);
if (mouseIsPressed) {
spacing = map(mouseX, 0, width, 10, 300) + map(mouseY, 0, height, 10, 300);
}
for (var y = 0; y < width; y += spacing) {
for (var x = 0; x < width; x += spacing) {
fill(map(map(dist(x, y, mouseX, mouseY), 0, 600, 0, 255), 0, 255, 255, 0) / 1.8);
rect(x, y, spacing, spacing);
}
// rect(x,y,spacing,spacing);
}
}
function initializeFields() {
x = 0;
y = 0;
spacing = 50;
}