let nSym = 1;
function setup() {
createCanvas(windowWidth * 0.9, windowHeight * 0.9);
rectMode(CENTER);
angleMode(DEGREES);
noStroke();
nCirc = int(random(10, 20));
nRot = [];
a1 = [];
b1 = [];
r1 = [];
r2 = [];
r3 = [];
for (let i = 0; i < nCirc; i++) {
a1[i] = random(width);
b1[i] = random(0, 360);
r1[i] = random(100, 255);
r2[i] = random(200, 225);
r3[i] = random(200, 255);
nRot[i] = int(random(5, 40));
}
}
function draw() {
t = frameCount / 10;
translate(width / 2, height / 2);
background(10, 30, 40, 50);
fill(255);
push();
rotate(t / 2);
for (let k = 0; k < nSym; k++) {
push();
rotate((360 / nSym) * k);
for (let j = 0; j < nCirc; j++) {
push();
translate((width / 6) * sin(t + b1[j]), (width / 6) * cos(t + b1[j]));
for (let i = 0; i < nRot[j]; i++) {
fill(
r1[j] * abs(cos(t + b1[j])),
r2[j] * abs(cos(t + b1[j])),
r3[j] * abs(cos(t + b1[j])),
90
);
a =
a1[j] * sin(t) * cos(t / 3 + b1[j]) - (a1[j] / 2) * sin(t + nRot[j]);
circle(
a * cos(b1[j] + (i * 360) / nRot[j]),
a * sin(b1[j] + (i * 360) / nRot[j]),
a / 10
);
fill(
(r1[j] / 2) * abs(cos(t + b1[j])),
(r2[j] / 2) * abs(cos(t + b1[j])),
(r3[j] / 2) * abs(cos(t + b1[j])),
90
);
circle(
a * cos(b1[j] + (i * 360) / nRot[j]),
a * sin(b1[j] + (i * 360) / nRot[j]),
a / 20
);
}
pop();
}
pop();
}
pop();
border();
}
function border() {
push();
noFill();
stroke(20, 50, 60);
strokeWeight(4);
rect(0, 0, width - 20, height - 20);
pop();
}
function mousePressed() {
frameCount = 0;
if (nSym < 20) {
nSym++;
} else {
nSym = 1;
}
setup();
draw();
}
function keyPressed() {
trails = !trails;
}
function windowResized() {
resizeCanvas(windowWidth * 0.9, windowHeight * 0.9);
}