let nStr, d, c;
let colors = [
"#db9031",
"#cb7d2b",
"#bc6926",
"#ac5620",
"#914923",
"#773c25",
"#5e2f25",
"#492723",
"#342020",
"#20181d"
];
let col;
function setup() {
createCanvas(windowWidth * 0.9, windowHeight * 0.9);
nColors = int(random(10, 20));
col = [];
nR = [];
nRot = [];
rectMode(CENTER);
nStr = 2 * int(random(50, 100));
c = min(width, height) * 0.9;
d = c / nStr;
angleMode(DEGREES);
noLoop();
noFill();
for (let i = 0; i < nStr; i++) {
col[i] = int(random(0, colors.length - 0.000001));
nR[i] = int(randomGaussian(3, 1));
nRot[i] = int(random(0, nStr));
}
}
function draw() {
background(50 + random(10, 20), 20 + random(10, 20), 50 + random(10, 20));
stroke(150, 180, 205);
strokeWeight(3);
translate(width / 2, height / 2);
t = frameCount;
for (let i = 0; i < nStr; i++) {
stroke(colors[col[i]]);
line(
0,
0,
(c / 2) * cos((i * 360) / nStr),
(c / 2) * sin((i * 360) / nStr)
);
}
strokeWeight(d * 0.3);
for (let i = 0; i < nStr; i++) {
for (let j = 0; j < nStr / 2; j++) {
stroke(colors[col[i]]);
push();
rotate((nRot[i] * 360) / nStr);
if (i % nR[i] === 0) {
arc(
0,
0,
d * i,
d * i,
2 + (360 / nStr) * nR[i] * j,
(360 / nStr) * nR[i] * (j + 1) - 2
);
} else {
arc(
0,
0,
d * i,
d * i,
2 + (360 / nStr) * nR[i] * j + 360 / nStr,
(360 / nStr) * nR[i] * (j + 1) - 2 + 360 / nStr
);
}
pop();
}
}
border();
}
function border() {
noFill();
stroke(colors[int(random(0, colors.length - 1))]);
strokeWeight(4);
rect(0, 0, width - 20, height - 20);
}
function mousePressed() {
frameCount = 0;
setup();
draw();
}
function keyPressed() {
trails = !trails;
}
function windowResized() {
resizeCanvas(windowWidth * 0.9, windowHeight * 0.9);
}