/* (c) Patrik Bóna - head at wall.sk created: february 2007 share it, use it */ int n = 1000; int mode = 0; Particle[] p = new Particle[n]; void setup() { size(380, 100); for(int i = 0; i < n; i++) { p[i] = new Particle(); } frameRate(24); smooth(); noStroke(); mouseX = width/2; } void draw() { for(int i = 0; i < n; i++) { p[i].update(); } background(0); //fill(255, 100); for(int i = 0; i < n; i++) { p[i].show(); } } void mousePressed() { mode = mode == 1 ? 0 : 1; } class Particle { float x, y, r, wind = 0; color c; Particle() { initialize(); } void initialize() { //x = random(width/4, width/2 + width/4); //c = color(random(255),random(255), random(255)); c = color(100, 50); x = random(0 + 50 , width - 50); y = height + 10; r = random(6,15); } void update() { if(mouseX < width/2) { wind = - 5 * ((width/2)-mouseX)*2/width; } else { wind = 5 * (mouseX-width/2)*2/width; } x = x + random(-r/6, r/6) + wind; y = y - r/5; r -= 0.3; if(r < 1.5) { initialize(); } } void show() { fill(#FFFF00,20); if(mode == 0) { ellipse(x, y, r, r); } else { rect(x,y,r,r); } } }