go to previous page   go to home page   go to next page

Answer:

A circle.


Centering a Circle

Picture of a Circle

You do not give drawOval() the center and radius of the circle you want.

To center a circle in the applet's area think in terms of the square that contains it. Put the square's center where you want the circle's center.

Say that the width and height of the drawing area is 150 by 150, then the center is at (150/2, 150/2). Subtract the radius of the circle to get the location of the upper left corner of the square that contains a centered circle:

X = (150/2 - radius)

Y = (150/2 - radius)

Similar calculations are needed to center other figures, or when you want to put a figure at some place other than the center of the drawing area.


QUESTION 6:

Say that you want a circle of radius 50 centered on the point (100, 300). What should the drawOval() command look like?

drawOval( , , ,  )