/**
flake_generator - The day 20 door for my 2010 Advent calendar
by Guru
click to generate new flakes ...
*/
void setup() {
size(300,300,P2D);
smooth();
noLoop();
}
void draw() {
background(0);
flake();
}
void mousePressed() {
redraw();
}
void flake() {
int count = (int)random(5,8);
float r1 = random(50, 100);
float r2 = random(10, 150);
float w = random( 10, 30);
fill(255);
stroke(128);
strokeWeight(2);
for (int i = 0; i < count; i++) {
pushMatrix();
translate( width/2, height/2);
rotate( i* TWO_PI / float(count));
beginShape();
vertex(0,0);
vertex( -w, r1 );
vertex( 0, r2 );
vertex( w, r1 );
endShape(CLOSE);
popMatrix();
}
}