xxxxxxxxxx
66
let a = 0.0;
let s = 0.0;
function setup() {
createCanvas(720, 400);
noStroke();
}
function draw() {
background(135, 1, 25);
push();
translate(360, 200);
rotate(frameCount / 100);
scale(s);
//white star
fill(0);
star(0, 200, 30, 70, 5);
pop();
a = a + 0.04;
s = cos(a) * 2;
translate(width / 2, height / 2);
scale(s);
fill(19, 121, 19, 201);
star(0, 0, 30, 70, 5);
translate(75, 0);
fill(235, 187, 1, 200);
scale(s);
star(0, 0, 30, 70, 5);
push();
push();
translate(360, 200);
rotate(frameCount / -200.0);
scale(s);
//white star
fill(0, 149, 183, 210);
star(0, 200, 30, 70, 5);
pop();
}
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);
}