let c;
let n, m;
function setup() {
createCanvas(600, 600, WEBGL);
fill(80, 160, 180, 50);
noStroke();
c = random(1);
describe("");
n = random(100, 200);
m = random([2, 3, 6, 8, 9, 15]);
noStroke();
}
function draw() {
t = 2 * PI * sin(frameCount / 1000);
m2 = m + abs(m * t);
pointLight(
255,
255,
255,
100 + 100 * cos(t),
100 - 100 * cos(t / 2),
100 + 100 * cos(t / 3)
);
pointLight(
255,
255,
255,
-200 + 100 * cos(t),
100 - 100 * cos(t / 2),
200 + 100 * cos(t / 3)
);
specularMaterial(80, 160, 180, 10);
for (let j = 0; j < m2; j++) {
push();
rotateZ((j * 2 * PI) / m2 - t / 100);
for (let i = 1; i < n; i += 5) {
push();
rotateZ((i * PI) / n + t);
translate(-width / 3 + (i * width) / n, 0, 50 * cos(t / i));
rotateX(2 * t * cos(i));
box(10, 10, 10);
pop();
}
pop();
}
}
function mousePressed() {
setup();
draw();
}