float SIZE = 240;

PGraphics g;

Spot[] spots = new Spot[3];

void setup(){
   size(500,400); 
  g = createGraphics(500,400,P2D);

   float angle = -PI/2.0;
   for(int i = 0; i < 3; i++){
      spots[i] = new Spot(angle);
     angle += PI * 2.0 / 3.0; 
   }
   
  frameRate(1); 
   clearG();
   background(200);
}

void mousePressed(){
 x = mouseX;
 y = mouseY;
 clearG();
}
void mouseMoved(){
   frameRate((401-mouseY) / 4.0); 

}


void clearG(){
  g.background(200);
}

float x = 250; float y = 250;

void draw(){

  background(200);  
  g.beginDraw();
  g.set((int)x,(int)y,color(255,128,0));
  g.endDraw();
  image(g,0,0);

  Spot nextSpot = spots[int(random(3))];
  
  stroke(255); // fill(255);

  line(x,y,nextSpot.x,nextSpot.y);
   // ellipse(x,y,5,5);  
  x = (x + nextSpot.x) / 2.0;
  y = (y + nextSpot.y) / 2.0;
    ellipse(x,y,5,5);
stroke(0);
    ellipse(nextSpot.x,nextSpot.y,5,5);

}

class Spot{
   float x,y;
  Spot(float angle){
     x = 250+SIZE*cos(angle);
     y = 250+SIZE*sin(angle);
  } 
  void draw(){
//     set(250+x,250+y,color(0)); 
  }
  
}