World Coordinates
Allows the use of a World Coordinate System. In this system you can attribute coordinates to any unit you want. After you define a window (rectangular region) in your world, each given coordinate is then mapped to canvas coordinates to draw the primitives. You can define a viewport in your canvas to change the coordinate mapping from world to canvas. The image below shows the relation between Window and Viewport.
Window x Viewport
If you want to map coordinates from one system to another, use the wdWorld2Canvas e wdCanvas2World functions.
The quality of the picture depends on the conversion from World to Canvas, so if the canvas has a small size the picture quality will be poor. To increase picture quality create a canvas with a larger size, if possible.
void
wdWindow(double xmin, double xmax, double ymin,
double ymax); [in C]
cd.wWindow(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 the size in millimeters of the whole canvas.
void
wdGetWindow(double *xmin, double *xmax, double
*ymin, double *ymax); [in C]
cd.wGetWindow() -> (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]
cd.wViewport(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 (0,w-1,0,h-1). 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]
cd.wGetViewport() -> (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 and NULL for the others.
void
wdWorld2Canvas(double xw,
double yw, int *xv, int *yv); [in C]
cd.wWorld2Canvas(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 and NULL for the others.
void
wdCanvas2World(int xv, int
yv, double *xw, double *yw); [in C]
cd.wCanvas2World(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 and NULL for the others.
Extra
void
wdHardcopy(cdContext* ctx, void *data, cdCanvas
*cnv, void(*draw_func)(void)); [in C]
cd.wHardcopy(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.