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 cdCanvasBegin(cdCanvas* canvas, int mode); [in C]
canvas: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 cdCanvasVertex(cdCanvas* canvas, int x, int y); [in C]
void cdfCanvasVertex(cdCanvas* canvas, double x, double y); [in C]
void wdCanvasVertex(cdCanvas* canvas, double x, double y); (WC) [in C]
canvas:Vertex(x, y: number) [in Lua]
canvas:wVertex(x, y: number) (WC) [in Lua]
Adds a vertex to the polygon definition.
void cdCanvasEnd(cdCanvas* canvas); [in C]
canvas:End() [in Lua]
Ends the polygon's definition and draws it.
"PATH": allows to create
a complex path using CD primitives and then fill, stroke or clip using the
new path. Must be used with the following parameters:
- "BEGIN" - creates a new empty path, must be the first call
- cdCanvasPixel, cdCanvasLine, cdCanvasArc - add elements to the path
instead of drawing to the canvas
- "FILL" - closes the path, and fills it with the current fill attributes,
then the path is discarded
- "STROKE" - strokes the path with the current line attributes, then the
path is discarded
- "CLOSESTROKE" - closes the path, and strokes it with the current line
attributes, then the path is discarded
- "FILLSTROKE" - closes the path, and fills it with the current fill
attributes, strokes the path with the current line attributes, then the path
is discarded
- "CLIP" - closes the path, and use it as a clipping area to be
intersected with the current clipping area, then the path is discarded
- "NULL" - discards the path and ends the process without any output.
- ARC - If there is a current point an additional straight line is drawn
from the current point to the starting point of the arc. The endpoint of the
arc becomes the new current point.