xxxxxxxxxx
function setup() {
createCanvas(windowWidth, windowHeight);
background(0);
}
function draw() {
background(0);
fill(227, 45, 84);
noStroke();
mil = millis() / 18;
push();
translate(width * 0.5, height * 0.5);
rotate(mil);
translate(mil, 0);
star(0, 100, mil / 8, 150, 85);
pop();
translate(windowWidth / 2, windowHeight / 2);
rotate(mil);
translate(mil, 0);
}
function star(x, y, radius1, radius2, npoints) {
let angle = TWO_PI / npoints;
let halfAngle = angle / 2.0;
beginShape();
for (let a = 0; a < TWO_PI; a += angle) {
let sx = x + cos(a) * radius2;
let sy = y + sin(a) * radius2;
vertex(sx, sy);
sx = x + cos(a + halfAngle) * radius1;
sy = y + sin(a + halfAngle) * radius1;
vertex(sx, sy);
}
endShape(CLOSE);
}