- SEE ALSO
Prima::Drawable::Path - stroke and fill complex paths
The module augments the
Prima::Drawable drawing and plotting functionality by implementing paths that allow arbitrary combination of polylines, splines, and arcs, to be used for drawing or clipping shapes.
# draws elliptic spiral my ( $d1, $dx ) = ( 0.8, 0.05 ); $canvas-> new_path-> scale(200, 100)-> rotate(45)-> arc( 0, 0, $d1 + $dx * 0, $d1 + $dx * 1, 0, 90)-> arc( 0, 0, $d1 + $dx * 2, $d1 + $dx * 1, 90, 180)-> arc( 0, 0, $d1 + $dx * 2, $d1 + $dx * 3, 180, 270)-> arc( 0, 0, $d1 + $dx * 4, $d1 + $dx * 3, 270, 360)-> stroke;
All primitives come in two versions, with absolute and relative coordinates. The absolute version draws a graphic primitive so that its starting point (or a reference point) is at (0,0). The relative version, called with an 'r' (f.ex.
rline) has its starting point as the ending point of the previous primitive (or (0,0) if there's none).
- arc CENTER_X, CENTER_Y, DIAMETER_X, DIAMETER_Y, ANGLE_START, ANGLE_END, TILT = 0
Adds elliptic arc to path centered around (CENTER_X,CENTER_Y).
- circular_arc ANGLE_START, ANGLE_END
Adds circular arc to the path. Note that adding transformations will effectively make it into elliptic arc, which is used internally by
- ellipse CENTER_X, CENTER_Y, DIAMETER_X, DIAMETER_Y = DIAMETER_X, TILT = 0
Adds full ellipse to the path.
- line, rline @POINTS
Adds a polyline to path
- rarc DIAMETER_X, DIAMETER_Y, ANGLE_START, ANGLE_END, TILT = 0
Adds elliptic arc to path so that the first point of the arc starts on the last point of the previous primitive, or (0,0) if there's none.
- spline, rspline $POINTS, %OPTIONS.
Adds B-spline to path. See "spline" in Prima::Drawable for
Transformation calls change the current path properties (matrix etc) so that all subsequent calls will use them until a call to
restore is used.
restore implement a stacking mechanism, so that local transformations can be made.
The final transformations calculate coordinates the new and the existing matrices:
P' = NewMatrix * P
- matrix A, B, C, D, Tx, Ty
Applies transformation matrix to the path. The matrix, as used by the module, is formed as such:
A B 0 C D 0 Tx Ty 1
and when applied to 2D coordinates, is calculated as
X' = AX + CY + Tx Y' = BX + DY + Ty
- precision INTEGER
Selects current precision for splines and arcs. See "spline" in Prima::Drawable,
Pops the stack entry and replaces the current matrix and graphic properties with it.
- rotate ANGLE
Adds rotation to the current matrix
Duplicates the current matrix and graphic properties and pushes them to the stack.
- shear X, Y = X
Adds shearing to the current matrix
- scale X, Y = X
Adds scaling to the current matrix
- translate X, Y = X
Adds offset to the current matrix
These methods perform actual path rendering, that was delayed until that, and will create an array of points that can be used for actual drawing.
- clip %options
Returns 1-bit image with clipping mask of the path.
%optionscan be used to pass
fillWindingproperty that affects the result of the filled shape.
Returns 2 points that box the path.
Runs all accumulated commands, and returns rendered set of points, suitable for further calls to
Return CTM resulted after running all commands
Paints a filled shape over the path
Draws a polyline over the path
- region WINDING=0
Creates a region object from polygonal shape. If WINDING is set, applies fill winding mode (see "fillWinding" in Drawable for more).
- append PATH
Copies all commands from another PATH object. The PATH object doesn't need to have balanced stacking brackets
restore, and can be viewed as a macro.
Returns identity matrix
- matrix_apply @POINTS
Applies current matrix to POINTS, returns the transformed points. If @POINTS is a list, returns list; if it is an array reference, returns array reference.
Dmitry Karasik, <firstname.lastname@example.org>.