Java Reference
In-Depth Information
corner. When the arc width, arc height, width and height have the same values, the result
is a circle. If the values for width and height are the same and the values of arcWidth and
arcHeight are 0, the result is a square.
Methods draw3DRect (Fig. 13.18, line 28) and fill3DRect (line 29) take the same
arguments. The first two specify the top-left corner of the rectangle. The next two argu-
ments specify the width and height of the rectangle, respectively. The last argument deter-
mines whether the rectangle is raised ( true ) or lowered ( false ). The three-dimensional
effect of draw3DRect appears as two edges of the rectangle in the original color and two
edges in a slightly darker color. The three-dimensional effect of fill3DRect appears as two
edges of the rectangle in the original drawing color and the fill and other two edges in a
slightly darker color. Raised rectangles have the original drawing color edges at the top and
left of the rectangle. Lowered rectangles have the original drawing color edges at the
bottom and right of the rectangle. The three-dimensional effect is difficult to see in some
colors.
Methods drawOval and fillOval (lines 32-33) take the same four arguments. The
first two specify the top-left coordinate of the bounding rectangle that contains the oval.
The last two specify the width and height of the bounding rectangle, respectively.
Figure 13.21 shows an oval bounded by a rectangle. The oval touches the center of all four
sides of the bounding rectangle. (The bounding rectangle is not displayed on the screen.)
(x,y)
height
width
Fig. 13.21 | Oval bounded by a rectangle.
13.6 Drawing Arcs
An arc is drawn as a portion of an oval. Arc angles are measured in degrees. Arcs sweep
(i.e., move along a curve) from a starting angle through the number of degrees specified
by their arc angle . The starting angle indicates in degrees where the arc begins. The arc
angle specifies the total number of degrees through which the arc sweeps. Figure 13.22 il-
lustrates two arcs. The left set of axes shows an arc sweeping from zero degrees to approx-
imately 110 degrees. Arcs that sweep in a counterclockwise direction are measured in
positive degrees . The set of axes on the right shows an arc sweeping from zero degrees to
approximately -110 degrees. Arcs that sweep in a clockwise direction are measured in neg-
ative degrees . Note the dashed boxes around the arcs in Fig. 13.22. When drawing an arc,
we specify a bounding rectangle for an oval. The arc will sweep along part of the oval.
Graphics methods drawArc and fillArc for drawing arcs are summarized in Fig. 13.23.
 
 
Search WWH ::




Custom Search