HashSet<Thing> things = new HashSet<Thing>();

void setup(){
   size(500,500);
  for(int i = 0; i < 20; i++){
     things.add(new Thing());
  } 
}

void draw(){
  for(Thing t : things){
     t.move(); 
  }
}

class Thing {
   float x,y;
  float xs,ys;
  float c;
 Thing(){
    x = 250; 
    y = 250;
   c = 128; 
 }
 void move(){
    float ox = x;
    float oy = y;
    
    c += random(-1,1);
    c = constrain(c,0,250);
    
    xs += random(-1,1);
    ys += random(-1,1);
    x += xs;
    y += ys;
    stroke(c);
    line(ox,oy,x,y);
    if(x < 0 || x > 500 ||y < 0 || y > 500){
       xs *= -.5;
      ys *= -.5;
      x += xs;
     y += ys; 
    }
 }
  
}