Expand/Shrink

cdCanvasBegin

Definition: include pGUI.e

cdCanvasBegin(cdCanvas canvas, integer mode)
Description: Starts defining a polygon to be drawn (or filled) according to the mode: CD_CLOSED_LINES, CD_OPEN_LINES, CD_FILL, CD_CLIP, CD_REGION or CD_BEZIER.
  • CD_OPEN_LINES: connects all the points at cdEnd. Depends on line width and line style attributes.
  • CD_CLOSED_LINES: connects all the points at cdEnd and connects the last point to the first. Depends on line width and line style attributes.
  • CD_FILL: connects the last point to the first and fills the resulting polygon according to the current interior style. When the interior style CD_HOLLOW is defined the it behaves as if the mode were CD_CLOSED_LINES.
  • CD_CLIP: instead of creating a polygon to be drawn, creates a polygon to define a polygonal clipping region.
  • CD_BEZIER: defines the points of a bezier curve. There must be at least 4 points: start, control, control and end. To specify a sequence of curves use 3 more points for each curve: control, control, end, control, control, end, ... The end point is used as start point for the next curve.
  • CD_REGION: starts the creation of a complex region for clipping. All calls to cdBox, cdSector, cdChord, Filled Polygons and cdCanvasText will be composed in a region for clipping. See Regions documentation.
  • CD_PATH: creates a path composed of several primitives that can be line draw, filled or used as clipping. Must call cdCanvasPathSet to configure the action between sequences of cdCanvasVertex.
Open, Closed and Filled Polygons

Bezier Lines

Do not create embedded polygons, that is, do not call function cdCanvasBegin twice without a call to cdCanvasEnd in between.
pwa/p2js: Supported. Note that on desktop/Phix, cdCanvasEnd() in effect implies a cdCanvasBegin() call for subsequent cdCanvasVertex() (quite probably more by accident or convenience than deliberate design), whereas under pwa/p2js an explicit call to cdCanvasBegin() is required each time, otherwise all the vertices end up being accumulative and intermeshed (which might actually have been entirely intentional for the HTML5 canvas primitives this routine wraps on that platform). Should it become necessary I may reconsider adding various flags (etc) to mimic desktop/Phix more accurately, or perhaps go the other way and start adding HTML5 capabilities to the desktop.
Comments: The functions cdCanvasBegin, cdCanvasVertex and cdCanvasEnd are used for many situations.
cdCanvasBegin is called once, cdCanvasVertex can be called many times, and cdCanvasEnd is called once to actually do something.
If you call cdCanvasBegin again before cdCanvasEnd the process is restarted, except for cdCanvasBegin(CD_REGION) that can contain one or more polygons inside.
See Also: cdCanvasVertex, cdCanvasEnd