ArrayList<PVector> points;
float[] av;
float[] ph;
void setup(){
size(500, 500);
mousePressed();
}
void mousePressed(){
points = new ArrayList<PVector>();
colorMode(RGB, 255);
background(32);
colorMode(HSB, 360, 100, 100, 100);
stroke(random(360), 100, 100, 1);
av = new float[4];
ph = new float[4];
for(int i = 0; i < 4; i++){
av[i] = map(random(1), 0, 1, PI / 256, PI / 128);
ph[i] = random(0, TWO_PI);
}
}
void draw(){
float x = map(sin(av[0] * frameCount + ph[0]) * sin(av[1] * frameCount + ph[1]), -1, 1, 0, width);
float y = map(sin(av[2] * frameCount + ph[2]) * sin(av[3] * frameCount + ph[3]), -1, 1, 0, height);
PVector np = new PVector(x, y);
for(PVector p: points){
if(PVector.dist(p, np) < 100){
line(p.x, p.y, np.x, np.y);
}
}
points.add(np);
}