class Circle { float x; float y; float rad; Circle( float xIn, float yIn, float radIn ) { x = xIn; y = yIn; rad = radIn; } } Circle[] circs; int sel = -1; void setup() { size( 600, 600 ); circs = new Circle[ 10 ]; for ( int idx = 0; idx < 10; ++idx ) { circs[idx] = new Circle( random( width ), random( height ), 20 ); } } void draw() { background( 0 ); fill( 255 ); for ( int idx = 0; idx < circs.length; ++idx ) { Circle c = circs[idx]; ellipse( c.x, c.y, 2*c.rad, 2*c.rad ); } } void mousePressed() { for ( int idx = circs.length - 1; idx >= 0; --idx ) { Circle c = circs[idx]; if ( dist( c.x, c.y, mouseX, mouseY ) < c.rad ) { sel = idx; return; } } } void mouseDragged() { Circle c = circs[sel]; c.x += mouseX - pmouseX; c.y += mouseY - pmouseY; } void mouseReleased() { sel = -1; }