Class | Tioga::Using_Paths |
In: |
lib/Tioga/Using_Paths.rb
|
Parent: | Doc< FigureMaker |
These are the methods and attributes related to using previously created paths in PDF graphics operations. See also Tutorial::Tutorial::SimpleFigure.
Fill the path, using the even-odd rule to determine the region to fill. The even-odd rule determines the insideness of a point by drawing a ray from that point in any direction and simply counting the number of path segments that cross the ray, regardless of direction. If this number is odd, the point is inside; if even, the point is outside. This yields the same results as the nonzero winding number rule for paths with simple shapes, but produces different results for more complex shapes. See also fill.
Fill the path, using the nonzero winding number rule to determine the region to fill. Any subpaths that are open are implicitly closed before being filled. The nonzero winding number rule determines whether a given point is inside a path by conceptually drawing a ray from that point to infinity in any direction and then examining the places where a segment of the path crosses the ray. Starting with a count of 0, the rule adds 1 each time a path segment crosses the ray from left to right and subtracts 1 each time a segment crosses from right to left. After counting all the crossings, if the result is 0 then the point is outside the path; otherwise it is inside.
For simple convex paths, the nonzero winding number rule defines the inside and outside as one would intuitively expect. The more interesting cases are those involving complex or self-intersecting paths. For a path consisting of a five-pointed star, drawn with five connected straight line segments intersecting each other, the rule considers the inside to be the entire area enclosed by the star, including the pentagon in the center. For a path composed of nested squares, the area enclosed by both is considered to be inside, provided that both squares are drawn in the same direction. If the squares are drawn in opposite directions, only the area between them is inside, according to the nonzero winding number rule. See also eofill.
Fill and then stroke the path, using the nonzero winding number rule to determine the region to fill (see fill). This produces the same result as constructing two identical path objects, painting the first with fill and the second with stroke. Note, however, that the filling and stroking portions of the operation consult different values of several graphics state parameters, such as the current color.
Paints a line along the current path. The stroked line follows each straight or curved segment in the path, centered on the segment with sides parallel to it. Each of the path‘s subpaths is treated separately.
The results of the stroke operator depend on the current settings of various parameters in the graphics state.
NOTE: Points at which unconnected segments happen to meet or intersect receive no special treatment. In particular, connecting the ends of a subpath with an explicit add_point_to_path operator rather than with close_path may result in a messy corner, because line caps will be applied instead of a line join.
If a subpath is degenerate (consists of a single-point closed path or of two or more points at the same coordinates), the stroke operator paints it only if round line caps have been specified, producing a filled circle centered at the single point. If butt or projecting square line caps have been specified, stroke produces no output, because the orientation of the caps would be indeterminate. A single-point open subpath (specified by a trailing move_to_point operator) produces no output.