PImage imgBlob; int nrOfBlobs=400; Blob[] blob=new Blob[400]; float gDiag; void setup() { size(400,300,P3D); noFill(); stroke(255); ellipseMode(CENTER_RADIUS); //framerate(100); imageMode(CORNER); gDiag=sqrt(sq(width)+sq(height)); imgBlob = loadImage("blob.gif"); brightToAlpha(imgBlob); for (int i=0;iwidth) { xv=-abs(xv)-abs(x+r-width)*0.1; amp+=(ampb-amp)*0.1; } if (y-r<0) { yv=abs(yv)+abs(y-r)*0.1; amp+=(ampb-amp)*0.1; } if (y+r>height) { yv=-abs(yv)-abs(y+r-height)*0.1; amp+=(ampb-amp)*0.1; } // random movement: xv+=random(-0.05,0.05); yv+=random(-0.05,0.05); // urge to go to the mouse: xv+=(width/2.0-x)*0.0001; yv+=(height/2.0-y)*0.0001; int nrOfConnections=0; // check if intersecting with one of the other blobs: for (int i=0;i0) { // if touching or further: if (ds>2*(blob[i].r+r)) { // disconnect if over a certain distance: connected[i]=false; blob[i].connected[id]=false; } else { // else draw to eachother xv+=(blob[i].x-x)*0.001; yv+=(blob[i].y-y)*0.001; } } else { // go away from each other to avoid overlap; xv+=(x-blob[i].x)*0.001; yv+=(y-blob[i].y)*0.001; amp+=(ampb-amp)*0.04; } } } } // break if too many connections: if (nrOfConnections>3) { for (int i=0;i