summaryrefslogtreecommitdiff
path: root/html/en/func/wd.html
blob: ebd97935a817e4b728f466e896a5527836e81971 (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<!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>
	<strong>wdWorld2Canvas</strong></font>
      e <font><strong>wdCanvas2World</strong></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 and do NOT depend or use the <strong>cdCanvasTransform</strong> 
	transformation matrix.</p>
    <hr>
    <div class="function"><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>
    </div><div class="function"><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>
    </div><div class="function"><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>
    </div><div class="function"><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>
    </div><div class="function"><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>
    </div><div class="function"><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>
      
    </div><div class="function"><pre class="function"><span class="mainFunction">void <a name="wdSetTransform">wdCanvasSetTransform</a>(cdCanvas* canvas, double sx, double sy, double tx, double ty); [in C]</span>
    
canvas:wSetTransform(sx, sy, tx, ty: number) [in Lua]</pre>
    <p>Configures the world coordinate system transformation to be used to 
	convert world coordinates (with values in real numbers) into canvas 
	coordinates (with values in integers). The transformation is automatically 
	set by <strong>wdCanvasWindow</strong> and <strong>wdCanvasViewport</strong>. 
	This has NO relation with <strong>cdCanvasTransform</strong>.</p>
    </div><div class="function"><pre class="function"><span class="mainFunction">void <a name="wdGetTransform">wdCanvasGetTransform</a>(cdCanvas* canvas, double *sx, double *sy, double *tx, double *ty); [in C]</span>

canvas:wGetTransform() -&gt; (sx, sy, tx, ty: number) [in Lua]</pre>
    <p>Queries the current transformation 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>
      
    </div><div class="function"><pre class="function"><span class="mainFunction">void <a name="wdTranslate">wdCanvasTranslate</a>(cdCanvas* canvas, double dtx, double dty); [in C]</span>
    
canvas:wTranslate(dtx, dty: number) [in Lua]</pre>
    <p>Translates the transformation by a delta, by adding the given values to 
	the current tx and ty values.</p>

    </div><div class="function"><pre class="function"><span class="mainFunction">void <a name="wdScale">wdCanvasScale</a>(cdCanvas* canvas, double dsx, double dsy); [in C]</span>
    
canvas:wScale(dsx, dsy: number) [in Lua]</pre>
    <p>Scales the transformation by a delta, by multiplying the given values by 
	the current sx and sy values.</p></div>
      
    <h3>Extra</h3>
    <div class="function"><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>
      </div>
  </body>
</html>