Expand/Shrink

cdCanvasPathSet

Definition: include pGUI.e

cdCanvasPathSet(cdCanvas canvas, integer action)
Description: Configures the action between sequences of cdCanvasVertex().
pwa/p2js: Not supported.
Comments: action can be:
  • CD_PATH_NEW - creates a new empty path. Useful if more than one path is configured. cdCanvasBegin(CD_PATH) already creates a new path.
  • CD_PATH_MOVETO - moves the current position to the given coordinates. Must be followed by 1 call to cdCanvasVertex, cdfCanvasVertex, or wdCanvasVertex.
  • CD_PATH_LINETO - adds a line to the path from the current position to the given coordinates. The current position is updated to the given coordinates.
    If there is no current position, nothing is connected and only the current position is updated.
    Must be followed by 1 call to cdCanvasVertex or wdCanvasVertex.
  • CD_PATH_ARC - adds an arc to the path. If there is a current position adds also a line from the current position to the start of the arc.
    The end of the arc becomes the current position.
    Must be followed by 3 calls to cdCanvasVertex or wdCanvasVertex.
    One for the center of the arc (xc,yc), one for the bounding rectangle size (w,h), and one for the start and end angles (angle1,angle2).
    Angles are in degrees and oriented counter-clockwise, but angle2 can be smaller than angle1 to describe a clockwise arc.
    When using integer coordinates angles must be multiplied by 1000.
  • CD_PATH_CURVETO - adds a bezier curve to the path.
    If there is no current position, the first point will be used twice.
    The end point becomes the current position.
    Must be followed by 3 calls to cdCanvasVertex or wdCanvasVertex.
    Must be first control point (x1,y1) + second control point (x2,y2) + end point (x3,y3).
  • CD_PATH_CLOSE - adds a line to the path that connects the last point with the first point of the path, closing it.
  • CD_PATH_FILL - fills the path with the current fill attributes, then the path is discarded.
  • CD_PATH_STROKE - strokes the path with the current line attributes, then the path is discarded.
  • CD_PATH_FILLSTROKE - fills the path with the current fill attributes, strokes the path with the current line attributes, then the path is discarded.
  • CD_PATH_CLIP - use the path as a clipping area to be intersected with the current clipping area, then the path is discarded.
So the normal path creation to draw a line will do:
cdCanvasBegin(canvas, CD_PATH);
cdCanvasPathSet(canvas, CD_PATH_MOVETO);
cdCanvasVertex(canvas, x1, y1);
cdCanvasPathSet(canvas, CD_PATH_LINETO);
cdCanvasVertex(canvas, x2, y2);
cdCanvasPathSet(canvas, CD_PATH_CURVETO);
cdCanvasVertex(canvas, x3, y3);  /* control point for start point */ 
cdCanvasVertex(canvas, x4, y4);  /* control point for end point */
cdCanvasVertex(canvas, x5, y5);  /* end point */
cdCanvasPathSet(canvas, CD_PATH_ARC);
cdCanvasVertex(canvas, x6, y6);  /* center */
cdCanvasVertex(canvas, x7, y7);  /* width, height */
cdCanvasVertex(canvas, x8, y8);  /* start angle, end angle (degrees / 1000) */
cdCanvasPathSet(canvas, CD_PATH_STROKE);
cdCanvasEnd(canvas);
See Also: cdCanvasBegin, cdCanvasVertex, cdCanvasEnd