Sabbia orizzontale

float dim,
      vento, vv;
int   num;

void setup()
{
   size(500, 350);
   background(0);
   noStroke();
   
   vento=width/10;
   vv=height/50;
   dim=height/6;
   num=width*height/6; 
}

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

void draw()
{
   if(mousePressed && mouseX < width)
   {
	  float r=random(1, dim);
	  ellipse(mouseX-r,  mouseY, r, r);
   }
   loadPixels();
   for(int i=0; i < num; i++) { // scegli un pixel 
       int x=int(random(0, width)); 
       int y=int(random(0, height)); 
       color c=pixels[width*y+x]; // copialo da qualche altra parte 
       x-=int(random(1, vento)); 
       y+=int(random(-vv, +vv)); 
       if(y >= 0 && y < height && x >=0 && x < width)
           pixels[width*y+x]=c;
   }  
   updatePixels();
}