I tried, but it does not work:(
i tried also larger distances from left and right edge...
Here is the
Code:
import processing.opengl.*;
int anzahl=10000;
float[][] P = new float[anzahl][2];
float pns=0.005; //Perlin noise size
float ps=10; //Patternsize Vectorfield
float w;//Winkel
float vx,vy;
float x=100,y=100,z;
float v0=1; //Geschwindigkeit
void setup(){
size(800,800,OPENGL);
background(0);
pointrand();
}
void draw(){
fill(0,100);
rect(0,0,width,height);
z+=5;
if (mousePressed && (mouseButton == RIGHT)) {
pointrand();
}
if (mousePressed && (mouseButton == LEFT)) {
feld();
}
for (int i=0;i<anzahl;i++){
x=P[i][0];
y=P[i][1];
w=noise(x*pns,y*pns,z*pns)*TWO_PI;
vx=sin(w);
vy=cos(w);
x+=vx*v0;
y+=vy*v0;
if(x < 0) x = width - 1;
if(x > width - 1) x = 0;
if(y < 0) y = height- 1;
if(y > height- 1) y = 0;
P[i][0]=x;
P[i][1]=y;
stroke(w/TWO_PI*255,255-w/TWO_PI*255,0,100);
line(x,y,x+vx*5,y+vy*5);
}
}
void feld(){
for(int x1=0;x1<width;x1+=ps){
for(int y1=0;y1<width;y1+=ps){
w=noise(x1*pns,y1*pns,z*pns)*TWO_PI;
stroke(w/TWO_PI*255,150);
line(x1,y1,x1+ps*sin(w),y1+ps*cos(w));
}
}
}
void pointrand(){
for (int i=0;i<anzahl;i++){
P[i][0]=random(0,width);
P[i][1]=random(0,height);
}
}