Skip to content

Instantly share code, notes, and snippets.

@sasaki-shigeo
Last active December 30, 2015 18:49
Show Gist options
  • Save sasaki-shigeo/7869828 to your computer and use it in GitHub Desktop.
Save sasaki-shigeo/7869828 to your computer and use it in GitHub Desktop.
A kind of snow crystal /Processing で雪の結晶を描く
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