Graphics Programs Reference
In-Depth Information
Figure 5-4. Approximating a circular arc with a Bézier curve
Filled Shapes and Winding Rules
Paths may be filled as well as stroked, by substituting another operator from Ta-
ble 5-6 for the S operation we used before (here, we used B to fill and stroke the path).
Figure 5-5 shows a shape filled and stroked using the following code:
2.0 w
0.75 g Change fill color to light Gray
250 250 m Move to start of path
350 350 450 450 550 250 c First curve
450 250 350 200 y Second curve
h B Close and fill
We've used the g operator to set the fill color. This is explained in “Colors and Color
Spaces” on page 60 . For the second curve, we've used the y operator which is like c ,
except that the second control point and the end point are one and the same, so only
four operands are needed.
There are two factors distinguishing fill operators from one another:
• Whether the path is automatically closed before filling. Closing involves adding a
straight line segment from the current point to the starting point of the current
subpath. The path may be manually closed with the h operator.
• The winding rule which determines the choices made when filling an object which
is self-intersecting or made up of multiple subpaths which overlap. Figure 5-6
shows the effect of the two winding rules on both a self-intersecting object, and a
path made from two overlapping rectangular subpaths.
The code for Figure 5-6 is:
100 350 200 200 re
120 370 160 160 re f Non-zero
400 350 200 200 re
420 370 160 160 re f* Even-odd
 
Search WWH ::




Custom Search