Last active
January 27, 2017 09:17
-
-
Save takawo/d458def15a60873207dc7d7abb9eb641 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
| int depth = 2; | |
| float len = 150; | |
| void setup() { | |
| size(960, 540, P2D); | |
| blendMode(ADD); | |
| colorMode(HSB, 360, 100, 100, 100); | |
| smooth(); | |
| } | |
| void draw() { | |
| background(0, 0, 0); | |
| translate(width/2, height/2); | |
| rotate(random(TWO_PI)); | |
| snowFrake(6, len); | |
| noLoop(); | |
| } | |
| void snowFrake(int depth, float l) { | |
| if (depth > 0) { | |
| float n = (int) random(3, 10); | |
| for (float angle = 0; angle < 360; angle += 360/n) { | |
| float theta = radians(angle)+random(-PI/4, PI/4); | |
| pushMatrix(); | |
| rotate(theta); | |
| stroke(0, 0, 100, 50); | |
| noFill(); | |
| float sw = map(l, 0, len, 0, 3); | |
| strokeWeight(sw); | |
| if (random(1) > 0.5) { | |
| bezier(0, 0, l/2, l/2, l/2, -l/2, l, 0); | |
| } else { | |
| bezier(0, 0, l/2, -l/2, l/2, l/2, l, 0); | |
| } | |
| //line(0, 0, l, 0); | |
| noStroke(); | |
| fill(0, 0, 100, 5); | |
| float d = map(l, 0, len, 0, 5); | |
| ellipse(l, 0, d, d); | |
| translate(l, 0); | |
| rotate(radians(360/n)/2); | |
| snowFrake(depth-1, l*0.45); | |
| popMatrix(); | |
| } | |
| } | |
| } | |
| void mousePressed() { | |
| redraw(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment