summaryrefslogtreecommitdiff
path: root/cd/src/lua3/toluawd.c
blob: 2549bcca83c5b0e4f8203b6a1fc2e70d4132ade6 (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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#include <stdlib.h>
#include <stdio.h>

#include <lua.h>
#include <lauxlib.h>

#include "cd.h"
#include "wd.h"

#include "cdlua.h"
#include "cdlua3_private.h"


static void L_wdWindow(void)
{
 double xmin = (double)luaL_check_number(1);
 double xmax = (double)luaL_check_number(2);
 double ymin = (double)luaL_check_number(3);
 double ymax = (double)luaL_check_number(4);
 wdWindow(xmin,xmax,ymin,ymax);
}

static void L_wdViewport(void)
{
 int xmin = (int)luaL_check_number(1);
 int xmax = (int)luaL_check_number(2);
 int ymin = (int)luaL_check_number(3);
 int ymax = (int)luaL_check_number(4);
 wdViewport(xmin,xmax,ymin,ymax);
}

static void L_wdClipArea(void)
{
 double xmin = (double)luaL_check_number(1);
 double xmax = (double)luaL_check_number(2);
 double ymin = (double)luaL_check_number(3);
 double ymax = (double)luaL_check_number(4);
 wdClipArea(xmin,xmax,ymin,ymax);
}

static void L_wdLine(void)
{
 double x1 = (double)luaL_check_number(1);
 double y1 = (double)luaL_check_number(2);
 double x2 = (double)luaL_check_number(3);
 double y2 = (double)luaL_check_number(4);
 wdLine(x1,y1,x2,y2);
}

static void L_wdBox(void)
{
 double xmin = (double)luaL_check_number(1);
 double xmax = (double)luaL_check_number(2);
 double ymin = (double)luaL_check_number(3);
 double ymax = (double)luaL_check_number(4);
 wdBox(xmin,xmax,ymin,ymax);
}

static void L_wdRect(void)
{
 double xmin = (double)luaL_check_number(1);
 double xmax = (double)luaL_check_number(2);
 double ymin = (double)luaL_check_number(3);
 double ymax = (double)luaL_check_number(4);
 wdRect(xmin,xmax,ymin,ymax);
}

static void L_wdArc(void)
{
 double xc = (double)luaL_check_number(1);
 double yc = (double)luaL_check_number(2);
 double w = (double)luaL_check_number(3);
 double h = (double)luaL_check_number(4);
 double angle1 = (double)luaL_check_number(5);
 double angle2 = (double)luaL_check_number(6);
 wdArc(xc,yc,w,h,angle1,angle2);
}

static void L_wdSector(void)
{
 double xc = (double)luaL_check_number(1);
 double yc = (double)luaL_check_number(2);
 double w = (double)luaL_check_number(3);
 double h = (double)luaL_check_number(4);
 double angle1 = (double)luaL_check_number(5);
 double angle2 = (double)luaL_check_number(6);
 wdSector(xc,yc,w,h,angle1,angle2);
}

static void L_wdChord(void)
{
 double xc = (double)luaL_check_number(1);
 double yc = (double)luaL_check_number(2);
 double w = (double)luaL_check_number(3);
 double h = (double)luaL_check_number(4);
 double angle1 = (double)luaL_check_number(5);
 double angle2 = (double)luaL_check_number(6);
 wdChord(xc,yc,w,h,angle1,angle2);
}

static void L_wdText(void)
{
 double x = (double)luaL_check_number(1);
 double y = (double)luaL_check_number(2);
 char* s = (char*)luaL_check_string(3);
 wdText(x,y,s);
}

static void L_wdVertex(void)
{
 double x = (double)luaL_check_number(1);
 double y = (double)luaL_check_number(2);
 wdVertex(x,y);
}

static void L_wdMark(void)
{
 double x = (double)luaL_check_number(1);
 double y = (double)luaL_check_number(2);
 wdMark(x,y);
}

static void L_wdOffsetRegion(void)
{
 double x = (double)luaL_check_number(1);
 double y = (double)luaL_check_number(2);
 wdOffsetRegion(x,y);
}

static void L_wdPointInRegion(void)
{
 double x = (double)luaL_check_number(1);
 double y = (double)luaL_check_number(2);
 int L_result = wdPointInRegion(x,y);
 lua_pushnumber((double)L_result);
}

static void L_wdLineWidth(void)
{
 double width = (double)luaL_check_number(1);
 double L_result = wdLineWidth(width);
 lua_pushnumber(L_result);
}

static void L_wdFont(void)
{
 int type_face = (int)luaL_check_number(1);
 int style = (int)luaL_check_number(2);
 double size = (double)luaL_check_number(3);
 wdFont(type_face,style,size);
}

static void L_wdMarkSize(void)
{
 double size = (double)luaL_check_number(1);
 double L_result = wdMarkSize(size);
 lua_pushnumber(L_result);
}

static void L_wdVectorTextDirection(void)
{
 double x1 = (double)luaL_check_number(1);
 double y1 = (double)luaL_check_number(2);
 double x2 = (double)luaL_check_number(3);
 double y2 = (double)luaL_check_number(4);
 wdVectorTextDirection(x1,y1,x2,y2);
}

static void L_wdVectorTextSize(void)
{
 double size_x = (double)luaL_check_number(1);
 double size_y = (double)luaL_check_number(2);
 char* s = (char*)luaL_check_string(3);
 wdVectorTextSize(size_x,size_y,s);
}

static void L_wdVectorCharSize(void)
{
 double size = (double)luaL_check_number(1);
 double L_result = wdVectorCharSize(size);
 lua_pushnumber(L_result);
}

static void L_wdVectorText(void)
{
 double x = (double)luaL_check_number(1);
 double y = (double)luaL_check_number(2);
 char* s = (char*)luaL_check_string(3);
 wdVectorText(x,y,s);
}

static void L_wdMultiLineVectorText(void)
{
 double x = (double)luaL_check_number(1);
 double y = (double)luaL_check_number(2);
 char* s = (char*)luaL_check_string(3);
 wdMultiLineVectorText(x,y,s);
}


/* ---------------------------------------- public interface */
int luaL_wd_open(void)
{
 cdlua_register("wdWindow",L_wdWindow);
 cdlua_register("wdViewport",L_wdViewport);
 cdlua_register("wdClipArea",L_wdClipArea);
 cdlua_register("wdLine",L_wdLine);
 cdlua_register("wdBox",L_wdBox);
 cdlua_register("wdRect",L_wdRect);
 cdlua_register("wdArc",L_wdArc);
 cdlua_register("wdSector",L_wdSector);
 cdlua_register("wdChord",L_wdChord);
 cdlua_register("wdText",L_wdText);
 cdlua_register("wdVertex",L_wdVertex);
 cdlua_register("wdMark",L_wdMark);
 cdlua_register("wdOffsetRegion",L_wdOffsetRegion);
 cdlua_register("wdPointInRegion",L_wdPointInRegion);
 cdlua_register("wdLineWidth",L_wdLineWidth);
 cdlua_register("wdFont",L_wdFont);
 cdlua_register("wdMarkSize",L_wdMarkSize);
 cdlua_register("wdVectorTextDirection",L_wdVectorTextDirection);
 cdlua_register("wdVectorTextSize",L_wdVectorTextSize);
 cdlua_register("wdVectorCharSize",L_wdVectorCharSize);
 cdlua_register("wdVectorText",L_wdVectorText);
 cdlua_register("wdMultiLineVectorText",L_wdMultiLineVectorText);
 return 1;
}