Skip to content

Instantly share code, notes, and snippets.

@sasaki-shigeo
Last active December 30, 2015 12:09
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save sasaki-shigeo/7827644 to your computer and use it in GitHub Desktop.
Drawing stars / Processing で星形(5芒星)を描く
void setup() {
size(500, 500);
noStroke();
fill(255, 255, 0);
for (int i = 0; i < 10; i++) {
star(random(width), random(height), 30);
}
}
void star(float x, float y, float r) {
pushMatrix();
translate(x, y);
scale(1, -1);
rotate(HALF_PI);
beginShape();
for (int i = 0; i < 5; i++) {
vertex(r * cos(4 * PI * i / 5), r * sin(4 * PI * i / 5));
}
endShape(CLOSE);
popMatrix();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment