CD - Canvas Draw

Simulation Driver

The Simulation driver was created to simulate functions that were not supported by some CD drivers. It works jointly with the other driver (known as "client"), using its pixel, line and text functions to simulate arcs, sectors, polygons, boxes, clipping and fillings with styles.

Important: All simulation primitives are based in the client's Pixel, Image and/or Line functions.


Use

The Simulation driver is used in several parts of the CD library. For example, most drivers do not contain the mark primitive - in this case, the mark's simulation is automatically used.

In many drivers, the behavior of a given primitive may not be the expected. Usually this is documented in the manual. Should you wish to activate the simulation of a primitive, simply call function cdSimulate with the code of the primitive to be simulated.


Behavior of Functions

Primitives

  • cdPixel: always uses the client's pixel function. When clipping simulation is active, it executes area and polygon clipping.
  • cdLine: draws lines pixel per pixel. The line clipping simulation, when possible, divides the line in several portions and draws each portion with the line function, which can be either simulated or not.
  • cdRect: the simulation is made by means of the line function.
  • cdMark: the simulation is made by means of the line function or the polygon function.
  • cdArc: simulates using the client's cdPixel. If clipping simulation is active, then the primitive will necessarily be simulated.
  • cdSector: simulates using the line function or cdPixel, depending on the interior style. If clipping simulation is active, then the primitive will necessarily be simulated.
  • cdBox: simulates using the line function or cdPixel, depending on the interior style. If clipping simulation is active and it is polygon clipping, then the primitive will necessarily be simulated.
  • cdBegin, cdVertex and cdEnd: simulate using the line function or cdPixel, depending on the interior style. If clipping simulation is active, then the primitive will necessarily be simulated. Open and Closed are simulated by calling the line function.
  • cdText: text simulation is made using TrueType font files in a transparent way for the user. Such files are in the directory pointed by the CDDIR environment variable. Other font files may be loaded by specifying the filenames, if they are in CDDIR, or the complete paths using function cdNativeFont, passing a string with the font's name and size separated by a comma. Inclined text is still not supported. Normal, Bold and/or Italic styles are defined in different font files. Clipping simulation is made by eliminating characters which are partially or completely out of the drawing region.