CMIS 141
Mousing circles
Modify the Mousing2 program so that it draws circles where the user
clicks on the applet area. Each circle is specified by two points
(two clicks), the first being the center of the circle, the second a
point on the circle. The distance from the center point to the point
on the circle is equal to the radius of the circle; this can be
calculated using the distance formula:
radius = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))
where (x1,y1) is the center and (x2,y2) is the point on the circle.
The center point needs to be translated to the upper-left corner of
the imaginary bounding rectangle of the circle:
xCorner = x1 - radius
yCorner = y2 - radius
See the MousingCircles program for what your program should look like.
You'll need a variable to know whether the first or second click has
happened. The variable could be a boolean (e.g. true its the first
click) or a counter (even its the first click, odd its the second).
Or use left and right buttons for the two clicks. The mouseClicked
method will have an if and else.
Extras:
Make each circle a random color.
Add a drawString that shows the data about each circle (center x
and y, radius, area, circumference, color's RGB values).
Add lines connecting the centers of the circles, if the user so
desires (similar to Mousing2).
Add a "starburst" on top of the circle. The starburst can be 50 lines
that start at the center and radiate outward randomly to the circle
boundary. Randomly can be done by offsetting the x and y by a number
between -radius and +radius which can be generated by:
(int)(Math.random()*2*radius - radius)
Add lines connecting every circle's center to every other circle's
center. Hint: arrays for x and y coordinates of centers.