Simulation

CD - Canvas Draw

Simulation Base 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, 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.

In many drivers, the behavior of a given primitive may not be the expected. Usually this is documented in the manual. If 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

Clipping

  • Clipping is not implemented in the simulation base driver. The primary driver must implement its own clipping.

Attributes

  • LineCap: only CD_CAPFLAT is supported.
  • LineJoin: only CD_MITER is supported.
  • Font: Selects a True Type font file for the FreeType library to render the text. Notice that TTF fonts have different files for different font styles, like bold and italic. Font files can be in the current directory, in the directory pointed by the CDDIR environment variable, in Windows in the system defined Font directory, or using the full path of the file.
    Old name "System" is mapped to "Courier". For the know font names "Courier" (cour), "Times" (times) and "Helvetica" (arial), the styles are added to the font file name as a suffix: "bd", "i" and "bi" are used for bold, italic and bold-italic. For other fonts, it will first check for a font map added using the attribute ADDFONTMAP, if failed it will try to load the type_face name without any change, if fail it will add the style suffix to the type_face and try to load again. The ".ttf" file extension is always automatically added to the end of the file name.
    The FreeType library was configured to support only TrueType fonts, but it can be configured to support Type 1 fonts also. You may remove the FreeType code from the CD library and use any other FreeType distribution.

Primitives

  • Pixel: always uses the client's pixel function. When clipping simulation is active, it executes area and polygon clipping.
  • Line: draws lines pixel per pixel.
  • Rect: simulated using the client's Line.
  • Arc: simulated using the client's Line.
  • Sector: simulated using the client's Poly.
  • Chord: simulated using the client's Poly
  • Box: simulated using the client's Poly.
  • Begin, Vertex and End: simulate using the Line or Pixel functions, depending on the interior style.
  • Text: text simulation is made using TrueType font files in a transparent way for the user. Oriented text is not supported.

Exclusive Attributes

  • "ADDFONTMAP": Add a font map between a type face name and a file name. It has the format "Type Face=filename", For ex: "Arial Narrow Bold=ARIALNB".