summaryrefslogtreecommitdiff
path: root/html/en/func/lines.html
blob: cbea432b6abe39d364922edd1371704f6e68b9e0 (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<!doctype HTML PUBLIC "-//IETF//DTD HTML//EN">
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Lines</title>
<link rel="stylesheet" type="text/css" href="../../style.css">
</head>

<body>

<h2 align="center">Lines</h2>

  <p>Line are segments that connects 2 or more points. The <strong>Line</strong> 
  function includes the 2 given points and draws the line using the foreground 
  color. Line thickness is controlled by the <strong>LineWidth</strong> function. 
  By using function <strong>LineStyle</strong> you can draw dashed lines with some 
  variations. Lines with a style other than continuous are affected by the back 
  opacity attribute and by the background color.</p>

<hr>
<pre class="function"><span class="mainFunction">void <a name="cdLine">cdCanvasLine</a>(cdCanvas* canvas, int x1, int y1, int x2, int y2); [in C]
</span>void cdfCanvasLine(cdCanvas* canvas, double x1, double y1, double x2, double y2); [in C]<br>void wdCanvasLine(cdCanvas* canvas, double x1, double y1, double x2, double y2); (WC) [in C]

canvas:Line(x1, y1, x2, y2: <em>number</em>) [in Lua]
canvas:fLine(x1, y1, x2, y2: <em>number</em>) [in Lua]
canvas:wLine(x1, y1, x2, y2: <em>number</em>)<font><font> (WC) [in Lua]</font></font></pre>

  <p>Draws a line from <b>(x1,y1)</b> to <tt><b>(x2,y2)</b></tt> using 
  the current foreground color and line width and style. Both points are 
  included in the line. </p>

<pre class="function"><a name="Polygons"><strong>Polygons</strong></a><strong> and Bezier Lines</strong></pre>

  <p>Open polygons can be created using <font><strong>cdBegin(</strong></font><b>CD_OPEN_LINES</b><font><strong>)/cdVertex(x,y)/.../cdEnd()</strong></font>.</p>
  <p>Closed polygons use the same number of vertices but the last point is 
  automatically connected to the first point. Closed polygons can be created 
  using <font><strong>cdBegin(</strong></font><tt><b>CD_CLOSED_LINES</b></tt><font><strong>)/cdVertex(x,y)/.../cdEnd()</strong></font>.</p>
  <p>Bezier lines can be created using <font><strong>cdBegin(</strong></font><b>CD_BEZIER</b><font><strong>)/cdVertex(x,y)/.../cdEnd()</strong></font>. 
  At least 4 vertices must be defined. The two vertices of the middle are the 
  control vertices. A sequence of bezier lines can be defined using more 3 
  vertices, two control points and an end point, the last point of the previous 
  bezier will be used as the start point.</p>
  <p>See the documentation of <a href="polygon.html">cdBegin/cdVertex/cdEnd</a>.</p>

<pre class="function"><span class="mainFunction">void <a name="cdRect">cdCanvasRect</a>(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax); [in C]<br></span>void cdfCanvasRect(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax); [in C]
void wdCanvasRect(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax); (WC) [in C]

canvas:Rect(xmin, xmax, ymin, ymax: <em>number</em>) [in Lua]
canvas:fRect(xmin, xmax, ymin, ymax: <em>number</em>) [in Lua]<br>canvas:wRect(xmin, xmax, ymin, ymax: <em>number</em>)<font><font> (WC) [in Lua]</font></font></pre>

  <p>Draws a rectangle with no filling. All points in the limits of interval
  <font><strong>x_min&lt;=x&lt;=x_max, y_min&lt;=y&lt;=y_max</strong></font> 
  will be painted. It is affected by line attributes and the foreground color. 
  If the active driver does not include this primitive, it will be simulated 
  using the <strong><font>cdLine</font></strong> primitive.</p>

<pre class="function"><span class="mainFunction">void <a name="cdArc">cdCanvasArc</a></span><span class="mainFunction">(cdCanvas* canvas, int xc, int yc, int w, int h, double angle1, double angle2); [in C]<br></span>void cdfCanvasArc(cdCanvas* canvas, double xc, double yc, double w, double h, double angle1, double angle2); [in C]<strong>
</strong>void wdCanvasArc(cdCanvas* canvas, double xc, double yc, double w, double h, double angle1, double angle2); (WC) [in C]

canvas:Arc(xc, yc, w, h, angle1, angle2: <em>number</em>) [in Lua]
canvas:fArc(xc, yc, w, h, angle1, angle2: <em>number</em>) [in Lua]
canvas:wArc(xc, yc, w, h, angle1, angle2: <em>number</em>)<font><font> (WC) [in Lua]</font></font></pre>

  <p>Draws the arc of an ellipse aligned with the axis, using the current 
  foreground color and line width and style.</p>
<p>The 
  coordinate <b>(xc,yc)</b> defines the center of the ellipse. 
  Dimensions <b>w</b> and <b>h</b> define the elliptic axes X 
  and Y, respectively. </p>
  <p>Angles <b>angle1</b> and <b>angle2</b> are in degrees and oriented 
	counter-clockwise. They define 
  the arc start and end, but they are not the angle relative to the 
  center, except when w==h and the ellipse is reduced to a circle. The arc 
  starts at the point <b><b>(xc+(w/2)*cos(angle1), yc+(h/2)*sin(angle1))</b>
  </b>and ends at <b>(xc+(w/2)*cos(angle2), yc+(h/2)*sin(angle2))</b>.&nbsp;A 
  complete ellipse can be drawn using 0 and 360 as the angles. If <b>angle2</b> 
	is less than <b>angle1</b> it will be increased by 360 until it is greater 
	than <b>angle1</b>. </p>
  <p>The angles are specified so if the size of the ellipse (w x h) is changed, 
  its shape is preserved. So the angles relative to the center are dependent 
  from the ellipse size. The actual angle can be obtained using <b>rangle = 
  atan2((h/2</b><b>)*sin(angle), (w/2)*cos(angle))</b>.</p>
  <p>To specify the angle in radians, you can 
  use the definition <font size="2"><strong>CD_RAD2DEG</strong></font> 
  to multiply the value in radians before passing the angle to CD.</p>
  <p align="center"><font size="4">Arc Parameters<br>
  </font>&nbsp;<img src="../../img/arc.gif" border="2" width="161" height="160"></p>

<h3>Attributes</h3>
<pre class="function"><span class="mainFunction">int <a name="cdLineStyle">cdCanvasLineStyle</a>(cdCanvas* canvas, int style); [in C]</span>

canvas:LineStyle(style: <em>number</em>) -&gt; (old_style: <em>number</em>) [in Lua]</pre>

  <p>Configures the current line style for: <b>CD_CONTINUOUS</b>,  <b>CD_DASHED</b>, 
  <b>CD_DOTTED</b>, <b>CD_DASH_DOT,</b> <b>CD_DASH_DOT_DOT,</b> or <tt><b>CD_CUSTOM</b></tt>. Returns the 
  previous value. Default value: <b>CD_CONTINUOUS</b>. Value <b><b>
  CD_QUERY</b> </b>simply returns the current value. When <b>CD_CUSTOM</b> 
  is used the <b>cdLineStyleDahes</b> function must be called before to 
  initialize the custom dashes. The spaces are drawn with the background color, 
  except when back opacity is transparent then the background is left unchanged. 
  See <a href="filled.html#cdBackOpacity">BackOpacity</a>.</p>
  <p align="center"><font size="4">Line Styles</font><br>
  <img src="../../img/lines.gif" border="2" width="243" height="62"></p>

<pre class="function"><span class="mainFunction">void <a name="cdLineStyleDashes">cdCanvasLineStyleDashes</a>(cdCanvas* canvas, const int* dashes, int count); [in C]</span>

canvas:LineStyleDashes(dashes: table, count: number) -&gt; (old_style: number) [in Lua]</pre>

  <p>Defines the custom line style dashes. The first value is the length of the 
  first dash, the second value is the length of the first space, and so on. For 
  example: &quot;10 2 5 2&quot; means dash size 10, space size 2, dash size 5, space size 
  2, and repeats the pattern. Sizes are in pixels.</p>

<pre class="function"><span class="mainFunction">int <a name="cdLineWidth">cdCanvasLineWidth</a>(cdCanvas* canvas, int width); [in C]<br></span>double wdCanvasLineWidth(cdCanvas* canvas, double width_mm); (WC) [in C]

canvas:LineWidth(width: number) -&gt; (old_width: number) [in Lua]
canvas:wLineWidth(width_mm: number) -&gt; (old_width_mm: number) (WC) [in Lua]</pre>

  <p>Configures the width of the current line (in pixels). Returns the previous 
  value. Default value: 1. Value <b><b>CD_QUERY</b> </b>simply returns the 
  current value. Valid width interval: &gt;= 1.</p>
  <p>In WC, it configures the current line width in millimeters.&nbsp;</p>

<pre class="function"><span class="mainFunction">int <a name="cdLineJoin">cdCanvasLineJoin</a>(cdCanvas* canvas, int style); [in C]</span>

canvas:LineJoin(style: number) -&gt; (old_style: number) [in Lua]</pre>

  <p>Configures the current line style for: <b>CD_MITER</b>, <b>
    CD_BEVEL</b> or <tt><b>CD_ROUND</b></tt>. Returns the previous value. 
  Default value: <b>CD_MITER</b>. Value <b><b>CD_QUERY</b> </b>simply 
  returns the current value.</p>
  <p align="center"><font size="4">Line Joins</font><br>
  <img src="../../img/linejoin.gif" border="2" width="111" height="138"></p>

<pre class="function"><span class="mainFunction">int <a name="cdLineCap">cdCanvasLineCap</a>(cdCanvas* canvas, int style); [in C]</span>

canvas:LineCap(style: number) -&gt; (old_style: number) [in Lua]</pre>

  <p>Configures the current line style for: <b>CD_CAPFLAT</b>, <b>
    CD_CAPSQUARE</b> or <tt><b>CD_CAPROUND</b></tt>. Returns the previous 
  value. Default value: <b>CD_CAPFLAT</b>. Value <b><b>CD_QUERY</b>
  </b>simply returns the current value.</p>
  <p align="center"><font size="4">Line Caps</font><br>
  <img src="../../img/linecap.gif" border="2" width="211" height="166"></p>


</body>

</html>