CD - Canvas Draw

Open, Closed and Filled Polygons,
Bezier Lines and
Regions Creation

The functions cdBegin, cdVertex and cdEnd are use for many situations. cdBegin is called once, cdVertex can be called many times, and cdEnd is called once to actually do something. If you call cdBegin again before cdEnd the process is restarted, except for cdBegin(CD_REGION) that can contains one or more polygons inside.


void cdBegin(int mode); [in C]
cd.Begin(mode: number) [in Lua]

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. Do not create embedded polygons, that is, do not call function cdBegin twice without a call to cdEnd in between.

  • 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 cdText will be composed in a region for clipping. See Regions documentation.

Open, Closed and Filled Polygons

Bezier Lines

void cdVertex(int x, int y); [in C]
void wdVertex(double x, double y); (WC) [in C]
cd.Vertex(x, y: number) [in Lua]
cd.wVertex(x, y: number)
(WC) [in Lua]

Adds a vertex to the polygon definition.

void cdEnd(void); [in C]
cd.End() [in Lua]

Ends the polygon's definition and draws it.