xxxxxxxxxx
46
let cols; let rows;
let spacing = 5;
let size = [];
let scl = 0.01;
let x = 0; let y = 0; let dx = 2; let dy = 3;
let xoff = 0;
function setup() {
createCanvas(1000, 500);
cols = width/spacing;
rows = height/spacing;
rectMode(CENTER);
}
function draw() {
background(244, 244, 243);
x = x + dx;
y = y + dy;
if (x > width || x < 0){
dx = dx * -1;
}
if (y > height || y < 0){
dy = dy * -1;
}
for (let i=0; i<cols; i++){
size[i] = [];
for (let j=0; j<rows; j++){
size[i][j] = (dist(x, y, i*spacing, j*spacing))*scl;
}
}
let r = noise(xoff)*255;
let g = noise(xoff+15)*255;
let b = noise(xoff+30)*255;
for (let i=0; i<cols; i++){
for (let j=0; j<rows; j++){
noStroke();
fill(r, g, b);
rect(spacing/2 + i*spacing, spacing/2 + j*spacing, size[i][j], size[i][j]);
}
}
xoff += 0.005;
}