CD - Canvas Draw

X-Windows Base Driver

This driver represents a basic driver for all system-dependent drivers implemented in the X-Windows system. The implementation uses the XLIB API functions. It was developed using X11R4, but works in more recent versions, such as X11R6.

Note: The coordinates internally implemented by the video driver use 16-bit integers. Therefore, if a coordinate with less than -32k or more than 32k is defined, it will be interpreted incorrectly.


Behavior of Functions

Control 

  • cdPlay: does nothing, returns CD_ERROR.

Coordinate System and Clipping

  • cdUpdateYAxis: the orientation of axis Y is the opposite to its orientation in the CD library.

Primitives

  • cdBegin: Filled  polygons have an error of one pixel to the right and below. CD_BEZIER is simulated with lines.
  • cdMark: is simulated.
  • cdBox: in Linux with ATI board, is being drawn with one extra pixel to the right and below.

Attributes

  • cdLineWidth: if width is 1, the driver will use 0 for a better performance.
  • cdLineStyle: thick lines have style only in the line's direction. For example, you will see small rectangles in a thick dotted line.
  • cdNativeFont: uses an X-Windows font string format. You can use program xfontsel to select a font and obtain the string.
  • cdFont: see the font mapping table for the equivalence used to map CD fonts into X-Windows fonts:
Font Mapping
CD Fonts X-Windows Fonts
CD_SYSTEM Fixed
CD_COURIER Courier
CD_TIMES_ROMAN Times
CD_HELVETICA Helvetica

Colors

  • cdPalette: When the number of bits per pixel is smaller than or equal to 8, the driver will use the system palette to solve colors passed as parameters to the canvas. The driver allocates colors as they are requested - if a color cannot be allocated, the closest color is used in the palette. For such, the driver sees all available colors, in the current application and others. If one of the applications is terminated, a color in the palette may become invalid and will only be updated by the driver when it is requested again. For this reason, a call to cdForeground or cdBackground or cdPalette is recommended before drawing.
    When CD_FORCE is used, the driver forces color allocation in the X server. This may imply changing colors in other applications when a cursor moves in and out of the canvas. However, if the number of requested colors is smaller than the maximum number of possible colors in the palette, then the first colors in the default system palette will be preserved, minimizing this problem.
    When CD_POLITE is used, all colors allocated by the driver are liberated, and the requested colors are allocated. This is useful for the application to prioritize the colors that will be allocated, causing other colors to be mapped to their closest colors.
    Note that canvases in the same application interfere with one another, but when a canvas is terminated it liberates all allocated colors.

Client Images

  • cdGetImageRGB: can be very slow due to the heavy conversions performed to translate data in system format into RGB vectors.

Exclusive Attributes

  • "GC":  returns the X11 graphics context (get only). In Lua is returned as a user data.