Last active
December 30, 2015 18:49
-
-
Save sasaki-shigeo/7869828 to your computer and use it in GitHub Desktop.
A kind of snow crystal /Processing で雪の結晶を描く
This file contains 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); | |
crystal(250, 250, 100); | |
} | |
void hexagon(float x, float y, float r) { | |
pushMatrix(); | |
translate(x, y); | |
beginShape(); | |
for (int i = 0; i < 6; i++) { | |
vertex(r*cos(radians(60*i)), | |
r*sin(radians(60*i))); | |
} | |
endShape(CLOSE); | |
popMatrix(); | |
} | |
void crystal(float x, float y, float r) { | |
noStroke(); | |
fill(255); | |
pushMatrix(); | |
translate(x, y); | |
hexagon(0, 0, 0.5*r); | |
for (int i = 0; i < 6; i++) { | |
hexagon(0.75*r*cos(radians(60*i)), | |
0.75*r*sin(radians(60*i)), | |
0.25*r); | |
} | |
popMatrix(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment