The canvas represents the drawing surface. It could be anything: a file, a client area inside a window in a Window System, a paper used by a printer, etc. Each canvas has its own attributes.


You must call cdCreateCanvas to create a canvas, and cdKillCanvas when you do not need the canvas anymore. It is not necessary to activate a canvas using cdCanvasActivate, but some drivers may require that call.

To know if a feature is supported by a driver, use function cdContextCaps or see the driver's documentation.


Some canvases are buffered and need to be flushed; for that, use the cdCanvasFlush function. In some drivers, this function can also be used to change to another page, as in drivers CD_PRINTER  and CD_PS.

You can clear the drawing surface with the cdCanvasClear function, but in some drivers the function may just draw a rectangle using the background color.

Coordinate System

You may retrieve the original canvas size using the cdCanvasGetSize function. The canvas' origin is at the bottom left corner of the canvas, but an origin change can be simulated with function cdCanvasOrigin. Usually user interface libraries have their origin at the upper right corner, oriented top down. In this case, the function cdCanvasUpdateYAxis converts the Y coordinate from this orientation to CD's orientation and vice-versa.


Some canvas contents can be interpreted; the cdCanvasPlay function interprets the contents of a canvas and calls library functions for the contents to be displayed in the active canvas.