> show canvas only <


/* built with Studio Sketchpad: 
 *   https://sketchpad.cc
 * 
 * observe the evolution of this sketch: 
 *   https://ccworkshop.sketchpad.cc/sp/pad/view/ro.bDqAMq2QlL6/rev.6
 * 
 * authors: 
 *   Youssef Faltas
 *   Ammer Harb

 * license (unless otherwise specified): 
 *   creative commons attribution-share alike 3.0 license.
 *   https://creativecommons.org/licenses/by-sa/3.0/ 
 */ 




Walker[] w;
 
int total = 50;
 
void setup() {
  size(1024/2, 500/2);
  frameRate(200);
  w = new Walker[total];
  for (int i = 0; i < w.length; i++) {
    w[i] = new Walker();
  }
  
  noiseDetail(4,0.5);
}
 
void draw() {
  fill(0,120);
  rect(0,0,width,height);
  
 
  for (int i = 0; i < total; i++) {
    w[i].walk();
   
    w[i].display();
    
    for (int j = 0; j < total; j++) {
      
       // if distance between particles less than 50
       // connect them!
       
        if(dist(w[i].location.x, w[i].location.y, w[j].location.x, w[j].location.y) < 100){
            
            strokeWeight(0.8);
            stroke(222,216,31);
            line(w[i].location.x, w[i].location.y, w[j].location.x, w[j].location.y);
        }
    }
    
    
  }
}
 
// A random walker class!
 
class Walker {
  PVector location, plocation;
 
  PVector noff;
 
  Walker() {
    location = new PVector(0, 0);
    plocation = new PVector(0, 0);
    
    noff = new PVector(random(1000),random(1000));
  }
 
  void display() {
    fill(255);
    noStroke();
    ellipse(location.x, location.y, 2, 2);
    
  }
  
  
  
  // Randomly move up, down, left, right, or stay in one place
  void walk() {
    
    plocation.x = location.x;
    plocation.y = location.y;
    
    location.x = map(noise(noff.x),0,1,width,mouseX);
    location.y = map(noise(noff.y),0,1,height,mouseY);
    
    noff.x += 0.0100;
    noff.y += 0.005;
  }
}