//created=18 Nov 06
//description=Binary particle bridged area mouse follower.
//title=Mouse Folower II
//publish=true
 
blob blue;
blob red;
blob green;
 
 
void setup()
{
size(550, 700,P3D);
//noStroke();
colorMode(RGB, 255, 255, 255, 100);
rectMode(CENTER);
blue = new blob(0,0,50);
red = new blob(255,255,255);
green = new blob(128,0,0);
background(255);
 
 
}
 
void draw()
{
//background(255);
 
 
fill(255,5);
//rect(width/2,height/2,width,height);
stroke(0);
noStroke();
fill(50,50,230,80);
blue.touch();
blue.draw();
 
red.touch();
red.draw();
 
//green.touch();
//green.draw();
 
 
 
}
 
class point{
float x,y;
float dx = 0,dy = 0;
float dx2 = 0,dy2 = 0;
float lx ,ly;
float damping;
float power;
public point(){
x = random (0,width);
y = random (0,height);
damping = random(.9,.99);
power = random(10,20);
}
 
public void touch(){
//move towards the mouse
dx2 = (x - mouseX)/power;
dy2 = (y - mouseY)/power;
 
 
dx -= dx2;
dy -= dy2;
 
dx *=damping;
dy *=damping;
 
lx = x;
ly = y;
 
x += dx;
y += dy;
 
}
 
}
 
class blob{
int r,g,bl;
point a,b;
public blob (int r,int g,int bl){
a = new point();
b = new point();
this.r = r;
this.g = g;
this.bl = bl;
}
public void touch(){
a.touch();
b.touch();
}
public void draw(){
fill(r,g,bl,15);
quad(a.x,a.y,b.x,b.y,b.lx,b.ly,a.lx,a.ly);
}
 
}