Java Reference
In-Depth Information
width
height
FIGURE 2.13 An oval and its bounding rectangle
of the arc is defined by the start angle and the ending point of the arc is defined by
the arc angle. The arc angle does not indicate where the arc ends, but rather its range.
The start angle and the arc angle are measured in degrees. The origin for the start
angle is an imaginary horizontal line passing through the center of the oval and can
be referred to as 0°, as shown in Figure 2.14.
Every graphics context has a current foreground color that is used whenever
shapes or strings are drawn. Every surface that can be drawn on has a background
color. The foreground color is set using the setColor method of the Graphics
class, and the background color is set using the setBackground method of the
component on which we are drawing, such as the applet.
Listing 2.11 shows an applet called Snowman . It uses various drawing and color
methods to draw a winter scene featuring a snowman. Review the code carefully
to note how each shape is drawn to create the overall picture.
Note that the snowman figure is based on two constant values called MID and
TOP , which define the midpoint of the snowman (left to right) and the top of the
VideoNote
Example using
drawn shapes.
90°
drawArc (10, 10, 60, 30, 20, 90)
110°
<10, 10>
20°
90°
height
30
20°
width 60
FIGURE 2.14 An arc defined by an oval, a start angle, and an arc angle
 
 
Search WWH ::




Custom Search