CD - Canvas Draw

World Coordinates - WC

void wdWindow(double xmin, double xmax, double ymin, double ymax); [in C]
wdWindow(xmin, xmax, ymin, ymax: number) [in Lua]

Configures a window in the world coordinate system to be used to convert world coordinates (with values in real numbers) into canvas coordinates (with values in integers). The default window is an approximation in millimeters of the whole canvas.

void wdGetWindow(double *xmin, double *xmax, double *ymin, double *ymax); [in C]
wdGetWindow() -> (xmin, xmax, ymin, ymax: number) [in Lua]

Queries the current window in the world coordinate system being used to convert world coordinates into canvas coordinates (and the other way round). It is not necessary to provide all return pointers, you can provide only the desired values.

void wdViewport(int xmin, int xmax, int ymin, int ymax); [in C]
wdViewport(xmin, xmax, ymin, ymax: number) [in Lua]

Configures a viewport in the canvas coordinate system to be used to convert world coordinates (with values in real numbers) into canvas coordinates (with values in integers). The default viewport is the whole canvas. If the canvas size is changed, the viewport will not be automatically updated.

void wdGetViewport(int *xmin, int *xmax, int *ymin, int *ymax); [in C]
wdGetViewport() -> (xmin, xmax, ymin, ymax: number) [in Lua]

Queries the current viewport in the world coordinate system being used to convert world coordinates into canvas coordinates (and the other way round). It is not necessary to provide all return pointers, you can provide only the desired values.

void wdWorld2Canvas(double xw, double yw, int *xv, int *yv); [in C]
wdWorld2Canvas(xw, yw: number) -> (xv, yv: number) [in Lua]

Converts world coordinates into canvas coordinates. It is not necessary to provide all return pointers, you can provide only the desired values.

void wdCanvas2World(int xv, int yv, double *xw, double *yw); [in C]
wdCanvas2World(xv, yv: number) -> (xw, yw: number) [in Lua]

Converts canvas coordinates into world coordinates. It is not necessary to provide all return pointers, you can provide only the desired values.


WC Attributes

void wdStipple(int w, int h, unsigned char *fgbg, double w_mm, double h_mm); [in C]
wdStipple(stipple: stipple_tag, w_mm, h_mm: number) [in Lua]

Allows specifying the stipple in world coordinates. Another stipple will be created with the size in pixels corresponding to the specified size in millimeters. The use of this function may produce very large or very small stipples.

void wdPattern(int w, int h, long int *color, double w_mm, double h_mm); [in C]
wdPattern(pattern: pattern_tag, w_mm, h_mm: number) [in Lua]

Allows specifying the pattern in world coordinates. Another pattern will be created with the size in pixels corresponding to the specified size in millimeters. The use of this function may produce very large or very small patterns.


Auxiliary WC Functions

void wdHardcopy(cdContext* ctx, void *data, cdCanvas *cnv, void(*draw_func)(void)); [in C]
wdHardcopy(ctx: number, data: string or userdata, cnv: canvas_tag, draw_func: function) [in Lua]

Creates a new canvas, activates it, prepares Window and Viewport according to the provided canvas, maintaining the aspect ratio and making the drawing occupy the largest possible area of the new canvas, calls the drawing function (which must use routines in WC) and, finally, removes the new canvas.