xxxxxxxxxx
43
const l = 25;
const space = 10;
function setup() {
createCanvas(600, 400);
rectMode(CENTER);
colorMode(RGB, 1, 1, 1);
noStroke();
fill(255);
smooth();
createLoop({
duration: 20,
startLoop: 0,
gif: true,
download: true,
fileName: "organic-rectangles.gif",
open: true,
}); //*/
}
function draw() {
background(0);
for (i = 0; i < width; i += space) {
push();
translate(i, 0);
for (j = 0; j < height; j += space) {
const ii = map(i, 0, width, 0, 1);
const jj = map(j, 0, height, 0, 1);
fill(ii, 1 - jj, 1);
push();
translate(0, j);
const m = millis();
const turn = m * (0.001 * cos(ii) + 0.001 * sin(jj));
rotate(turn);
rect(0, 0, l * sin(jj)/2, l * cos(ii)/2);
pop();
}
pop();
}
}