Coordinate Systems
void cdGetCanvasSize(int *width, int *height, double *width_mm, double
*height_mm); [in C]
cdGetCanvasSize() -> (width,
heigth, mm_width, mm_height: number) [in Lua]
Returns the canvas size in pixels and in millimeters. Just as in all functions of the CD library, it is possible to ignore a return parameter by setting its pointer to NULL, that is, by calling cdGetCanvasSize(&w, &h, NULL, NULL) to obtain only the values in pixels.
void cdUpdateYAxis(int
*y); [in C]
cdUpdateYAxis(yc:
number) -> (yr: number) [in Lua]
In some graph systems, the origin is at the upper left corner of the canvas, with the direction of the Y axis pointing down. In this case, the function converts the coordinate system of the CD library into the internal system of the active canvas' driver, and the other way round. If this is not the case, nothing happens.
void cdMM2Pixel(double mm_dx, double mm_dy, int *dx,
int *dy); [in C]
cdMM2Pixel(mm_dx, mm_dy:
number) -> (dx, dy:
number)
[in Lua]
Converts sizes in millimeters into pixels (canvas coordinates). Parameters with NULL pointer are ignored.
void cdPixel2MM(int dx, int dy, double *mm_dx, double
*mm_dy); [in C]
cdPixel2MM(dx, dy:
number) -> (mm_dx, mm_dy: number) [in Lua]
Converts sizes in pixels (canvas coordinates) into millimeters. Parameters with NULL pointer are ignored. Use this function to obtain the horizontal and vertical resolution of the canvas by passing 1 as parameter in dx and dy. The resolution value is obtained using the formula res=1.0/mm.
void cdOrigin(int x, int y); [in C]
cdOrigin(x, y: number) [in Lua]
Allows translating the origin - for instance, to the center of the canvas. The function profits from the architecture of the library to simulate a translation of the origin, which in fact is never actually passed to the active canvas in the respective driver. Default values: (0, 0)
Clipping
int cdClip(int mode); [in C]
cdClip(mode: number) -> (old_mode: number) [in Lua]
Activates or deactivates clipping. Returns the previous status. Values: CD_CLIPAREA, CD_CLIPPOLYGON or CD_CLIPOFF. The value CD_QUERY simply returns the current status. Default value: CD_CLIPOFF. The value CD_CLIPAREA means the same as the old CD_CLIPON. The value CD_CLIPPOLYGON activates a polygon as a clipping region, but works only in some drivers (please refer to the notes of each driver). The clipping polygon must be defined before activating the polygon clipping; if it is not defined, the current clipping state remains unchanged. (Currently, only the drivers derived from the basic Windows driver - except for WMF -, the ones derived from the basic X-Windows driver, the PS and the METAFILE drivers support this function).
void cdClipArea(int xmin, int xmax, int ymin, int ymax); [in C]
void wdClipArea(double xmin, double xmax, double ymin, double ymax); (WC) [in C]
cdClipArea(xmin, xmax, ymin, ymax: number) [in Lua]
wdClipArea(xmin, xmax, ymin, ymax: number) (WC) [in Lua]
Defines a rectangle for clipping. Only the points in the interval: x_min<= x <= x_max, y_min <= y <= y_max will be printed. Default region: (0, w-1, 0, h-1).
int cdGetClipArea(int *xmin, int *xmax, int *ymin, int
*ymax); [in C]
int wdGetClipArea(double *xmin, double *xmax, double *ymin, double *ymax); (WC)
[in C]
cdGetClipArea() -> (xmin,
xmax, ymin, ymax, status: number) [in Lua]
wdGetClipArea() -> (xmin,
xmax, ymin, ymax, status: number) (WC) [in Lua]
Returns the rectangle and the clipping status. It is not necessary to provide all return pointers, you can provide only the desired values.
int* cdGetClipPoly(int *n); [in C]
double * wdGetClipPoly(int *n); (WC) [in C]
cdGetClipPoly() -> (n: number, points: table) [in Lua]
wdGetClipPoly() -> (n: number, points: table) (WC) [in Lua]
Returns the number of points in the clipping polygon and the polygon itself as a sequence of points, each with its respective x and y coordinates (E.g.: x1,y1,x2,y2,x3,y3,...).