xxxxxxxxxx
28
function setup() {
createCanvas(400, 400);
background("silver");
c_start = color("yellow");
c_end = color("silver");
let count = 200;
for (let i = 0; i < count; i++) {
let mid_c = lerpColor(c_start, c_end, i / count);
stroke(mid_c);
noFill();
drawStar(width / 2, height / 2, 5, i, i / 2);
}
}
function draw() {}
// Function to draw a star shape
function drawStar(x, y, n, outerRadius, innerRadius) {
beginShape();
for (let i = 0; i < 2 * n; i++) {
let radius = i % 2 === 0 ? outerRadius : innerRadius;
let angle = (i * PI) / n - HALF_PI;
vertex(x + cos(angle) * radius, y + sin(angle) * radius);
}
endShape(CLOSE);
}