ArrayList flakes ; void keyPressed(){ if(key == ' ') reset(); } void reset(){ flakes = new ArrayList (); for(int x = 0; x < SPACE; x++){ for(int y = 0; y < SPACE; y++){ flakes.add(new Flake((x + .5) * width / SPACE, (y+.5) * height / SPACE)); } } } float SPACE = 4; void setup(){ size(500,500); reset(); strokeWeight(5); stroke(255); noFill(); } void draw(){ background(0,0,128); for(Flake f : flakes){ f.draw(); } } void mouseDragged(){ mouseMoved(); } void mouseMoved(){ float dx = mouseX - pmouseX; float dy = mouseY - pmouseY; for(Flake f : flakes){ f.blow(dx,dy,mouseX,mouseY); } } class Flake{ float x,y; float sz; float a,as; float dx,dy; float mx; Flake(float px, float py){ x = px; y = py; sz = random(20,60); as = random(-.05,.05); mx = random(sz/2 + random(-sz/4,sz/4)); dx = random(random(sz)); dy = random(sz/2+random(sz)); } void draw(){ pushMatrix(); translate(x,y); rotate(a); a += as; for(int i = 0; i < 6; i++){ pushMatrix(); rotate((2 * PI) * (i/6)); line(0,0,sz,0); line(mx,0,dx,dy); line(mx,0,dx,-dy); popMatrix(); } popMatrix(); as *= .99; } void blow(float dx,float dy,float mx,float my){ float ds = dist(mx,my,x,y); if(ds>sz) return; if(ds == 0.0) ds = 0.001; float m = 1; if(my > y) m *= -1; as += m*(dx)/400; } }