Trying to understand your sketch better, and perlin noise too, I ended up with this.
Code:
p p[];
float globalZ=0;
void setup(){
size(screen.width,screen.height-140);
smooth();
p=new p[2000];
for(int i=0; i<p.length; i++) p[i]=new p(i/5000.0, 500, 500);
}
void draw(){
fill(0,10);
rect(0,0,width,height);//fade background
noStroke();
drawMap();
stroke(255);
for(int i=0; i<p.length; i++) p[i].update();//render particles
globalZ+= map(mouseX, 0,width, 0.001,0.03);
}
void drawMap(){
int step=8;
float val;
for(int i=0;i<width;i+=step){
for(int j=0;j<height;j+=step){
if (mouseY==0) val = 255; // doar la inceput
else val = noise(i/(float)mouseY,j/(float)mouseY, globalZ);
val = map(val,0,1, -50,300);
// if (val<128) val=0;
// else val=255;
fill(val);
rect(i,j,1,1);
}
}
}
void mousePressed(){
println("----------");
int rnd = round(random(2000));
p[rnd].x=mouseX;
p[rnd].y=mouseY;
}
class p {
float id,x,y,xp,yp,s,d;
public p(float _id,float _x,float _y) {
id=_id; // prima valoare a "adincimi", Z pentru noise
x=xp=_x;
y=yp=_y;
s=random(2,7); //speed
}
void update(){
id+=map(mouseX, 0,width, 0.001,0.05);
d=noise(x/(float)mouseY,y/(float)mouseY,globalZ) *360; // globalZ instead of id for continuity
x+=cos(radians(d))*s;
y+=sin(radians(d))*s;
if(x<0) x=xp=width;//offscreen rewind
if(x>width)x=xp=0;
if(y<0) y=yp=height;
if(y>height)y=yp=0;
line(xp,yp,x,y);
xp=x;
yp=y;
}
}