cdCanvas *cdCreateCanvas(cdContext* ctx, void *data); [in C] cd.CreateCanvas(ctx: number, data: string or userdata) -> (canvas: canvas_tag) [in Lua]
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.
The driver is set by the driver variable with additional information provided in the data parameter. Even though it is possible to create more than one canvas with the same driver/data pair, this is not recommended, and its behavior is not specified. Each canvas maintains its own features.
In case of failure, a NULL value is returned. The following predefined drivers are available:
- CD_IMAGE = Server-Image Drawing (cdimage.h).
- CD_IMAGERGB = Client-Image Drawing (cdirgb.h).
- CD_DBUFFER = Offscreen Drawing (cddbuf.h).
- CD_CGM = Computer Graphics Metafile ISO (cdcgm.h).
- CD_DGN = MicroStation Design File (cddgn.h).
- CD_DXF = AutoCad Drawing Interchange File (cddxf.h).
- CD_EMF = Microsoft Windows Enhanced Metafile (cdemf.h). Works only in MS Windows systems.
- CD_METAFILE = Metafile Canvas Draw (cdmf.h).
- CD_PS = PostScript File (cdps.h).
- CD_WMF = Microsoft Windows Metafile (cdwmf.h).
cdCanvas* cdCreateCanvasf(cdContext *ctx, const char* format, ...); [in C] [There is no equivalent in Lua]
Same as cdCreateCanvas, used in the case that the parameter data is a string composed by several parameters. This function can be used with parameters equivalent to the printf function from the default C library.
void cdKillCanvas(cdCanvas *canvas); [in C] cd.KillCanvas(canvas: canvas_tag) [in Lua]
Destroys a previously created canvas.
int cdCanvasActivate(cdCanvas *canvas); [in C] canvas:Activate(canvas: canvas_tag) -> (status: number) [in Lua]
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.
void cdCanvasDeactivate(cdCanvas* canvas); [in C] canvas:Deactivate() -> (canvas: canvas_tag) [in Lua]
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 cdCanvasActivate. On some drivers will simply call Flush.
cdContext* cdCanvasGetContext(cdCanvas *canvas); [in C] canvas:GetContext(canvas: canvas_tag) -> (ctx: number) [in Lua]
Returns the context of a given canvas, which can be compared with the predefined contexts, such as "CD_PS".
int cdContextCaps(cdContext* ctx); [in C] cd.ContextCaps(ctx: number) -> (caps: number) [in Lua]
Returns the resources available for that context. To verify if a given resource is available, perform a binary AND ('&.html with the following values:
CD_CAP_YAXIS - The Y axis has the same orientation as the CD axis.
CD_CAP_CLIPPOLY - Usually is not implemented.
CD_CAP_MARK - Marks are implemented directly in the driver (they are usually simulated).
CD_CAP_RECT - Rectangles are implemented directly in the driver (they are usually simulated).
CD_CAP_VECTORTEXT - Vector text is implemented directly in the driver (it is usually simulated).
CD_CAP_IMAGERGBA - If this is not implemented, but cdGetImageRGB is, then it is simulated using cdGetImageRGB and cdPutImageRGB.
CD_CAP_IMAGESRV - Usually is only implemented in contexts of window graphics systems (Native Window and IUP).
CD_CAP_WD - Functions of world coordinates are implemented directly in the driver (they are usually simulated).
CD_CAP_FONTDIM - If not defined, the function is implemented using an internal heuristics of the library.
CD_CAP_TEXTSIZE - If not defined, the function is implemented using an internal heuristics of the library.
CD_CAP_TEXTORIENTATION - Usually is not implemented.
CD_CAP_PALETTE - Usually is only implemented in contexts of window graphics systems (Native Window and IUP).
int cdCanvasSimulate(cdCanvas* canvas, int mode); [in C] canvas:Simulate(mode: number) -> (old_mode: number) [in Lua]
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.
If simulation is activated the driver transformation matrix is disabled.
See in the Simulation sub-driver the information on how each simulation is performed.
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:
CD_SIM_NONE - Deactivates all kinds of simulation.
CD_SIM_ALL - Activates all simulation options.
CD_SIM_LINES - Combination of CD_SIM_LINE, CD_SIM_RECT, CD_SIM_ARC and CD_SIM_POLYLINE.
CD_SIM_FILLS - Combination of CD_SIM_BOX, CD_SIM_SECTOR, CD_SIM_CHORD and CD_SIM_POLYGON.
void cdlua_open(void); [for Lua 3]
int cdlua_open(lua_State * L); [for Lua 5]
Initializes the CDLua binding. In Lua 5 the binding is lua state safe, this means that several states can be initialized any time.
void cdlua_close(void); [for Lua 3]
int cdlua_close(lua_State * L); [for Lua 5]
Releases the memory allocated by the CDLua binding.
cdCanvas* cdlua_getcanvas(void); [for Lua 3]
cdCanvas* cdlua_getcanvas(lua_State * L); [for Lua 5]
Returns the canvas in the Lua stack at index 1. The function will call lua_error if there is not a valid canvas in the stack.