xxxxxxxxxx
34
function setup() {
createCanvas(500, 500);
angleMode(DEGREES);
}
let rot = 0;
let radius = 240;
let frac = 1;
function draw() {
background("black");
stroke("white");
let alpha = 0;
for (let i = 0; i < 40; i++) {
fill(255, 0, 255, alpha);
polygon(6, 250, 250, radius * frac, i * rot);
frac *= 0.9;
alpha += 20;
}
rot += 0.1;
frac = 1;
}
function polygon(n, x, y, r, angleOffset) {
let angle = 360 / n;
beginShape();
for (let i = 0; i < n; i++) {
let nextX = x + cos(i * angle + angleOffset) * r;
let nextY = y + sin(i * angle + angleOffset) * r;
vertex(nextX, nextY);
}
endShape(CLOSE);
}