Skip to content

Instantly share code, notes, and snippets.

@takawo
Created January 27, 2017 09:16
Show Gist options
  • Select an option

  • Save takawo/6c345023603617e97c779aeeb70266fc to your computer and use it in GitHub Desktop.

Select an option

Save takawo/6c345023603617e97c779aeeb70266fc to your computer and use it in GitHub Desktop.
int depth = 6;
float len = 150;
color c2 = color(255,255,255,128);
color c1 = color(0,0,0,255);
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(depth, 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();
float m = map(_depth, 0, depth, 0, 1);
//if(_depth == depth-1) println(m);
color c = lerpColor(c1, c2, m);
rotate(theta);
stroke(c);
noFill();
float sw = map(l, 0, len, 0, 3);
strokeWeight(sw);
if (random(1) > 0.5) {
bezier(0, 0, l/2, l/n, l/n, -l/2, l, 0);
} else {
bezier(0, 0, l/2, -l/n, l/n, 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