Last active
December 30, 2015 12:09
-
-
Save sasaki-shigeo/7827644 to your computer and use it in GitHub Desktop.
Drawing stars /
Processing で星形(5芒星)を描く
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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