summaryrefslogtreecommitdiff
path: root/html/en/func/wd.html
blob: 9c83ec5b851677acd3d4ae9a6ff2d154640150ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<!doctype HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
  <head>
    <title>World Coordinates</title>
    <meta http-equiv="Content-Language" content="en-us">
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link rel="stylesheet" type="text/css" href="../../style.css">
  </head>
  <body>
    <h2 align="center">World Coordinates</h2>
    <p>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.</p>
    <p align="center"><font size="4">Window x Viewport</font><br>
      <img src="../../img/wc-dc.gif" border="2" width="330" height="182"></p>
    <p>If you want to map coordinates from one system to another, use the <font>wdWorld2Canvas</font>
      e <font>wdCanvas2World</font> functions.
    </p>
    <p>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.</p>
    <p>All World Coordinate drawing in all drivers are simulated using other CD 
      primitives.</p>
    <hr>
    <pre class="function"><span class="mainFunction">void <a name="wdWindow">wdCanvasWindow</a>(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax); [in C]</span>
    
canvas:wWindow(xmin, xmax, ymin, ymax: number) [in Lua]</pre>
    <p>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.</p>
    <pre class="function"><span class="mainFunction">void <a name="wdGetWindow">wdCanvasGetWindow</a>(cdCanvas* canvas, double *xmin, double *xmax, double *ymin, double *ymax); [in C]</span>

canvas:wGetWindow() -&gt; (xmin, xmax, ymin, ymax: number) [in Lua]</pre>
    <p>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.</p>
    <pre class="function"><span class="mainFunction">void <a name="wdViewport">wdCanvasViewport</a>(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax); [in C]</span>

canvas:wViewport(xmin, xmax, ymin, ymax: number) [in Lua]</pre>
    <p>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 <font>(0,w-1,0,h-1)</font>. 
      If the canvas size is changed, the viewport will not be automatically updated.
    </p>
    <pre class="function"><span class="mainFunction">void <a name="wdGetViewport">wdCanvasGetViewport</a>(cdCanvas* canvas, int *xmin, int *xmax, int *ymin, int *ymax); [in C]</span>

canvas:wGetViewport() -&gt; (xmin, xmax, ymin, ymax: number) [in Lua]</pre>
    <p>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 <font>NULL</font> for the others.</p>
    <pre class="function"><span class="mainFunction">void <a name="wdWorld2Canvas">wdCanvasWorld2Canvas</a>(cdCanvas* canvas, double xw, double yw, int *xv, int *yv); [in C]</span>

canvas:wWorld2Canvas(xw, yw: number) -&gt; (xv, yv: number) [in Lua]</pre>
    <p>Converts world coordinates into canvas coordinates. It is not necessary to 
      provide all return pointers, you can provide only the desired values and <font>NULL</font>
      for the others.</p>
    <pre class="function"><span class="mainFunction">void <a name="wdCanvas2World">wdCanvasCanvas2World</a>(cdCanvas* canvas, int xv, int yv, double *xw, double *yw); [in C]</span>

canvas:wCanvas2World(xv, yv: number) -&gt; (xw, yw: number) [in Lua]</pre>
    <p>Converts canvas coordinates into world coordinates. It is not necessary to 
      provide all return pointers, you can provide only the desired values and <font>NULL</font>
      for the others.</p>
    <h3>Extra</h3>
    <pre class="function"><span class="mainFunction">void <a name="wdHardcopy">wdCanvasHardcopy</a>(cdCanvas *canvas, cdContext* ctx, void *data, void(*draw_func)(cdCanvas *canvas_copy)); [in C]</span>

canvas:wCanvasHardcopy(ctx: number, data: string or userdata, draw_func: function) [in Lua]</pre>
    <p>Creates a new canvas, 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.</p>
    <p>It is usually used for "hard copies" of drawings (print equivalent copy). The 
      most common used contexts are Printer, PS and PDF.</p>
  </body>
</html>