
void setup() {
size (450, 1000);
background(247, 156, 35);
color c= color (#2F5289);
fill(c);
}
void draw() {
background(#2F5289);
color c= color (240, random(212), 73);
fill(c);
strokeWeight(10);
pushMatrix();
translate(width*0.6, height*0.5);
rotate(frameCount /50.0);
star(150, 200, 50, 70, 5);
popMatrix();
pushMatrix();
translate(width*0.2, height*0.1);
rotate(frameCount /-130.0);
star(100, 100, 20, 40, 5);
popMatrix();
pushMatrix();
translate(width*0.8, height*0.7);
rotate(frameCount /30.0);
star(40, 0, 10, 5, 5);
popMatrix();
pushMatrix();
translate(width*0.3, height*0.65);
rotate(frameCount /-75.0);
star(0, 0, 25, 55, 5);
noFill();
popMatrix();
pushMatrix();
translate(width*0.7, height*0.88);
rotate(frameCount /-75.0);
star(0, 200, 100, 135, 5);
popMatrix();
pushMatrix();
translate(width*0.3, height*0.4);
rotate(frameCount /-130.0);
star(0, 100, 20, 40, 5);
popMatrix();
pushMatrix();
translate(width*0.7, height*0.25);
rotate(frameCount /+30.0);
star(0, 0, 70, 30, 6);
popMatrix();
}
void star(float x, float y, float radius1, float radius2, int npoints)
{
float angle = TWO_PI / npoints;
float halfAngle = angle/2;
beginShape();
for (float a = 0; a < TAU; a += angle)
{
float sx = x + cos(a) * radius2;
float 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);
}
void keyPressed() {
if(key == 's') saveFrame("filename-jsfall6.png");
}
댓글
댓글 쓰기