General Attributes
long int
cdForeground(long int
color); [in C]
cdForeground(color: color_tag) -> (old_color:
color_tag) [in Lua]
Configures a new current foreground color and returns the previous one. This color is used in all primitives (lines, areas, marks and text). Default value: CD_BLACK. Value CD_QUERY simply returns the current value.
long int
cdBackground(long int
color); [in C]
cdBackground(color: color_tag) -> (old_color:
color_tag) [in Lua]
Configures the new current background color and returns the previous one. However, it does not automatically change the background of a canvas. For such, it is necessary to call the cdClear function. The background color only makes sense for cdClear and for primitives affected by the background opacity attribute. Default value: CD_WHITE. Value CD_QUERY simply returns the current value.
int
cdBackOpacity(int opacity);
[in C]
cdBackOpacity(opacity: number) -> (old_opacity:
number) [in Lua]
Configures the background opacity to filling primitives based on the foreground and background colors. Values: CD_TRANSPARENT or CD_OPAQUE. If it is opaque, the text primitive, for instance, will erase whatever is in the bounding box with the background color. If it is transparent, only the foreground color is painted. The same occurs for the interior styles of hatch and stipple, and for lines with a style different from CD_CONTINUOUS. It returns the previous value. Default value: CD_TRANSPARENT. Value CD_QUERY simply returns the current value.
int
cdWriteMode(int mode); [in C]
cdWriteMode(mode: number) -> (old_mode:
number) [in Lua]
Defines the writing type for all drawing primitives. Values: CD_REPLACE, CD_XOR or CD_NOT_XOR. Returns the previous value. Default value: CD_REPLACE. Value CD_QUERY simply returns the current value.
Line Attributes
int
cdLineStyle(int style); [in C]
cdLineStyle(style: number) -> (old_style:
number) [in Lua]
Configures the current line style for: CD_CONTINUOUS, CD_DASHED, CD_DOTTED, CD_DASH_DOT or CD_DASH_DOT_DOT. Returns the previous value. Default value: CD_CONTINUOUS. Value CD_QUERY simply returns the current value.
int
cdLineWidth(int width); [in C]
double cdLineWidth(double width); (WC) [in C]
cdLineWidth(width: number) -> (old_width: number) [in Lua]
wdLineWidth(width: number) -> (old_width: number) (WC) [in
Lua]
Configures the width of the current line (in pixels). Returns the previous value. Default value: 1. Value CD_QUERY simply returns the current value. Valid width interval: >= 1.
In WC, it configures the current line width in millimeters.
Mark Attributes
int
cdMarkType(int type); [in C]
cdMarkType(type: number) -> (old_type: number)
[in Lua]
Configures the current mark type for: CD_PLUS, CD_STAR, CD_CIRCLE, CD_X, CD_BOX, CD_DIAMOND, CD_HOLLOW_CIRCLE, CD_HOLLOW_BOX or CD_HOLLOW_DIAMOND. Returns the previous value. Default value: CD_STAR. Value CD_QUERY simply returns the current value.
int
cdMarkSize(int size); [in C]
double
cdMarkSize(double size); (WC) [in C]
cdMarkSize(size: number) -> (old_size: number) [in Lua]
wdMarkSize(size: number) -> (old_size: number) (WC) [in Lua]
Configures the mark size in pixels. Returns the previous value. Default value: 10. Value CD_QUERY simply returns the current value. Valid width interval: >= 1.
In WC, it configures the current line width in millimeters.
Filling Attributes
int
cdInteriorStyle(int style);
[in C]
cdInteriorStyle(style: number) -> (old_style:
number) [in Lua]
Configures the current style for the area filling primitives: CD_SOLID, CD_HOLLOW, CD_HATCH, CD_STIPPLE or CD_PATTERN. Note that CD_HATCH and CD_STIPPLE are affected by the opacity of the current background. It returns the previous value. Default value: CD_SOLID. Value CD_QUERY simply returns the current value. If stipple or pattern are not defined, the state of the attribute is not changed. When the style CD_HOLLOW is defined, functions cdBox and cdSector behave as their equivalent cdRect and cdArc, and the polygons with style CD_FILL behave like CD_CLOSED_LINES.
int
cdHatch(int style); [in C]
cdHatch(style: number) -> (old_style: number)
[in Lua]
Selects a predefined hatch style (CD_HORIZONTAL, CD_VERTICAL, CD_FDIAGONAL, CD_BDIAGONAL, CD_CROSS or CD_DIAGCROSS) and sets the interior style to CD_HATCH. Returns the previous value. Default value: CD_HORIZONTAL. Value CD_QUERY simply returns the current value.
void
cdStipple(int w, int h, unsigned char *fgbg) [in
C]
cdStipple(stipple: stipple_tag) [in Lua]
Defines a wxh matrix of zeros and ones. The zeros are mapped to the background color or are transparent, according to the background opacity attribute. The ones are mapped to the foreground color. The function sets the interior style to CD_STIPPLE. To avoid having to deal with matrices in C, the element (i,j) of fgbg is stored as fgbg[j*w+i]. The origin is the left bottom corner of the image. It cannot be queried. It does not need to be stored by the application, as it is internally replicated by the library.
In WC, a stipple can be specified with the desired size in world coordinates. See function wdStipple.
unsigned char *
cdGetStipple(int* w, int*
h); [in C]
cdGetStipple() - > (stipple: stipple_tag) [in
Lua]
Returns the current stipple and its dimensions. Returns NULL if no stipple was defined.
void
cdPattern(int w, int h, long int *color); [in C]
cdPattern(pattern: pattern_tag) [in Lua]
Defines a new wxh color matrix and sets the interior style to CD_PATTERN. To avoid having to deal with matrices in C, the color element (i,j) is stored as color[j*w+i]. The origin is the left bottom corner of the image. It cannot be queried. It does not need to be stored by the application, as it is internally replicated by the library.
In WC, a pattern can be specified with the desired size in world coordinates. See function wdPattern.
long int *
cdGetPattern(int* w, int*
h); [in C]
cdGetPattern() - > (pattern: pattern_tag) [in
Lua]
Returns the current pattern and its dimensions. Returns NULL if no pattern was defined.
Text Attributes
void
cdFont(int typeface, int style, int size); [in
C]
void wdFont(int typeface, int style, double size); (WD)
[in C]
cdFont(typeface, style, size: number) [in Lua]
wdFont(typeface, style, size: number) (WD) [in Lua]
Selects a text font. The font type can be: CD_SYSTEM, CD_COURIER, CD_TIMES_ROMAN or CD_HELVETICA. The style can be: CD_PLAIN, CD_BOLD, CD_ITALIC or CD_BOLD_ITALIC. The size is provided in points (1/72 inch), and, to make the selection easier, CD provides three constants: CD_SMALL=8, CD_STANDARD=12 and CD_LARGE=18. Points were used here because it is a common unit to define font sizes. Default value: CD_SYSTEM, CD_PLAIN, CD_STANDARD. If you wish to specify a value in pixels, simply pass the size value in pixels providing a negative value. This way, the application will know that such value is in pixels instead of points. If you wish to specify the size in pixels but want the function to keep the value in points, use function cdPixel2MM to convert pixels into millimeters, then use the formula "(value in points) = 2.84 * (value in millimeters)" to convert from millimeters into points. Instead of 2.84, you can use the definition CD_MM2PT.
In WC, the size is specified in millimeters, but is internally passed in points.
void
cdGetFont(int *typeface, int *style, int *size);
[in C]
void wdGetFont(int *typeface, int *style, double *size);
(WC) [in C]
cdGetFont() -> (typeface, style, size: number) [in Lua]
wdGetFont() -> (typeface, style, size: number) (WC) [in Lua]
Returns the values of the font modified by function cdFont, ignoring the values modified by function cdNativeFont. It is not necessary to provide all return pointers; you can provide only the desired values.
In WC, the size is returned in millimeters.
char*
cdNativeFont(char* font);
[in C]
cdNativeFont(font: string) -> (old_font:
string) [in Lua]
Selects a native text font. The font description depends on the driver and the platform. It does not need to be stored by the application, as it is internally replicated by the library. It returns the previous string. Passing NULL as a parameter, it returns only the previous string and does not change the font. The value returned is the last attributed value, which may not correspond exactly to the font selected by the driver.
int
cdTextAlignment(int
alignment); [in C]
cdTextAlignment(alignment: number) ->
(old_alignment: number) [in Lua]
Defines the vertical and horizontal alignment of a text as: CD_NORTH, CD_SOUTH, CD_EAST, CD_WEST, CD_NORTH_EAST, CD_NORTH_WEST, CD_SOUTH_EAST, CD_SOUTH_WEST, CD_CENTER, CD_BASE_LEFT, CD_BASE_CENTER, or CD_BASE_RIGHT. Returns the previous value. Default value: CD_BASE_LEFT. Value CD_QUERY simply returns the current value.
double
cdTextOrientation(double
angle); [in C]
cdTextOrientation(angle: number) -> (old_angle:
number) [in Lua]
Defines the text orientation, which is an angle provided in degrees relative to the horizontal line according to which the text is drawn. Returns the previous value. Value CD_QUERY simply returns the current value. The default value is 0. (Notice that most drivers DO NOT implement this attribute. Currently, only the drivers derived from the basic Windows driver (except for WMF), the PS and the DXF drivers support it.)
Vector Text Attributes
void
cdVectorTextDirection(int
x1, int y1, int x2, int y2); [in C]
void wdVectorTextDirection(double x1, double y1, double
x2, double y2); (WC) [in C]
cdVectorTextDirection(x1, y1, x2, y2: number) [in Lua]
wdVectorTextDirection(x1, y1, x2, y2: number) (WC) [in Lua]
Defines the text direction by means of two points, (x1,y1) and (x2,y2). The default direction is horizontal from left to right.
double*
cdVectorTextTransform(double*
matrix); [in C]
cdVectorTextTransform(matrix: table) ->
(old_matrix: table) [in Lua]
Defines a transformation matrix with 6 elements. If the matrix is NULL, no transformation is set. The default direction is no transformation. The origin is the left bottom corner of matrix. It returns the previous matrix, and the returned vector is only valid until the following call to the function.
The matrix contains rotation and translation elements. It is applied after computing the position and orientation normal to the vector text. We can describe the elements as follows:
|x'| | cos(ang) -sin(ang) trans_x | |x| | 3 4 5| |y'| = | sin(ang) cos(ang) trans_y | * |y| with indices | 0 1 2|
void
cdVectorTextSize(int w, int
h, char *text); [in C]
void wdVectorTextSize(double size_x,
double size_y, char *s); (WC) [in C]
cdVectorTextSize(w, h: number, text: string) [in Lua]
wdVectorTextSize(w, h: number, text: string) (WC) [in Lua]
Modifies the scale of the vector text so that it corresponds to the string of the bounding box defined by w and h. It ignores strings with multiple lines.
void
cdGetVectorTextSize(char
*text, int *w, int *h); [in C]
void wdGetVectorTextSize(char * s, double *x, double *y);
(WC) [in C]
cdGetVectorTextSize(text: string) -> (w, h:
number) [in Lua]
wdGetVectorTextSize(text: string) -> (w, h: number)
(WC)
[in Lua]
Queries the string's bounding box. Ignores strings with multiple lines. It is not necessary to provide all return pointers, you can provide only the desired values.
double
cdVectorCharSize(int size);
[in C]
double wdVectorCharSize(double size); (WC) [in C]
cdVectorCharSize(size: number) -> (old_size: number) [in Lua]
wdVectorCharSize(size: number) -> (old_size: number)
(WC)
[in Lua]
Sets the height of the characters and adjusts the width according to it. Returns the previous value. CD_QUERY returns the current value.
char*
cdVectorFont(char
*filename); [in C]
cdVectorFont(filename: string) -> (font_name:
string) [in Lua]
Replaces the current vector font with a font stored in a file with a given name. Returns the name of the font loaded or NULL, if it fails. If filename is NULL, it activates the default font "Simplex II". There is no file associated to this font, it is an embedded font. The library will attempt to load a font from the directory defined by the environment variable "CDDIR", apart from the filename parameter. If it fails, it will attempt to load it using only the filename parameter. The file format is compatible with the GKS file format (text mode).
Properties
int
cdGetColorPlanes(void); [in
C]
cdGetColorPlanes() -> (bpp: number) [in Lua]
Returns a given number, for instance p, which defines the number of colors supported by the current device as 2^p, representing the number of bits by pixel.
void
cdFontDim(int *max_width, int *line_height, int
*ascent, int *descent); [in C]
void wdFontDim(double *max_width, double *height, double
*ascent, double *descent); (WC) [in C]
cdFontDim() -> (max_width, max_height, ascent, descent: number)
[in Lua]
wdFontDim() -> (max_width, max_height, ascent, descent: number)
(WC) [in Lua]
Returns the maximum width of a character, the line's height and the ascent and descent of the characters of the currently selected font. The line's height is the sum of the ascents and descents of a given additional space (if this is the case). All values are given in pixels. If the driver does not support this kind of query, the values will be given 0 (zero). It is not necessary to provide all return pointers, you can provide only the desired values.
void
cdTextSize(char *text, int *width, int *height);
[in C]
void wdTextSize(char *s, double *width, double *height);
(WC) [in C]
cdTextSize(text: string) -> (width, heigth: number)
[in Lua]
wdTextSize(text: string) -> (width, heigth: number)
(WC) [in Lua]
Returns the width and height of a text's bounding box with the currently selected font. If the driver does not support this kind of query, the values will be given 0 (zero). It is not necessary to provide all return pointers, you can provide only the desired values.
void
cdTextBox(int x, int y, char *text, int *xmin,
int *xmax, int *ymin, int *ymax); [in C]
void wdTextBox(double x, double y, char *s, double *xmin,
double *xmax, double *ymin, double *ymax); (WC) [in C]
cdTextBox(x, y: number, text: string) -> (xmin, xmax, ymin,
ymax: number) [in Lua]
wdTextBox(x, y: number, text: string) -> (xmin, xmax, ymin,
ymax: number) (WC) [in Lua]
Returns the smallest bounding horizontal rectangle of a text box, even if it is inclined. All return pointers are required.
void
cdGetVectorTextBounds(char
*s, int px, int py, int *rect); [in C]
void wdGetVectorTextBounds(char *s, double x, double y,
double *rect); (WC) [in C]
cdGetVectorTextBounds(s: string, px,py:
number) -> (rect: table) [in Lua]
wdGetVectorTextBounds(s: string, px,py: number) -> (rect:
table) (WC) [in Lua]
Returns the bounding rectangle of the text specified in the current vector font, alignment and direction. Eight values are returned, corresponding to pairs (x,y) of the rectangle's vertices ordered conter-clockwise, starting by the bottom left corner.
Color Coding
long int
cdEncodeColor(unsigned char
red, unsigned char green, unsigned char blue)
cdEncodeColor(r, g, b: number) -> (old_color:
color_tag)
Returns a codified triple (r,g,b) in a long integer such as 0x00RRGGBB, where RR are the red components, GG are the green ones and BB are the blue ones. The code is used in the CD library to define colors. There are some predefined colors: CD_RED, CD_GREEN, CD_BLUE, CD_DARK_RED, CD_DARK_GREEN, CD_DARK_BLUE, CD_YELLOW, CD_MAGENTA, CD_CYAN, CD_DARK_YELLOW, CD_DARK_MAGENTA, CD_DARK_CYAN, CD_WHITE, CD_BLACK, CD_DARK_GRAY, CD_GRAY. It can be used without an active canvas.
void
cdDecodeColor(long int
color, unsigned char *red, unsigned char *green, unsigned char *blue)
cdDecodeColor(color: color_tag) -> (r, g, b:
number)
Returns the red, green and blue components of a color in the CD library. Can be used without an active canvas.
long int
cdEncodeAlpha(long int
color, unsigned char alpha)
cdEncodeAlpha(color: color_tag, alpha: number)
-> (color: color_tag)
Returns the given color coded with the alpha information. ATENTION: In the moment this is usefull only in Win32 with GDI+ active. Se in Windows Using GDI+ Base Driver. The internal representation of the component is inverted, because the default value must be 0 and opaque for compatibility.
unsigned char
cdDecodeAlpha(long int
color)
cdDecodeAlpha(color: color_tag) -> (a: number)
Returns the alpha component of a color in the CD library. Can be used without an active canvas.
unsigned char
cdRed(long int color); [in
C]
cdRed(color: color_tag) -> (r: number)
[in Lua]
Macro that returns the red component of a color in the CD library. Can be used without an active canvas.
unsigned char
cdGreen(long int color);
[in C]
cdGreen(color: color_tag) -> (g: number)
[in Lua]
Macro that returns the green component of a color in the CD library. Can be used without an active canvas.
unsigned char
cdBlue(long int color); [in
C]
cdBlue(color: color_tag) -> (b: number)
[in Lua]
Macro that returns the blue component of a color in the CD library. Can be used without an active canvas.
void
cdPalette(int n, long int *color, int mode); [in
C]
cdPalette(palette: palette_tag; mode: number)
[in Lua]
In systems limited to 256 palette colors, this function aims at adding n colors to the system's palette. In such systems, the colors demanded forward or backward which are not in the palette are approximated to the closest available color. The type can be CD_FORCE or CD_POLITE. CD_FORCE ignores the system colors and interface elements, since the menus and dialogues may be in illegible colors, but there will be more colors available. CD_POLITE is the recommended type. It must always be used before drawing. It cannot be queried.