void setup() { size(600, 600); colorMode(RGB, 255); } void draw() { background(255,255,255); smooth(); strokeCap(SQUARE); float ar= width/6.0, ax=1.5*ar, ay=height/2; float br= (height-mouseY)/2.0, bx=mouseX, by=height/2; float cx=(ax+bx)/2.0, cy=(ay+by)/2.0, cr=(ar+br)/2.0; float d = bx-ax; float x=(ar-br)/d; float y=sqrt((d-ar+br)*(d+ar-br))/d; strokeWeight(1); noStroke(); fill(0,255,0); disk(ax,ay,ar); fill(0,0,255); disk(bx,by,br); fill(250,250,0); stroke(0); beginShape(); vertex(ax+x*ar,ay+y*ar); vertex(bx+x*br,by+y*br); vertex(bx+x*br,by-y*br); vertex(ax+x*ar,ay-y*ar); endShape(CLOSE); fill(255,0,0); disk(cx,cy,cr); stroke(250,250,50); line(cx+x*cr,cy-y*cr,cx+x*cr,cy+y*cr); strokeWeight(4); stroke(0); line(ax+x*ar,ay+y*ar,ax+x*ar,ay-y*ar); line(bx+x*br,by+y*br,bx+x*br,by-y*br); } void disk(float x, float y, float r) {ellipse(x, y,2*r,2*r);};