// This implementation looks for a time when the current ball location // is contacting the fixed ball, but based on the previous mouse location it was not. int radius = 20; color c = color(255); void setup() { size(500,400); } void draw() { background(204); if ((dist(width/2, height/2, mouseX, mouseY) <= 2 * radius) && (dist(width/2, height/2, pmouseX, pmouseY) > 2 * radius)) { c = color(random(255), random(255), random(255)); } fill(0); ellipse(width/2, height/2, 2*radius, 2*radius); fill(c); ellipse(mouseX, mouseY, 2*radius, 2*radius); }