Java also provides a method for drawing ovals (circular areas). The student
will use it in exactly the same was as drawRect:
g.drawOval(40,40,100,50);This example will draw an oblong oval (an ellipse) which is 100 units long and 50 units high. Its upper-left corner is at (40,40).
To make a circle the student will simply make sure that the last two
parameter are the same since a circle is as tall as it is wide:
g.drawOval(100, 10, 60, 60);This line will create a circle with a diameter of 60 with its upper-left corner at (100,10).
NOTE ON UPPER-LEFT CORNERS: An upper-left corner refers to the upper-left
corner of the bounding rectangle which contains the circle. The edge of the
circle will not actually touch this point.
EXAMPLE: This applet is an approximation of what the student will be expected to create. No code will be offered since the student will need to experiment with the use of the drawOval method to successfully complete this activity. |
x |
ASSIGNMENT:
The student will simply recreate (as closely as possible) the configuration
of ovals on the applet displayed on this page. The student will notice that
some of the ellipses in this applet are oblong on the vertical axis and
others are oblong on the horizontal axis. There is one perfect circle.