Created
December 26, 2024 01:00
-
-
Save sasaki-shigeo/dd0058533494a3c2bdb8f93e4a1ab5f7 to your computer and use it in GitHub Desktop.
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); | |
noLoop(); | |
} | |
void draw() { | |
stroke(#ffffff); | |
strokeWeight(20); | |
snow(width/2, height/2, 0.8 * min(width, height)); | |
} | |
void cedarLeaf(float len) { | |
float unit = len/4; | |
float rx = cos(PI/6) * unit; // == √3/2 * unit | |
float ry = sin(PI/6) * unit; // == 0.5 * unit | |
line(0, 0, 0, len); | |
for (int i = 1; i < 4; i++) { | |
line(0, i * unit, rx, i * unit + ry); | |
line(0, i * unit, -rx, i * unit + ry); | |
} | |
} | |
void snow(float x, float y, float len) { | |
pushMatrix(); | |
translate(x, y); | |
for (int i = 0; i < 6; i++) { | |
rotate(PI/3); | |
cedarLeaf(len / 2); | |
} | |
popMatrix(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment