summaryrefslogtreecommitdiff
path: root/html/en/func/clipping.html
blob: 00bbbdd3ef9f780e71eb7a46a6b813d30b43cce1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<!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>Clip</b> function activates and deactivaes the clipping.</p>
    <hr>
    <pre class="function"><span class="mainFunction">int&nbsp;cdCanvasClip(cdCanvas* canvas, int mode); [in C]</span>

canvas:Clip(mode: number) -&gt; (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>
	<p>The defined clipping area, polygon and complex regions are stored 
	internally, so you may define them independently and switch between area, 
	polygon and complex region without having to define them again. Also if the 
	active clipping region is re-defined it immediately becomes the current 
	clipping region.</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 the current rectangle for clipping. Only the points in the interval <i><b>xmin&lt;= 
          x &lt;= xmax</b></i> and<b> </b><i><b>ymin &lt;= y &lt;= ymax</b></i> will 
      be printed. Default region: (0, w-1, 0, h-1).
    </p>
    <pre class="function"><span class="mainFunction">int&nbsp;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() -&gt; (xmin, xmax, ymin, ymax, status: number) [in Lua]
canvas:wGetClipArea() -&gt; (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>