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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
<!doctype HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Coordinate System</title>
<link rel="stylesheet" type="text/css" href="../../style.css">
</head>
<body>
<h2 align="center">Coordinate System</h2>
<div class="function"><pre class="function"><span class="mainFunction">void <a name="cdGetCanvasSize">cdCanvasGetSize</a>(cdCanvas* canvas, int *width, int *height, double *width_mm, double *height_mm); [in C]</span>
canvas:GetSize() -> (width, height, mm_width, mm_height: number) [in Lua]</pre>
<p>Returns the canvas size in pixels and in millimeters. You can provide only
the desired values and <font>NULL</font> for the others.</p>
</div><div class="function"><pre class="function"><span class="mainFunction">int <a name="cdYAxisMode">cdCanvasYAxisMode</a>(cdCanvas* canvas, int invert); [in C]</span>
canvas:YAxisMode(invert: number) -> (old_invert: number) [in Lua]</pre>
<p>Returns the orientation of the Y axis. Internally in some drivers the
native axis orientation is top-bottom, so the CD primitives must invert the
Y axis since the CD orientation is bottom-top. Using CD_QUERY will return
the current Y axis mode, if needs to be inverted internally or not.</p>
<p>Using 1 or 0 you can
control if the Y axis will be inverted or not. But this is <strong>not</strong>
recommended, because it has several limitations. Only drivers that the
native axis orientation is inverted can be controlled, drivers that has the
same orientation of the CD library can not be controlled. If changed Vector
Text will always displays the text upside down.</p>
</div><div class="function"><pre class="function"><span class="mainFunction">int <a name="cdUpdateYAxis">cdCanvasUpdateYAxis</a>(cdCanvas* canvas, int *y); [in C]</span>
double cdfCanvasUpdateYAxis(cdCanvas* canvas, double *y); [in C]
int cdCanvasInvertYAxis(cdCanvas* canvas, int y); [in C]
double cdfCanvasInvertYAxis(cdCanvas* canvas, double y); [in C]
canvas:UpdateYAxis(yc: number) -> (yr: number) [in Lua]
canvas:InvertYAxis(yc: number) -> (yr: number) [in Lua]</pre>
<p>Converts the coordinate system of the CD library into the internal
system of the active canvas' driver, and the other way round, if they are
invert, or else do nothing. This is just <font>"y = height-1 -
y"</font>. It returns the changed value. The "Invert" will always invert
the given value, the "Update" function will invert only if the canvas has the
Y axis inverted.</p>
</div><div class="function"><pre class="function"><span class="mainFunction">void cdCanvasMM2Pixel(cdCanvas* canvas, double mm_dx, double mm_dy, int *dx, int *dy); [in C]</span>
void cdfCanvasMM2Pixel(cdCanvas* canvas, double mm_dx, double mm_dy, double *dx, double *dy); [in C]
canvas:MM2Pixel(mm_dx, mm_dy: number) -> (dx, dy: number) [in Lua]
canvas:fMM2Pixel(mm_dx, mm_dy: number) -> (dx, dy: number) [in Lua]</pre>
<p>Converts sizes in millimeters into pixels (canvas coordinates). You can
provide only the desired values and <font>NULL</font> for the
others.</p>
</div><div class="function"><pre class="function"><span class="mainFunction">void cdCanvasPixel2MM(cdCanvas* canvas, int dx, int dy, double *mm_dx, double *mm_dy); [in C]</span>
void cdfCanvasPixel2MM(cdCanvas* canvas, double dx, double dy, double *mm_dx, double *mm_dy); [in C]
canvas:Pixel2MM(dx, dy: number) -> (mm_dx, mm_dy: number) [in Lua]
canvas:fPixel2MM(dx, dy: number) -> (mm_dx, mm_dy: number) [in Lua]</pre>
<p>Converts sizes in pixels (canvas coordinates) into millimeters. You can
provide only the desired values and <font>NULL</font> for the
others. Use this function to obtain the horizontal and vertical resolution of
the canvas by passing 1 as parameter in <font>dx</font> and
<font>dy</font>. The resolution value is obtained using the
formula <strong><font>res=1.0/mm</font></strong>.</p>
</div><div class="function"><pre class="function"><span class="mainFunction">void cdCanvasOrigin(cdCanvas* canvas, int x, int y); [in C]</span>
void cdfCanvasOrigin(cdCanvas* canvas, double x, double y); [in C]
canvas:Origin(x, y: number) [in Lua]
canvas:fOrigin(x, y: number) [in Lua]</pre>
<p>Allows translating the origin - for instance, to the center of the canvas.
The function profits from the architecture of the library to simulate a
translation of the origin, which in fact is never actually passed to the
canvas in the respective driver. It is not related with WD nor Transformation
Matrix. Default values: (0, 0)</p>
</div><div class="function"><pre class="function"><span class="mainFunction">void cdCanvasGetOrigin(cdCanvas* canvas, int *x, int *y); [in C]</span>
void cdfCanvasGetOrigin(cdCanvas* canvas, double *x, double *y); [in C]
canvas:GetOrigin() -> (x, y: number) [in Lua]
canvas:fGetOrigin() -> (x, y: number) [in Lua]</pre>
<p>Returns the origin.</p>
</div>
<h3>Transformation Matrix</h3>
<div class="function"><pre class="function"><span class="mainFunction">void <a name="cdTransform">cdCanvasTransform</a>(cdCanvas* canvas, const double* matrix); [in C]</span>
canvas:Transform(matrix: table) [in Lua]</pre>
<p>Defines a transformation matrix with 6 elements. If the matrix is NULL,
the
transformation is reset to the identity. Default value: NULL.</p>
<p>The matrix contains scale (sx,sy), rotation (angle) and translation (dx,dy) elements as follows:</p>
<pre>|x'| |sx*cos(angle) -sin(angle) dx| |x| |0 2 4|
|y'| = | sin(angle) sy*cos(angle) dy| * |y| with indices |1 3 5|
|1|</pre>
<p>In other words:</p>
<pre>matrix[0] = sx*cos(angle) // Horizontal Scale and Rotation component
matrix[1] = sin(angle) // Rotation component (can also contain an horizontal shear component)
matrix[2] = -sin(angle) // Rotation component (can also contain a vertical shear component)
matrix[3] = sy*cos(angle) // Vertical Scale and Rotation component
matrix[4] = dx // Horizontal Translation component
matrix[5] = dy // Vertical Translation component</pre>
<p>But notice that the indices are different of the <strong>
cdCanvasVectorTextTransform</strong>.</p>
<p>Functions that retrieve images from the canvas are not affected by the
transformation matrix, such as <strong>GetImage</strong>, <strong>GetImageRGB</strong>
and <strong>ScrollArea</strong>.</p>
<p>Transformation matrix is independent of the <strong>World Coordinate</strong>
and <strong>Origin</strong>
functions. And those are affected if a transformation is set, just like other
regular primitives.</p>
<p>The transformation matrix and world coordinates perform similar
functions. World coordinates were developed before the transformation matrix
support. The transformation matrix operates at a lower level than world
coordinates, and, as such, might be faster, but might behave differently on
different platforms. World coordinates behave consistently across platforms.</p>
</div><div class="function"><pre class="function"><span class="mainFunction">double* <a name="cdGetTransform">cdCanvasGetTransform</a>(cdCanvas* canvas); [in C]</span>
canvas:GetTransformation() -> (matrix: table) [in Lua]</pre>
<p>Returns the transformation matrix. If the identity is set, returns NULL.</p>
</div><div class="function"><pre class="function"><span class="mainFunction">void <a name="cdTransformMultiply">cdCanvasTransforMultiply</a>(cdCanvas* canvas, const double* matrix); [in C]</span>
canvas:TransformMultiply(matrix: table) [in Lua]</pre>
<p>Left multiply the current transformation by the given transformation.</p>
</div><div class="function"><pre class="function"><span class="mainFunction">void <a name="cdTransformTranslate">cdCanvasTransformTranslate</a>(cdCanvas* canvas, double dx, double dy); [in C]</span>
canvas:TransformTranslate(dx, dy: number) [in Lua]</pre>
<p>Applies a translation to the current transformation.</p>
</div><div class="function"><pre class="function"><span class="mainFunction">void <a name="cdTransformScale">cdCanvasTransformScale</a>(cdCanvas* canvas, double sx, double sy); [in C]</span>
canvas:TransformScale(sx, sy: number) [in Lua]</pre>
<p>Applies a scale to the current transformation.</p>
</div><div class="function"><pre class="function"><span class="mainFunction">void <a name="cdTransformRotate">cdCanvasTransformRotate</a>(cdCanvas* canvas, double angle); [in C]</span>
canvas:TransformRotate(angle: number) [in Lua]</pre>
<p>Applies a rotation to the current transformation. Angle is in degrees,
oriented counter-clockwise from the horizontal axis.</p>
</div><div class="function"><pre class="function"><span class="mainFunction">void <a name="cdTransformPoint">cdCanvasTransformPoint</a>(cdCanvas* canvas, int x, int y, int *tx, int *ty); [in C]</span>
void cdfCanvasTransformPoint(cdCanvas* canvas, double x, double y, double *tx, double *ty); [in C]
canvas:TransformPoint(x, y: number) -> (tx, ty: number) [in Lua]
canvas:fTransformPoint(x, y: number) -> (tx, ty: number) [in Lua]</pre>
<p>Applies a transformation to a given point.</p>
</div>
</body>
</html>
|