CAIRO Base Driver

This driver represents a basic driver for all system-dependent drivers implemented in the X-Windows and MS-Windows systems. The implementation uses the Cairo and Pango functions. This driver can be compiled and used in all systems Cairo is supported. The drivers Native Window, Image, Printer and Double Buffer were implemented.

The main motivation for the use of Cairo was transparency for all the primitives. Beyond that we got other features like anti-aliasing, gradient filling, transformations and back-ends (support to rendering: PDF, PS, SVG and PNG surfaces).

This driver still does not completely replace the X-Windows and GDI Windows base drivers, because Cairo does not have support for bitwise XOR operations and for complex clipping regions.

So we let the programmer to choose what to use. We created the function cdUseContextPlus that allows to activate or to deactivate the use of Cairo for the available GDK, Win32 or X-Windows based drivers. This function affects only the cdCreateCanvas function call, once created the canvas will be always a Cairo canvas. In fact the function affects primary the definitions CD_NATIVEWINDOW, CD_IMAGE and CD_DBUFFER, because they are function calls and not static defines.

Using Cairo it is allowed to create more that one canvas at the same time for the same Window. And they can co-exist with a standard GDK, Win32 or X-Windows canvas.

To enable the use of Cairo based drivers you must call the initialization function cdInitContextPlus() once and link to the libraries "cdcairo" and "cairo". Also the Cairo library must be installed in your system. When using the GDK base driver you do not need to link with the "cdcairo" library.

In CDLua it is not necessary any additional initialization, and require"cdluacairo" can be used when using dynamic libraries. But when using require there are some restrictions, in Win32 the GDK base driver can NOT be used, in Linux the X11 base driver can NOT be used, and in other UNICES the GDK base driver can NOT be used.

Extra Drivers (cdcairo.h)

Only available in Lua when require"cdluacairo" is used.

CD_CAIRO_PS - PostScript Driver

Similar to CD_PS, uses the same creation parameters. But margins are not supported and Postscript level can be 2 (parameter -2) or 3 (parameter -3).

CD_CAIRO_PDF - PDF Driver

Similar to CD_PDF, uses the same creation parameters. The driver also does not depends on the PDFLib. The additional attributes "OPACITY", "PATTERN", "PDF", "PDFLIBVERSION" and the description strings, are not supported.

CD_CAIRO_SVG - Scalable Vector Graphics Driver

Similar to CD_SVG, uses the same creation parameters. The additional attributes "OPACITY" and "CMD" are not supported.

CD_CAIRO_IMAGERGB - RGB Client Image Driver

Similar to CD_IMAGERGB, uses almost the same creation parameters. The main difference is that the data pointers are packed in RGBARGBARGBA... format. So it is used only 1 pointer for data, instead of 3. Also the attributes "REDIMAGE", "GREENIMAGE", "BLUEIMAGE" and "ALPHAIMAGE are not supported and replaced by the "RGBDATA" attribute. There are also two new attributes, "STRIDE" that returns the line size in bytes, when data is specified during creation then stride is always width*32. Even when there is not alpha channel, data is stored in 32 bits per pixel. Image data is also organized in top-bottom orientation, it means the data pointer points to the top-left corner.

Behavior of Functions

Control 

Coordinate System and Clipping

Primitives

Attributes

Colors

Exclusive Attributes