Sabbia verticale

float dim, 
      gravita, vento;     
color fondo;
int   num;
color c,c1;

void setup()
{
   size(500, 500);
   noStroke();
   ellipseMode(CENTER); 
   fondo=color(0);
   background(fondo);
   
   int w=width, h=height;
   num=w*h/10;
   gravita=h/10;
   vento=w/25;
   dim=w/10;
}

void mousePressed()
{
   fill(200+random(55), 200+random(55), 0);
}

void keyPressed()
{
    background(fondo);
}

void draw()
{
   if(mousePressed && mouseY < height)
   {
	 float r=random(dim)+1;
	 ellipse(mouseX, mouseY+r, r, r);
   }
   loadPixels();   
   for(int i=0; i < num; i++)
   { 
	 int x =int(random(width));
	 int y =int(random(height));
	 c=pixels[width*y+x];
	 if(c != fondo)
         {
	     int y1=y+(int)random(gravita);              
             int x1=x+(int)random(-vento, +vento);
             if(y1 < height && x1 >=0 && x1 < width)
             {
                 c1=pixels[width*y1+x1];
    	         if(c1 == fondo)
	         {
                    pixels[width*y+x]=fondo;
                    pixels[width*y1+x1]=c;
	         }
             }
         }
   }  
   updatePixels();   
}