<!doctype HTML PUBLIC "-//IETF//DTD HTML//EN"> <html> <head> <title>Clipping</title> <meta http-equiv="Content-Language" content="en-us"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" type="text/css" href="../../style.css"> </head> <body> <h2 align="center">Clipping</h2> <p>The clipping area is an area that limits the available drawing area inside the canvas. Any primitive is drawn only inside the clipping area. It affects all primitives.</p> <p>You can set the clipping area by using the function <b>cdClipArea</b>, and retrieve it using <b>cdGetClipArea</b>. The clipping area is a rectangle by default, but it can has other shapes. In some drivers a polygon area can be defined, and in display based drivers a complex region can be defined. The complex region can be a combination of boxes, polygons, sectors, chords and texts.</p> <p>The <b>cdClip</b> function activates and deactivaes the clipping.</p> <hr> <pre class="function"><span class="mainFunction">int cdCanvasClip(cdCanvas* canvas, int mode); [in C]</span> canvas:Clip(mode: number) -> (old_mode: number) [in Lua]</pre> <p>Activates or deactivates clipping. Returns the previous status. Values: <b>CD_CLIPAREA, CD_CLIPPOLYGON, CD_CLIPREGION</b> or <b>CD_CLIPOFF</b>. The value <b>CD_QUERY</b> simply returns the current status. Default value: <b>CD_CLIPOFF</b>.</p> <p>The value <b>CD_CLIPAREA</b> activates a rectangular area as the clipping region. </p> <p>The value <b>CD_CLIPPOLYGON</b> activates a polygon as a clipping region, but works only in some drivers (please refer to the notes of each driver). The clipping polygon must be defined before activating the polygon clipping; if it is not defined, the current clipping state remains unchanged. See the documentation of <a href="polygon.html">cdBegin/cdVertex/cdEnd</a> to create a polygon.</p> <p>The value <b>CD_CLIPREGION</b> activates a complex clipping region. See the documentation of <a href="region.html">Regions</a>.</p> <pre class="function"><span class="mainFunction">void cdCanvasClipArea(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax); [in C]</span> void cdfCanvasClipArea(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax); [in C] void wdCanvasClipArea(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax); (WC) [in C] canvas:ClipArea(xmin, xmax, ymin, ymax: number) [in Lua] canvas:wClipArea(xmin, xmax, ymin, ymax: number) (WC) [in Lua]</pre> <p>Defines a rectangle for clipping. Only the points in the interval <i><b>xmin<= x <= xmax</b></i> and<b> </b><i><b>ymin <= y <= ymax</b></i> will be printed. Default region: (0, w-1, 0, h-1). </p> <pre class="function"><span class="mainFunction">int cdCanvasGetClipArea(cdCanvas* canvas, int *xmin, int *xmax, int *ymin, int *ymax); [in C]</span> int cdfCanvasGetClipArea(cdCanvas* canvas, double *xmin, double *xmax, double *ymin, double *ymax); [in C] int wdCanvasGetClipArea(cdCanvas* canvas, double *xmin, double *xmax, double *ymin, double *ymax); (WC) [in C] canvas:GetClipArea() -> (xmin, xmax, ymin, ymax, status: number) [in Lua] canvas:wGetClipArea() -> (xmin, xmax, ymin, ymax, status: number) (WC) [in Lua]</pre> <p>Returns the rectangle and the clipping status. It is not necessary to provide all return pointers, you can provide only the desired values and <i><b>NULL</b></i> for the others.</p> <h4><a name="Polygons">Polygons</a></h4> <p>A polygon for clipping can be created using <font face="Courier"><strong>cdBegin(</strong>CD_CLIP<strong>)/cdVertex(x,y)/.../cdEnd()</strong></font>.</p> <p>See the documentation of <a href="polygon.html">cdBegin/cdVertex/cdEnd</a>.</p> </body> </html>