coordinates

CD - Canvas Draw

Complex Clipping Regions

A complex region can composed of boxes, sectors, chords, polygons and texts.

It is implemented only in the Windows GDI, GDI+ and X-Windows base drivers.


Creating

Complex clipping regions can be created using cdBegin(CD_REGION)/(filled primtives)/.../cdEnd(). For more about cdBegin and cdEnd see Polygons.

Between a cdBegin(CD_REGION) and a cdEnd(), all calls to cdBox, cdSector, cdChord, cdBegin(CD_FILL)/cdVertex(x,y)/.../cdEnd() and cdText will be composed in a region for clipping. This is the only exception when you can call a cdBegin after another cdBegin.

When you call cdBegin(CD_REGION) a new empty region will be created. So for the first operation you should use CD_UNION or CD_NOTINTERSECT combine modes. When you finished to compose the region call cdEnd().

To make the region active you must call cdClip(CD_CLIPREGION). For other clipping regions see Clipping.

int cdRegionCombineMode(int mode); [in C]
cd.RegionCombineMode(mode: number) -> (old_mode: number) [in Lua]

Changes the way regions are combined when created. Returns the previous status. Values: CD_UNION, CD_INTERSECT, CD_DIFFERENCE or CD_NOTINTERSECT. The value CD_QUERY simply returns the current status. Default value: CD_UNION.

Combine Modes

int cdPointInRegion(int x, int y); [in C]
cd.PointInRegion(x, y: number) -> (status: number) [in Lua]

Returns a non zero value if the point is contained inside the current region.

void cdOffsetRegion(int dx, int dy); [in C]
void wdOffsetRegion(double dx, double dy); (WC) [in C]
cd.OffsetRegion(dx, dy: number) [in Lua]
cd.wOffsetRegion(dx, dy: number) (WC) [in Lua]

Moves the current region by the given offset. In X-Windows, if the region moves to outside the canvas border, the part moved outside will be lost, the region will need to be reconstruted.

void cdRegionBox(int *xmin, int *xmax, int *ymin, int *ymax); [in C]
void wdRegionBox(double *xmin, double *xmax, double *ymin, double *ymax); (WC) [in C]
cd.RegionBox() -> (xmin, xmax, ymin, ymax, status: number) [in Lua]
cd.wRegionBox() -> (xmin, xmax, ymin, ymax, status: number) (WC) [in Lua]

Returns the rectangle of the bounding box of the current region. It is not necessary to provide all return pointers, you can provide only the desired values and NULL for the others.