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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
|
<!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>Canvas Initialization</title>
<link rel="stylesheet" type="text/css" href="../../style.css">
</head>
<body>
<h2 align="center">Canvas Initialization</h2>
<div class="function"><pre class="function"><span class="mainFunction">cdCanvas *<a name="cdCreateCanvas">cdCreateCanvas(cdContext* ctx, void *data)</a>; [in C]</span>
cd.CreateCanvas(ctx: number, data: string or userdata) -> (canvas: cdCanvas) [in Lua]</pre>
<p>Creates a CD canvas for a virtual visualization surface (VVS). A VVS may be the canvas of a user-interface window,
the page of a document sent to a printer, an offscreen image, the clipboard, a metafile, and so on. To create the
canvas, it is necessary to specify the driver in which each canvas is implemented. </p>
<p>The driver is set by the <b>driver</b> variable with additional information provided in the <tt>
<b>data</b></tt>
parameter. Even though it is possible to create more than one canvas with the same <tt>
<b>driver/data</b></tt> pair,
this is not recommended, and its behavior is not specified. Each canvas maintains its own features. </p>
<p>In case of failure, a <b>NULL</b> value is returned. The following predefined drivers are available:</p>
<p><b>Window-Base Drivers</b></p>
<ul>
<li><a href="../drv/iup.html"><b>CD_IUP</b></a> = IUP Canvas (<b>cdiup.h</b>).</li>
<li><a href="../drv/native.html"><b>CD_NATIVEWINDOW</b></a> = Native
Window (<b>cdnative.h</b>).</li>
<li><b><a href="../drv/gl.html">CD_GL</a></b> = Native
Window (<b>cdgl.h</b>).</li>
</ul>
<p><b>Device-Based Drivers</b></p>
<ul>
<li><a href="../drv/clipbd.html"><b>CD_CLIPBOARD</b></a> = Clipboard (<b>cdclipbd.h</b>).</li>
<li><a href="../drv/printer.html"><b>CD_PRINTER</b></a> = Printer (<b>cdprint.h</b>).<br>
<a href="../drv/picture.html"><strong>CD_PICTURE</strong></a> = Picture in
memory (<strong>cdpicture.h</strong>).</li>
</ul>
<p><b>Image-Based Drivers</b> </p>
<ul>
<li><a href="../drv/image.html"><b>CD_IMAGE</b></a> = Server-Image
Drawing (<b>cdimage.h</b>).</li>
<li><a href="../drv/irgb.html"><b>CD_IMAGERGB</b></a> = Client-Image
Drawing (<b>cdirgb.h</b>).</li>
<li><a href="../drv/dbuf.html"><b>CD_DBUFFER</b></a> = Offscreen Drawing
(<b>cddbuf.h</b>).</li>
<li><b><a href="../drv/dbufrgb.html">CD_DBUFFERRGB</a></b> = Client Offscreen Drawing
(<b>cddbuf.h</b>).</li>
</ul>
<p><b>File-Based Drivers</b> </p>
<ul>
<li><a href="../drv/pdf.html"><b>CD_PDF</b></a> = Adobe Portable Document Format (<b>cdpdf.h</b>).</li>
<li><a href="../drv/ps.html"><b>CD_PS</b></a> = PostScript File (<b>cdps.h</b>).</li>
<li><a href="../drv/svg.html"><b>CD_SVG</b></a> = Scalable Vector Graphics (<b>cdsvg.h</b>).</li>
<li><a href="../drv/mf.html"><b>CD_METAFILE</b></a> = Internal CD Metafile (<b>cdmf.h</b>).</li>
<li><a href="../drv/debug.html"><b>CD_DEBUG</b></a> = Internal CD Debug Log (<b>cddebug.h</b>).<br>
</li>
<li><a href="../drv/cgm.html"><b>CD_CGM</b></a> = Computer Graphics
Metafile ISO (<b>cdcgm.h</b>).</li>
<li><a href="../drv/dgn.html"><b>CD_DGN</b></a> = MicroStation Design
File (<b>cddgn.h</b>).</li>
<li><a href="../drv/dxf.html"><b>CD_DXF</b></a> = AutoCad Drawing
Interchange File (<b>cddxf.h</b>).<br>
</li>
<li><a href="../drv/emf.html"><b>CD_EMF</b></a> = Microsoft Windows
Enhanced Metafile (<b>cdemf.h</b>). Works only in MS Windows systems.</li>
<li><a href="../drv/wmf.html"><b>CD_WMF</b></a> = Microsoft Windows
Metafile (<b>cdwmf.h</b>). Works only in MS Windows systems.</li>
</ul>
</div><div class="function"><pre class="function"><span class="mainFunction">cdCanvas* <a name="cdCreateCanvasf">cdCreateCanvasf(cdContext *ctx, const char* format, ...)</a>; [in C]
</span><font>
</font>[There is no equivalent in Lua]</pre>
<p>Same as <strong><font>cdCreateCanvas</font></strong>, used in the case that the parameter <b>
<font>data</font></b> is a string composed by several parameters. This function can be used with
parameters equivalent to the <b><font>printf</font></b> function from the default C library.</p>
</div><div class="function"><pre class="function"><span class="mainFunction">void <a name="cdKillCanvas">cdKillCanvas(cdCanvas *canvas)</a>; [in C]</span>
cd.KillCanvas(canvas: cdCanvas) [in Lua]</pre>
<p>Destroys a previously created canvas. If this function is not called in
Lua, the garbage collector will call it.</p>
</div><div class="function"><pre class="function"><span class="mainFunction">int <a name="cdCanvasActivate">cdCanvasActivate</a>(cdCanvas *canvas); [in C]</span>
canvas:Activate(canvas: cdCanvas) -> (status: number) [in Lua]</pre>
<p>Activates a canvas for drawing. This is used only for a few drivers. Native
Window and IUP drivers will update the canvas size if the window size has
changed. Double Buffer driver will recreate the image buffer if the window
canvas size has changed. In these cases the function MUST be called, for other
drivers is useless. Returns CD_ERROR or CD_OK.</p>
</div><div class="function"><pre class="function"><span class="mainFunction">void <a name="cdCanvasDeactivate">cdCanvasDeactivate</a>(cdCanvas* canvas); [in C]</span>
canvas:Deactivate(canvas: cdCanvas) [in Lua]</pre>
<p>Called when the application has finished drawing in the canvas. It is
optional, but if used for the Native Window driver in Windows when the handle
can not be retained, the drawing can only be done again after a <strong>
cdCanvasActivate</strong>. On some drivers will simply call
<a href="control.html#cdFlush">Flush</a>.</p>
</div><div class="function"><pre class="function"><span class="mainFunction">int <a name="cdUseContextPlus">cdUseContextPlus</a>(int use); [in C]</span>
cd.UseContextPlus(use: boolean) -> (old_use: boolean) [in Lua]</pre>
<p>Activates or deactivates the use of an external context for the next calls of the <font face="Courier"><b>
<a href="../func/init.html#cdCreateCanvas">cdCreateCanvas</a></b></font>
function.</p>
</div><div class="function"><pre class="function"><span class="mainFunction">void <a name="cdInitContextPlus">cdInitContextPlus</a>(void); [in C]
</span>
cd.InitContextPlus() [in Lua]</pre>
<p>Initializes the context driver to use another context replacing the standard drivers.
This functions is only available when a library containing a "ContextPlus"
context driver is used. See the <a href="../drv/cairo.html">Cairo</a>, <a href="../drv/gdiplus.html">GDI+</a>
and <a href="../drv/xrender.html">XRender</a> base drivers. Those libraries does
not support XOR write mode, but has support for anti-aliasing and alpha for
transparency.</p>
<p>In Lua, when using require"cdluacontextplus" this function will be
automatically called.</p>
</div><hr><div class="function"><pre class="function"><span class="mainFunction">cdContext* <a name="cdCanvasGetContext">cdCanvasGetContext</a>(cdCanvas *canvas); [in C]</span>
canvas:GetContext(canvas: cdCanvas) -> (ctx: number) [in Lua]</pre>
<p>Returns the context of a given canvas, which can be compared with the predefined contexts, such as "CD_PS".</p>
</div><div class="function"><pre class="function"><span class="mainFunction">int <a name="cdContextCaps">cdContextCaps</a>(cdContext* ctx); [in C]</span>
cd.ContextCaps(ctx: number) -> (caps: number) [in Lua]</pre>
<p>Returns the resources available for that context. To verify if a given resource is available, perform a binary AND
('&.html with the following values:</p>
<p><font>CD_CAP_FLUSH<br>
CD_CAP_CLEAR <br>
CD_CAP_PLAY <br>
CD_CAP_YAXIS</font> - The Y axis has the same orientation as the CD axis.<br>
<font>CD_CAP_CLIPAREA <br>
CD_CAP_CLIPPOLY</font> - Usually is not implemented.<br>
<font>CD_CAP_MARK</font> - Marks are implemented directly in the driver (they are usually simulated).<br>
<font>CD_CAP_RECT</font> - Rectangles are implemented directly in the driver (they are usually
simulated).<br>
<font>CD_CAP_VECTORTEXT</font> - Vector text is implemented directly in the driver (it is usually
simulated).<br>
<font>CD_CAP_IMAGERGB <br>
CD_CAP_IMAGERGBA</font> - If this is not implemented, but <font>cdGetImageRGB</font> is, then it is
simulated using <font>cdGetImageRGB</font> and <font>cdPutImageRGB</font>.<br>
<font>CD_CAP_IMAGEMAP <br>
CD_CAP_GETIMAGERGB <br>
CD_CAP_IMAGESRV</font> - Usually is only implemented in contexts of window graphics systems (Native Window and IUP).<br>
<font>CD_CAP_BACKGROUND <br>
CD_CAP_BACKOPACITY <br>
CD_CAP_WRITEMODE <br>
CD_CAP_LINESTYLE <br>
CD_CAP_LINEWITH <br>
CD_CAP_WD</font> - Functions of world coordinates are implemented directly in the driver (they are usually
simulated).<br>
<font>CD_CAP_HATCH <br>
CD_CAP_STIPPLE <br>
CD_CAP_PATTERN <br>
CD_CAP_FONT <br>
CD_CAP_FONTDIM</font> - If not defined, the function is implemented using an internal heuristics of the library.<br>
<font>CD_CAP_TEXTSIZE</font> - If not defined, the function is implemented using an internal
heuristics of the library.<br>
<font>CD_CAP_TEXTORIENTATION</font> - Usually is not implemented.<br>
<font>CD_CAP_PALETTE</font> - Usually is only implemented in contexts of window graphics systems
(Native Window and IUP).</p>
</div><div class="function"><pre class="function"><span class="mainFunction">int <a name="cdContextType">cdContextType</a>(cdContext* ctx); [in C]</span>
cd.ContextType(ctx: number) -> (type: number) [in Lua]</pre>
<p>Returns the type of the context:</p>
<p>CD_CTX_WINDOW - GUI window based<br>
CD_CTX_DEVICE - device based (clipboard, printer, picture)<br>
CD_CTX_IMAGE - server or client image based, including double buffer based <br>
CD_CTX_FILE - metafile based</p>
</div><div class="function"><pre class="function"><span class="mainFunction">int <a name="cdContextIsPlus">cdContextIsPlus</a>(cdContext* ctx); [in C]</span>
cd.ContextIsPlus(ctx: number) -> (plus: boolean) [in Lua]</pre>
<p>Returns if it is a context plus.</p>
</div><div class="function"><pre class="function"><span class="mainFunction">int <a name="cdCanvasSimulate">cdCanvasSimulate</a>(cdCanvas* canvas, int mode); [in C]</span>
canvas:Simulate(mode: number) -> (old_mode: number) [in Lua]</pre>
<p>Activates the simulation of one or more primitives. It is ignored for the canvas
in the ImageRGB context, because in this case everything is already simulated. It also has no effect for primitives that
are usually simulated. It returns the previous simulation, but does not include primitives that are usually simulated.
The simulation can be activated at any moment. For instance, if a line simulation is required only for a situation,
the simulation can be activated for the line to be drawn, and then deactivated.</p>
<p>If simulation is activated the driver transformation matrix is disabled.</p>
<p>See in the Simulation sub-driver the information on how each simulation is performed.</p>
<p>To activate a given simulation, perform a binary OR ('|.html using one or more of the following values (in Lua, the
values must be added '+.html:</p>
<p><font>CD_SIM_NONE</font> - Deactivates all kinds of simulation.<br>
<font>CD_SIM_LINE <br>
CD_SIM_RECT <br>
CD_SIM_BOX <br>
CD_SIM_ARC <br>
CD_SIM_SECTOR <br>
CD_SIM_CHORD <br>
CD_SIM_POLYLINE <br>
CD_SIM_POLYGON <br>
CD_SIM_TEXT <br>
CD_SIM_ALL</font> - Activates all simulation options. <br>
<font>CD_SIM_LINES</font> - Combination of <font>CD_SIM_LINE, CD_SIM_RECT, CD_SIM_ARC</font>
and <font>CD_SIM_POLYLINE</font>.<br>
<font>CD_SIM_FILLS</font> - Combination of <font>CD_SIM_BOX, CD_SIM_SECTOR, CD_SIM_</font>CHORD and
<font>CD_SIM_POLYGON</font>.<br>
</p>
</div>
<h3>Extras</h3>
<div class="function"><pre class="function">int <strong><span style="font-size: 110%"><a name="cdlua_open">cdlua_open</a></span></strong>(lua_State* L); [for Lua 5]</pre>
<p>Initializes the CDLua binding. In Lua 5 the binding is lua state safe, this means that several states can be
initialized any time.</p>
</div><div class="function"><pre class="function">int <strong><span style="font-size: 110%"><a name="cdlua_close">cdlua_close</a></span></strong>(lua_State* L); [for Lua 5]</pre>
<p>Releases the memory allocated by the CDLua binding.</p>
</div><div class="function"><pre class="function">cdCanvas* <strong><span style="font-size: 110%"><a name="cdlua_getcanvas">cdlua_checkcanvas</a></span></strong>(lua_State* L, int pos); [for Lua 5]</pre>
<p>Returns the canvas in the Lua stack at position pos. The function will call lua_error if there is not a valid canvas in
the stack at the given position.</p>
</div><div class="function"><pre class="function">void <strong><span style="font-size: 110%">cdlua_pushcanvas</span></strong>(lua_State* L, cdCanvas* canvas);</pre>
<p>Pushes the given canvas into the stack.</p>
</div>
</body>
</html>
|