/* "Stand By":- pre beta - by Alfredo Calosci, based on: Structure 3 (work in progress) A surface filled with one hundred medium to small sized circles. Each circle has a different size and direction, but moves at the same slow rate. Display: A. The instantaneous intersections of the circles B. The aggregate intersections of the circles Implemented by Casey Reas Uses circle intersection code from William Ngan Processing v.1.0.9 */ Circle circleA, circleB, circleC; void setup() { size( 768, 628 ); frameRate( 30 ); circleA = new Circle( 150, 300, 90 ); circleB = new Circle( 200, 300, 90 ); circleC = new Circle( 300, 400, 120 ); ellipseMode(CENTER_DIAMETER); //rectMode(CENTER_DIAMETER); noStroke(); smooth(); background(255); } void draw() { circleA.update(); circleB.update(); circleC.update(); //circleA.display(); //circleB.display(); //circleC.display(); intersect( circleA, circleB ); intersect( circleA, circleC ); intersect( circleB, circleC ); // tapa fill(128); noStroke(); rect(0,0,(72/4)*16,(16/4)*16); rect((120/4)*16,0,(72/4)*16,(16/4)*16); rect(0,(16/4)*16,(36/4)*16,(16/4)*16); rect((156/4)*16,(16/4)*16,(36/4)*16,(16/4)*16); } class Circle { float x, y, r, r2; float xspeed, xdir; float yspeed, ydir; Circle( float px, float py, float pr ) { x = px; y = py; r = pr; r2 = r*r; xspeed = random(-2.0, 2.0); yspeed = random(-2.0, 2.0); xdir = 1; ydir = -1; } void update() { x += xspeed * xdir; if(x > width - r || x < r) { xdir = xdir * -1; } y += yspeed * ydir; //if(y > height - r || y < r) { if(y > height || y < r) { ydir = ydir * -1; } } void display(){ stroke(0, 0, 0, 26); noFill(); ellipse(x,y,r*2,r*2); } } void intersect( Circle cA, Circle cB ) { float dx = cA.x - cB.x; float dy = cA.y - cB.y; float d2 = dx*dx + dy*dy; float d = sqrt( d2 ); if ( d>cA.r+cB.r || d