class Circle { float x,y; // for circles float r; boolean dragging = false; // Is the object being dragged? boolean rollover = false; // Is the mouse over the ellipse? float dx,dy; // constructor Circle(float x_, float y_, float r_) { x = x_; y = y_; r = r_; } // Method to display void center_circle() { // circle in the middle ellipseMode(CENTER); noStroke(); fill(255); ellipse(x, y, 20,20); } boolean intersect(Component b) { float distance = dist(x,y,b.x,b.y); if (distance < r + b.r) { return true; } else if (distance < 250){ return true; } else { return false; } } // The methods below are for mouse interaction void clicked(int mx, int my) { float d = dist(mx,my,x,y); if (d < r) { dragging = true; dx = x-mx; dy = y-my; } } void rollover(int mx, int my) { float d = dist(mx,my,x,y); if (d < r) { rollover = true; } else { rollover = false; } } void stopDragging() { dragging = false; } void drag() { if (dragging) { x = mouseX + dx; y = mouseY + dy; } } }