rays 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.doc/ext/rays/bitmap.cpp +70 -233
- data/.doc/ext/rays/bounds.cpp +339 -57
- data/.doc/ext/rays/color.cpp +58 -48
- data/.doc/ext/rays/color_space.cpp +174 -0
- data/.doc/ext/rays/font.cpp +31 -53
- data/.doc/ext/rays/image.cpp +64 -67
- data/.doc/ext/rays/matrix.cpp +22 -50
- data/.doc/ext/rays/native.cpp +9 -2
- data/.doc/ext/rays/painter.cpp +276 -259
- data/.doc/ext/rays/point.cpp +186 -52
- data/.doc/ext/rays/rays.cpp +25 -20
- data/.doc/ext/rays/shader.cpp +61 -0
- data/.doc/ext/rays/texture.cpp +47 -59
- data/{README → README.md} +0 -0
- data/Rakefile +6 -5
- data/VERSION +1 -1
- data/ext/rays/bitmap.cpp +88 -248
- data/ext/rays/bounds.cpp +437 -141
- data/ext/rays/color.cpp +79 -69
- data/ext/rays/color_space.cpp +185 -0
- data/ext/rays/extconf.rb +14 -63
- data/ext/rays/font.cpp +44 -65
- data/ext/rays/image.cpp +82 -81
- data/ext/rays/matrix.cpp +32 -60
- data/ext/rays/native.cpp +9 -2
- data/ext/rays/painter.cpp +345 -321
- data/ext/rays/point.cpp +212 -69
- data/ext/rays/rays.cpp +29 -23
- data/ext/rays/shader.cpp +63 -0
- data/ext/rays/texture.cpp +64 -74
- data/include/rays/bitmap.h +21 -12
- data/include/rays/bounds.h +67 -9
- data/include/rays/color.h +23 -7
- data/include/rays/{colorspace.h → color_space.h} +6 -3
- data/include/rays/exception.h +17 -11
- data/include/rays/font.h +4 -3
- data/include/rays/image.h +11 -6
- data/include/rays/matrix.h +15 -12
- data/include/rays/opengl.h +54 -1
- data/include/rays/painter.h +98 -108
- data/include/rays/point.h +45 -5
- data/include/rays/rays.h +2 -2
- data/include/rays/ruby/bitmap.h +2 -16
- data/include/rays/ruby/bounds.h +4 -16
- data/include/rays/ruby/color.h +3 -16
- data/include/rays/ruby/color_space.h +27 -0
- data/include/rays/ruby/font.h +2 -16
- data/include/rays/ruby/image.h +2 -16
- data/include/rays/ruby/matrix.h +2 -16
- data/include/rays/ruby/painter.h +2 -16
- data/include/rays/ruby/point.h +3 -16
- data/include/rays/ruby/shader.h +27 -0
- data/include/rays/ruby/texture.h +2 -16
- data/include/rays/ruby.h +1 -0
- data/include/rays/shader.h +48 -0
- data/include/rays/texture.h +13 -2
- data/include/rays.h +2 -1
- data/lib/rays/bitmap.rb +20 -11
- data/lib/rays/bounds.rb +29 -68
- data/lib/rays/color.rb +39 -0
- data/lib/rays/color_space.rb +33 -0
- data/lib/rays/font.rb +29 -0
- data/lib/rays/image.rb +22 -0
- data/lib/rays/module.rb +11 -7
- data/lib/rays/painter.rb +103 -40
- data/lib/rays/point.rb +19 -36
- data/lib/rays/shader.rb +13 -0
- data/lib/rays/texture.rb +9 -0
- data/lib/rays.rb +4 -0
- data/rays.gemspec +3 -4
- data/src/bounds.cpp +272 -63
- data/src/color.cpp +168 -21
- data/src/{colorspace.cpp → color_space.cpp} +38 -1
- data/src/exception.cpp +24 -15
- data/src/frame_buffer.cpp +275 -0
- data/src/frame_buffer.h +79 -0
- data/src/image.cpp +80 -36
- data/src/ios/bitmap.mm +340 -0
- data/src/ios/font.mm +206 -0
- data/src/{cocoa → ios}/helper.h +2 -2
- data/src/{cocoa → ios}/helper.mm +0 -0
- data/src/ios/opengl.mm +21 -0
- data/src/ios/program.cpp +122 -0
- data/src/{cocoa → ios}/rays.mm +8 -7
- data/src/matrix.cpp +10 -22
- data/src/opengl.cpp +64 -0
- data/src/{cocoa → osx}/bitmap.mm +121 -70
- data/src/{cocoa → osx}/font.mm +32 -24
- data/src/osx/helper.h +26 -0
- data/src/osx/helper.mm +25 -0
- data/src/osx/opengl.mm +103 -0
- data/src/osx/rays.mm +43 -0
- data/src/painter.cpp +596 -422
- data/src/point.cpp +154 -11
- data/src/program.cpp +513 -0
- data/src/program.h +73 -0
- data/src/render_buffer.cpp +120 -0
- data/src/render_buffer.h +47 -0
- data/src/shader.cpp +117 -0
- data/src/texture.cpp +104 -134
- data/test/helper.rb +10 -3
- data/test/test_bitmap.rb +18 -0
- data/test/test_bounds.rb +81 -35
- data/test/test_color.rb +29 -2
- data/test/test_image.rb +63 -0
- data/test/test_painter.rb +120 -0
- data/test/test_point.rb +30 -9
- data/test/test_shader.rb +37 -0
- data/test/test_texture.rb +18 -0
- metadata +75 -58
- data/.gitignore +0 -14
- data/ChangeLog +0 -8
data/ext/rays/painter.cpp
CHANGED
@@ -2,11 +2,13 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
#include <rucy.h>
|
5
|
-
#include
|
6
|
-
#include
|
7
|
-
#include
|
8
|
-
#include
|
9
|
-
#include
|
5
|
+
#include "rays/ruby/point.h"
|
6
|
+
#include "rays/ruby/bounds.h"
|
7
|
+
#include "rays/ruby/color.h"
|
8
|
+
#include "rays/ruby/matrix.h"
|
9
|
+
#include "rays/ruby/font.h"
|
10
|
+
#include "rays/ruby/image.h"
|
11
|
+
#include "rays/ruby/shader.h"
|
10
12
|
#include "defs.h"
|
11
13
|
|
12
14
|
|
@@ -17,55 +19,22 @@ using Rays::coord;
|
|
17
19
|
|
18
20
|
static Class cPainter;
|
19
21
|
|
22
|
+
RUCY_DEFINE_VALUE_FROM_TO(Rays::Painter, cPainter)
|
20
23
|
|
21
|
-
|
22
|
-
{
|
23
|
-
|
24
|
-
|
25
|
-
Class
|
26
|
-
painter_class ()
|
27
|
-
{
|
28
|
-
return cPainter;
|
29
|
-
}
|
30
|
-
|
31
|
-
|
32
|
-
}// Rays
|
33
|
-
|
34
|
-
|
35
|
-
namespace Rucy
|
36
|
-
{
|
37
|
-
|
38
|
-
|
39
|
-
Value
|
40
|
-
value (const Rays::Painter& obj)
|
41
|
-
{
|
42
|
-
return new_type(cPainter, new Rays::Painter(obj));
|
43
|
-
}
|
44
|
-
|
45
|
-
Value
|
46
|
-
value (const Rays::Painter* obj)
|
47
|
-
{
|
48
|
-
return obj ? value(*obj) : nil();
|
49
|
-
}
|
50
|
-
|
51
|
-
|
52
|
-
}// Rucy
|
53
|
-
|
24
|
+
#define THIS to<Rays::Painter*>(self)
|
54
25
|
|
55
|
-
#define
|
56
|
-
|
57
|
-
#define CHECK RUCY_CHECK_OBJECT(self, Rays::Painter, cPainter)
|
26
|
+
#define CHECK RUCY_CHECK_OBJECT(Rays::Painter, cPainter, self)
|
58
27
|
|
59
28
|
|
60
29
|
static
|
61
|
-
|
30
|
+
RUCY_DEF_ALLOC(alloc, klass)
|
62
31
|
{
|
63
32
|
return new_type<Rays::Painter>(klass);
|
64
33
|
}
|
65
|
-
|
34
|
+
RUCY_END
|
66
35
|
|
67
36
|
static
|
68
|
-
|
37
|
+
RUCY_DEF4(canvas, x, y, width, height)
|
69
38
|
{
|
70
39
|
CHECK;
|
71
40
|
|
@@ -73,156 +42,155 @@ RUBY_DEF4(canvas, x, y, width, height)
|
|
73
42
|
coord yy = to<coord>(y);
|
74
43
|
coord ww = to<coord>(width);
|
75
44
|
coord hh = to<coord>(height);
|
76
|
-
|
77
|
-
rays_error("Painter#canvas(%f, %f, %f, %f) failed.", xx, yy, ww, hh);
|
45
|
+
THIS->canvas(xx, yy, ww, hh);
|
78
46
|
|
79
47
|
return self;
|
80
48
|
}
|
81
|
-
|
49
|
+
RUCY_END
|
82
50
|
|
83
51
|
static
|
84
|
-
|
52
|
+
RUCY_DEF0(begin_paint)
|
85
53
|
{
|
86
54
|
CHECK;
|
87
|
-
|
88
|
-
if (!THIS->begin())
|
89
|
-
rays_error("Painter#begin_paint() failed.");
|
90
|
-
|
55
|
+
THIS->begin();
|
91
56
|
return self;
|
92
57
|
}
|
93
|
-
|
58
|
+
RUCY_END
|
94
59
|
|
95
60
|
static
|
96
|
-
|
61
|
+
RUCY_DEF0(end_paint)
|
97
62
|
{
|
98
63
|
CHECK;
|
99
|
-
|
100
|
-
if (!THIS->end())
|
101
|
-
rays_error("Painter#end_paint() failed.");
|
102
|
-
|
64
|
+
THIS->end();
|
103
65
|
return self;
|
104
66
|
}
|
105
|
-
|
67
|
+
RUCY_END
|
106
68
|
|
107
69
|
|
108
70
|
static
|
109
|
-
|
71
|
+
RUCY_DEFN(line)
|
110
72
|
{
|
111
73
|
CHECK;
|
74
|
+
check_arg_count(__FILE__, __LINE__, "Painter#line", argc, 2, 4);
|
112
75
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
76
|
+
if (argc == 2)
|
77
|
+
THIS->line(to<Rays::Point&>(argv[0]), to<Rays::Point&>(argv[1]));
|
78
|
+
else
|
79
|
+
{
|
80
|
+
coord x1 = to<coord>(argv[0]);
|
81
|
+
coord y1 = to<coord>(argv[1]);
|
82
|
+
coord x2 = to<coord>(argv[2]);
|
83
|
+
coord y2 = to<coord>(argv[3]);
|
84
|
+
THIS->line(x1, y1, x2, y2);
|
85
|
+
}
|
119
86
|
|
120
87
|
return self;
|
121
88
|
}
|
122
|
-
|
89
|
+
RUCY_END
|
123
90
|
|
124
91
|
static
|
125
|
-
|
92
|
+
RUCY_DEFN(rect)
|
126
93
|
{
|
127
94
|
CHECK;
|
95
|
+
check_arg_count(__FILE__, __LINE__, "Painter#rect", argc, 1, 4);
|
128
96
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
97
|
+
if (argc == 1)
|
98
|
+
THIS->rect(to<Rays::Bounds&>(argv[0]));
|
99
|
+
else
|
100
|
+
{
|
101
|
+
coord x = to<coord>(argv[0]);
|
102
|
+
coord y = to<coord>(argv[1]);
|
103
|
+
coord w = to<coord>(argv[2]);
|
104
|
+
coord h = to<coord>(argv[3]);
|
105
|
+
THIS->rect(x, y, w, h);
|
106
|
+
}
|
135
107
|
|
136
108
|
return self;
|
137
109
|
}
|
138
|
-
|
110
|
+
RUCY_END
|
139
111
|
|
140
112
|
static
|
141
|
-
|
113
|
+
RUCY_DEFN(ellipse)
|
142
114
|
{
|
143
115
|
CHECK;
|
144
|
-
|
145
|
-
arg_count_error("Painter#ellipse", argc, 4, 5, 6);
|
116
|
+
check_arg_count(__FILE__, __LINE__, "Painter#ellipse", argc, 1, 2, 3, 4, 5, 6);
|
146
117
|
|
147
|
-
|
148
|
-
coord yy = to<coord>(argv[1]);
|
149
|
-
coord ww = to<coord>(argv[2]);
|
150
|
-
coord hh = (argc >= 4) ? to<coord>(argv[3]) : 0;
|
151
|
-
coord min_ = (argc >= 5) ? to<coord>(argv[4]) : 0;
|
152
|
-
uint nseg = (argc >= 6) ? to<uint>(argv[5]) : 0;
|
153
|
-
if (!THIS->ellipse(xx, yy, ww, hh, min_, nseg))
|
118
|
+
if (argv[0].is_kind_of(Rays::bounds_class()))
|
154
119
|
{
|
155
|
-
|
156
|
-
|
157
|
-
|
120
|
+
const Rays::Bounds& b = to<Rays::Bounds&>(argv[0]);
|
121
|
+
coord min_ = (argc >= 2) ? to<coord>(argv[1]) : 0;
|
122
|
+
uint nseg = (argc >= 3) ? to<uint> (argv[2]) : 0;
|
123
|
+
THIS->ellipse(b, min_, nseg);
|
124
|
+
}
|
125
|
+
else
|
126
|
+
{
|
127
|
+
coord x = to<coord>(argv[0]);
|
128
|
+
coord y = to<coord>(argv[1]);
|
129
|
+
coord w = to<coord>(argv[2]);
|
130
|
+
coord h = (argc >= 4) ? to<coord>(argv[3]) : 0;
|
131
|
+
coord min_ = (argc >= 5) ? to<coord>(argv[4]) : 0;
|
132
|
+
uint nseg = (argc >= 6) ? to<uint> (argv[5]) : 0;
|
133
|
+
THIS->ellipse(x, y, w, h, min_, nseg);
|
158
134
|
}
|
159
135
|
|
160
136
|
return self;
|
161
137
|
}
|
162
|
-
|
138
|
+
RUCY_END
|
163
139
|
|
164
140
|
static
|
165
|
-
|
141
|
+
RUCY_DEFN(arc)
|
166
142
|
{
|
167
143
|
CHECK;
|
168
|
-
|
169
|
-
arg_count_error("Painter#ellipse", argc, 4, 5, 6, 7, 8);
|
144
|
+
check_arg_count(__FILE__, __LINE__, "Painter#ellipse", argc, 1, 2, 3, 4, 5, 6, 7, 8);
|
170
145
|
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
146
|
+
if (argv[0].is_kind_of(Rays::bounds_class()))
|
147
|
+
{
|
148
|
+
const Rays::Bounds& b = to<Rays::Bounds&>(argv[0]);
|
149
|
+
float from = (argc >= 2) ? to<float>(argv[1]) : 0;
|
150
|
+
float to_ = (argc >= 3) ? to<float>(argv[2]) : 360;
|
151
|
+
coord min_ = (argc >= 4) ? to<coord>(argv[3]) : 0;
|
152
|
+
uint nseg = (argc >= 5) ? to<uint> (argv[4]) : 0;
|
153
|
+
THIS->arc(b, from, to_, min_, nseg);
|
154
|
+
}
|
155
|
+
else
|
180
156
|
{
|
181
|
-
|
182
|
-
|
183
|
-
|
157
|
+
coord x = to<coord>(argv[0]);
|
158
|
+
coord y = to<coord>(argv[1]);
|
159
|
+
coord w = to<coord>(argv[2]);
|
160
|
+
coord h = (argc >= 4) ? to<coord>(argv[3]) : 0;
|
161
|
+
float from = (argc >= 5) ? to<float>(argv[4]) : 0;
|
162
|
+
float to_ = (argc >= 6) ? to<float>(argv[5]) : 360;
|
163
|
+
coord min_ = (argc >= 7) ? to<coord>(argv[6]) : 0;
|
164
|
+
uint nseg = (argc >= 8) ? to<uint> (argv[7]) : 0;
|
165
|
+
THIS->arc(x, y, w, h, from, to_, min_, nseg);
|
184
166
|
}
|
185
167
|
|
186
168
|
return self;
|
187
169
|
}
|
188
|
-
|
170
|
+
RUCY_END
|
189
171
|
|
190
172
|
static
|
191
|
-
|
173
|
+
RUCY_DEFN(image)
|
192
174
|
{
|
193
175
|
CHECK;
|
194
|
-
|
195
|
-
arg_count_error("Painter#image", argc, 1, 3, 5, 7, 9);
|
176
|
+
check_arg_count(__FILE__, __LINE__, "Painter#image", argc, 1, 3, 5, 7, 9);
|
196
177
|
|
197
178
|
const Rays::Image* image = to<Rays::Image*>(argv[0]);
|
198
179
|
if (!image)
|
199
|
-
argument_error("%s is not an image.", argv[0].inspect().c_str());
|
180
|
+
argument_error(__FILE__, __LINE__, "%s is not an image.", argv[0].inspect().c_str());
|
200
181
|
|
201
182
|
if (argc == 1)
|
202
|
-
|
203
|
-
if (!THIS->image(*image))
|
204
|
-
rays_error("Painter#image(%s) failed.", argv[0].inspect().c_str());
|
205
|
-
}
|
183
|
+
THIS->image(*image);
|
206
184
|
else if (argc == 3)
|
207
185
|
{
|
208
186
|
coord x = to<coord>(argv[1]), y = to<coord>(argv[2]);
|
209
|
-
|
210
|
-
{
|
211
|
-
rays_error(
|
212
|
-
"Painter#image(%s, %f, %f) failed.",
|
213
|
-
argv[0].inspect().c_str(), x, y);
|
214
|
-
}
|
187
|
+
THIS->image(*image, x, y);
|
215
188
|
}
|
216
189
|
else if (argc == 5)
|
217
190
|
{
|
218
191
|
coord x = to<coord>(argv[1]), w = to<coord>(argv[3]);
|
219
192
|
coord y = to<coord>(argv[2]), h = to<coord>(argv[4]);
|
220
|
-
|
221
|
-
{
|
222
|
-
rays_error(
|
223
|
-
"Painter#image(%s, %f, %f, %f, %f) failed.",
|
224
|
-
argv[0].inspect().c_str(), x, y, w, h);
|
225
|
-
}
|
193
|
+
THIS->image(*image, x, y, w, h);
|
226
194
|
}
|
227
195
|
else if (argc == 7)
|
228
196
|
{
|
@@ -230,12 +198,7 @@ RUBY_DEFN(image)
|
|
230
198
|
coord sy = to<coord>(argv[2]), dy = to<coord>(argv[6]);
|
231
199
|
coord sw = to<coord>(argv[3]);
|
232
200
|
coord sh = to<coord>(argv[4]);
|
233
|
-
|
234
|
-
{
|
235
|
-
rays_error(
|
236
|
-
"Painter#image(%s, %f, %f, %f, %f, %f, %f) failed.",
|
237
|
-
argv[0].inspect().c_str(), sx, sy, sw, sh, dx, dy);
|
238
|
-
}
|
201
|
+
THIS->image(*image, sx, sy, sw, sh, dx, dy);
|
239
202
|
}
|
240
203
|
else if (argc == 9)
|
241
204
|
{
|
@@ -243,98 +206,85 @@ RUBY_DEFN(image)
|
|
243
206
|
coord sy = to<coord>(argv[2]), dy = to<coord>(argv[6]);
|
244
207
|
coord sw = to<coord>(argv[3]), dw = to<coord>(argv[7]);
|
245
208
|
coord sh = to<coord>(argv[4]), dh = to<coord>(argv[8]);
|
246
|
-
|
247
|
-
{
|
248
|
-
rays_error(
|
249
|
-
"Painter#image(%s, %f, %f, %f, %f, %f, %f, %f, %f) failed.",
|
250
|
-
argv[0].inspect().c_str(), sx, sy, sw, sh, dx, dy, dw, dh);
|
251
|
-
}
|
209
|
+
THIS->image(*image, sx, sy, sw, sh, dx, dy, dw, dh);
|
252
210
|
}
|
253
211
|
|
254
212
|
return self;
|
255
213
|
}
|
256
|
-
|
214
|
+
RUCY_END
|
257
215
|
|
258
216
|
static
|
259
|
-
|
217
|
+
RUCY_DEFN(text)
|
260
218
|
{
|
261
219
|
CHECK;
|
262
|
-
|
263
|
-
arg_count_error("Painter#text", argc, 1, 3, 4, 5, 7);
|
220
|
+
check_arg_count(__FILE__, __LINE__, "Painter#text", argc, 1, 3, 4, 5, 7);
|
264
221
|
|
265
222
|
if (argc == 1)
|
266
|
-
|
267
|
-
if (!THIS->text(argv[0].c_str()))
|
268
|
-
rays_error("Painter#text(%s) failed.", argv[0].inspect().c_str());
|
269
|
-
}
|
223
|
+
THIS->text(argv[0].c_str());
|
270
224
|
else if (argc == 3)
|
271
225
|
{
|
272
226
|
coord x = to<coord>(argv[1]), y = to<coord>(argv[2]);
|
273
|
-
|
274
|
-
{
|
275
|
-
rays_error(
|
276
|
-
"Painter#text(%s, %f, %f) failed.",
|
277
|
-
argv[0].inspect().c_str(), x, y);
|
278
|
-
}
|
227
|
+
THIS->text(argv[0].c_str(), x, y);
|
279
228
|
}
|
280
229
|
else if (argc == 4)
|
281
230
|
{
|
282
231
|
const Rays::Font* font = to<Rays::Font*>(argv[3]);
|
283
232
|
if (!font || !*font)
|
284
|
-
rays_error("Painter#text: invalid font.");
|
233
|
+
rays_error(__FILE__, __LINE__, "Painter#text: invalid font.");
|
285
234
|
|
286
235
|
coord x = to<coord>(argv[1]), y = to<coord>(argv[2]);
|
287
|
-
|
288
|
-
{
|
289
|
-
rays_error(
|
290
|
-
"Painter#image(%s, %f, %f, %s) failed.",
|
291
|
-
argv[0].inspect().c_str(), x, y, argv[3].inspect().c_str());
|
292
|
-
}
|
236
|
+
THIS->text(argv[0].c_str(), x, y, font);
|
293
237
|
}
|
294
238
|
else if (argc == 5)
|
295
239
|
{
|
296
240
|
coord x = to<coord>(argv[1]), w = to<coord>(argv[3]);
|
297
241
|
coord y = to<coord>(argv[2]), h = to<coord>(argv[4]);
|
298
|
-
|
299
|
-
{
|
300
|
-
rays_error(
|
301
|
-
"Painter#text(%s, %f, %f, %f, %f) failed.",
|
302
|
-
argv[0].inspect().c_str(), x, y, w, h);
|
303
|
-
}
|
242
|
+
THIS->text(argv[0].c_str(), x, y, w, h);
|
304
243
|
}
|
305
244
|
else if (argc == 7)
|
306
245
|
{
|
307
246
|
const Rays::Font* font = to<Rays::Font*>(argv[3]);
|
308
247
|
if (!font || !*font)
|
309
|
-
rays_error("Painter#text: invalid font.");
|
248
|
+
rays_error(__FILE__, __LINE__, "Painter#text: invalid font.");
|
310
249
|
|
311
250
|
coord x = to<coord>(argv[1]), w = to<coord>(argv[3]);
|
312
251
|
coord y = to<coord>(argv[2]), h = to<coord>(argv[4]);
|
313
|
-
|
314
|
-
{
|
315
|
-
rays_error(
|
316
|
-
"Painter#image(%s, %f, %f, %f, %f, %s) failed.",
|
317
|
-
argv[0].inspect().c_str(), x, y, w, h, argv[3].inspect().c_str());
|
318
|
-
}
|
252
|
+
THIS->text(argv[0].c_str(), x, y, w, h, font);
|
319
253
|
}
|
320
254
|
|
321
255
|
return self;
|
322
256
|
}
|
323
|
-
|
257
|
+
RUCY_END
|
258
|
+
|
259
|
+
static
|
260
|
+
RUCY_DEF0(clear)
|
261
|
+
{
|
262
|
+
CHECK;
|
263
|
+
THIS->clear();
|
264
|
+
}
|
265
|
+
RUCY_END
|
266
|
+
|
267
|
+
static
|
268
|
+
RUCY_DEF0(bounds)
|
269
|
+
{
|
270
|
+
CHECK;
|
271
|
+
return value(THIS->bounds());
|
272
|
+
}
|
273
|
+
RUCY_END
|
324
274
|
|
325
275
|
static
|
326
|
-
|
276
|
+
RUCY_DEFN(set_background)
|
327
277
|
{
|
328
278
|
CHECK;
|
329
|
-
|
330
|
-
arg_count_error("Painter#set_background", argc, 1, 2, 3, 4);
|
279
|
+
check_arg_count(__FILE__, __LINE__, "Painter#set_background", argc, 1, 2, 3, 4);
|
331
280
|
|
332
|
-
if (argc == 1
|
281
|
+
if (argc == 1 && argv[0].is_kind_of(Rays::color_class()))
|
282
|
+
THIS->set_background(to<Rays::Color&>(argv[0]));
|
283
|
+
else if (argc == 1 || argc == 2)
|
333
284
|
{
|
334
285
|
float v = to<float>(argv[0]);
|
335
286
|
float a = (argc >= 2) ? to<float>(argv[1]) : 1;
|
336
|
-
|
337
|
-
rays_error("Painter#set_background(%f, %f) failed.", v, a);
|
287
|
+
THIS->set_background(v, v, v, a);
|
338
288
|
}
|
339
289
|
else
|
340
290
|
{
|
@@ -342,48 +292,43 @@ RUBY_DEFN(set_background)
|
|
342
292
|
float g = to<float>(argv[1]);
|
343
293
|
float b = to<float>(argv[2]);
|
344
294
|
float a = (argc == 4) ? to<float>(argv[3]) : 1;
|
345
|
-
|
346
|
-
rays_error("Painter#set_background(%f, %f, %f, %f) failed.", r, g, b, a);
|
295
|
+
THIS->set_background(r, g, b, a);
|
347
296
|
}
|
348
297
|
|
349
298
|
return self;
|
350
299
|
}
|
351
|
-
|
300
|
+
RUCY_END
|
352
301
|
|
353
302
|
static
|
354
|
-
|
303
|
+
RUCY_DEF0(no_background)
|
355
304
|
{
|
356
305
|
CHECK;
|
357
|
-
|
358
|
-
if (!THIS->no_background())
|
359
|
-
rays_error("Painter#no_clear() failed.");
|
360
|
-
|
306
|
+
THIS->no_background();
|
361
307
|
return self;
|
362
308
|
}
|
363
|
-
|
309
|
+
RUCY_END
|
364
310
|
|
365
311
|
static
|
366
|
-
|
312
|
+
RUCY_DEF0(get_background)
|
367
313
|
{
|
368
314
|
CHECK;
|
369
|
-
|
370
315
|
return value(THIS->background());
|
371
316
|
}
|
372
|
-
|
317
|
+
RUCY_END
|
373
318
|
|
374
319
|
static
|
375
|
-
|
320
|
+
RUCY_DEFN(set_fill)
|
376
321
|
{
|
377
322
|
CHECK;
|
378
|
-
|
379
|
-
arg_count_error("Painter#set_fill", argc, 1, 2, 3, 4);
|
323
|
+
check_arg_count(__FILE__, __LINE__, "Painter#set_fill", argc, 1, 2, 3, 4);
|
380
324
|
|
381
|
-
if (argc == 1
|
325
|
+
if (argc == 1 && argv[0].is_kind_of(Rays::color_class()))
|
326
|
+
THIS->set_fill(to<Rays::Color&>(argv[0]));
|
327
|
+
else if (argc == 1 || argc == 2)
|
382
328
|
{
|
383
329
|
float v = to<float>(argv[0]);
|
384
330
|
float a = (argc >= 2) ? to<float>(argv[1]) : 1;
|
385
|
-
|
386
|
-
rays_error("Painter#set_fill(%f, %f) failed.", v, a);
|
331
|
+
THIS->set_fill(v, v, v, a);
|
387
332
|
}
|
388
333
|
else
|
389
334
|
{
|
@@ -391,48 +336,43 @@ RUBY_DEFN(set_fill)
|
|
391
336
|
float g = to<float>(argv[1]);
|
392
337
|
float b = to<float>(argv[2]);
|
393
338
|
float a = (argc == 4) ? to<float>(argv[3]) : 1;
|
394
|
-
|
395
|
-
rays_error("Painter#set_fill(%f, %f, %f, %f) failed.", r, g, b, a);
|
339
|
+
THIS->set_fill(r, g, b, a);
|
396
340
|
}
|
397
341
|
|
398
342
|
return self;
|
399
343
|
}
|
400
|
-
|
344
|
+
RUCY_END
|
401
345
|
|
402
346
|
static
|
403
|
-
|
347
|
+
RUCY_DEF0(no_fill)
|
404
348
|
{
|
405
349
|
CHECK;
|
406
|
-
|
407
|
-
if (!THIS->no_fill())
|
408
|
-
rays_error("Painter#no_fill() failed.");
|
409
|
-
|
350
|
+
THIS->no_fill();
|
410
351
|
return self;
|
411
352
|
}
|
412
|
-
|
353
|
+
RUCY_END
|
413
354
|
|
414
355
|
static
|
415
|
-
|
356
|
+
RUCY_DEF0(get_fill)
|
416
357
|
{
|
417
358
|
CHECK;
|
418
|
-
|
419
359
|
return value(THIS->fill());
|
420
360
|
}
|
421
|
-
|
361
|
+
RUCY_END
|
422
362
|
|
423
363
|
static
|
424
|
-
|
364
|
+
RUCY_DEFN(set_stroke)
|
425
365
|
{
|
426
366
|
CHECK;
|
427
|
-
|
428
|
-
arg_count_error("Painter#set_stroke", argc, 1, 2, 3, 4);
|
367
|
+
check_arg_count(__FILE__, __LINE__, "Painter#set_stroke", argc, 1, 2, 3, 4);
|
429
368
|
|
430
|
-
if (argc == 1
|
369
|
+
if (argc == 1 && argv[0].is_kind_of(Rays::color_class()))
|
370
|
+
THIS->set_stroke(to<Rays::Color&>(argv[0]));
|
371
|
+
else if (argc == 1 || argc == 2)
|
431
372
|
{
|
432
373
|
float v = to<float>(argv[0]);
|
433
374
|
float a = (argc >= 2) ? to<float>(argv[1]) : 1;
|
434
|
-
|
435
|
-
rays_error("Painter#set_stroke(%f, %f) failed.", v, a);
|
375
|
+
THIS->set_stroke(v, v, v, a);
|
436
376
|
}
|
437
377
|
else
|
438
378
|
{
|
@@ -440,161 +380,234 @@ RUBY_DEFN(set_stroke)
|
|
440
380
|
float g = to<float>(argv[1]);
|
441
381
|
float b = to<float>(argv[2]);
|
442
382
|
float a = (argc == 4) ? to<float>(argv[3]) : 1;
|
443
|
-
|
444
|
-
rays_error("Painter#set_stroke(%f, %f, %f, %f) failed.", r, g, b, a);
|
383
|
+
THIS->set_stroke(r, g, b, a);
|
445
384
|
}
|
446
385
|
|
447
386
|
return self;
|
448
387
|
}
|
449
|
-
|
388
|
+
RUCY_END
|
450
389
|
|
451
390
|
static
|
452
|
-
|
391
|
+
RUCY_DEF0(no_stroke)
|
453
392
|
{
|
454
393
|
CHECK;
|
455
|
-
|
456
|
-
if (!THIS->no_stroke())
|
457
|
-
rays_error("Painter#no_stroke() failed.");
|
458
|
-
|
394
|
+
THIS->no_stroke();
|
459
395
|
return self;
|
460
396
|
}
|
461
|
-
|
397
|
+
RUCY_END
|
462
398
|
|
463
399
|
static
|
464
|
-
|
400
|
+
RUCY_DEF0(get_stroke)
|
465
401
|
{
|
466
402
|
CHECK;
|
467
|
-
|
468
403
|
return value(THIS->stroke());
|
469
404
|
}
|
470
|
-
|
405
|
+
RUCY_END
|
471
406
|
|
472
407
|
static
|
473
|
-
|
408
|
+
RUCY_DEFN(set_clip)
|
474
409
|
{
|
475
410
|
CHECK;
|
411
|
+
check_arg_count(__FILE__, __LINE__, "Painter#set_clip", argc, 1, 4);
|
476
412
|
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
413
|
+
if (argc == 1)
|
414
|
+
THIS->set_clip(to<Rays::Bounds&>(argv[0]));
|
415
|
+
else
|
416
|
+
{
|
417
|
+
coord x = to<coord>(argv[0]);
|
418
|
+
coord y = to<coord>(argv[1]);
|
419
|
+
coord w = to<coord>(argv[2]);
|
420
|
+
coord h = to<coord>(argv[3]);
|
421
|
+
THIS->set_clip(x, y, w, h);
|
422
|
+
}
|
481
423
|
|
482
424
|
return self;
|
483
425
|
}
|
484
|
-
|
426
|
+
RUCY_END
|
485
427
|
|
486
428
|
static
|
487
|
-
|
429
|
+
RUCY_DEF0(no_clip)
|
488
430
|
{
|
489
431
|
CHECK;
|
490
|
-
|
491
|
-
if (!THIS->no_clip())
|
492
|
-
rays_error("Painter#no_clip() failed.");
|
493
|
-
|
432
|
+
THIS->no_clip();
|
494
433
|
return self;
|
495
434
|
}
|
496
|
-
|
435
|
+
RUCY_END
|
497
436
|
|
498
437
|
static
|
499
|
-
|
438
|
+
RUCY_DEF0(get_clip)
|
500
439
|
{
|
501
440
|
CHECK;
|
502
|
-
|
503
441
|
return value(THIS->clip());
|
504
442
|
}
|
505
|
-
|
443
|
+
RUCY_END
|
506
444
|
|
507
445
|
static
|
508
|
-
|
446
|
+
RUCY_DEFN(set_font)
|
509
447
|
{
|
510
448
|
CHECK;
|
449
|
+
check_arg_count(__FILE__, __LINE__, "Painter#set_font", argc, 0, 1, 2);
|
511
450
|
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
451
|
+
if (argc == 0 || argv[0].is_kind_of(Rays::font_class()))
|
452
|
+
{
|
453
|
+
const Rays::Font* f = argc == 0
|
454
|
+
? &Rays::default_font()
|
455
|
+
: to<Rays::Font*>(argv[0]);
|
456
|
+
if (!f || !*f)
|
457
|
+
argument_error(__FILE__, __LINE__);
|
516
458
|
|
517
|
-
|
518
|
-
|
459
|
+
THIS->set_font(*f);
|
460
|
+
}
|
461
|
+
else
|
462
|
+
{
|
463
|
+
const char* name = argv[0].c_str();
|
464
|
+
coord size = argc >= 2 ? to<coord>(argv[1]) : 0;
|
465
|
+
THIS->set_font(name, size);
|
466
|
+
}
|
519
467
|
|
520
468
|
return self;
|
521
469
|
}
|
522
|
-
|
470
|
+
RUCY_END
|
523
471
|
|
524
472
|
static
|
525
|
-
|
473
|
+
RUCY_DEF0(get_font)
|
526
474
|
{
|
527
475
|
CHECK;
|
528
|
-
|
529
476
|
return value(THIS->font());
|
530
477
|
}
|
531
|
-
|
478
|
+
RUCY_END
|
479
|
+
|
480
|
+
static
|
481
|
+
RUCY_DEF0(push_attr)
|
482
|
+
{
|
483
|
+
CHECK;
|
484
|
+
THIS->push_attr();
|
485
|
+
return self;
|
486
|
+
}
|
487
|
+
RUCY_END
|
532
488
|
|
533
489
|
static
|
534
|
-
|
490
|
+
RUCY_DEF0(pop_attr)
|
535
491
|
{
|
536
492
|
CHECK;
|
493
|
+
THIS->pop_attr();
|
494
|
+
return self;
|
495
|
+
}
|
496
|
+
RUCY_END
|
497
|
+
|
537
498
|
|
538
|
-
|
539
|
-
|
499
|
+
static
|
500
|
+
RUCY_DEF1(attach_shader, shader)
|
501
|
+
{
|
502
|
+
CHECK;
|
503
|
+
THIS->attach(to<Rays::Shader&>(shader));
|
504
|
+
return self;
|
505
|
+
}
|
506
|
+
RUCY_END
|
540
507
|
|
508
|
+
static
|
509
|
+
RUCY_DEF1(detach_shader, shader)
|
510
|
+
{
|
511
|
+
CHECK;
|
512
|
+
THIS->detach(to<Rays::Shader&>(shader));
|
541
513
|
return self;
|
542
514
|
}
|
543
|
-
|
515
|
+
RUCY_END
|
544
516
|
|
545
517
|
static
|
546
|
-
|
518
|
+
RUCY_DEFN(set_uniform)
|
547
519
|
{
|
548
520
|
CHECK;
|
521
|
+
check_arg_count(__FILE__, __LINE__, "Painter#set_uniform", argc, 2, 3, 4, 5);
|
522
|
+
|
523
|
+
#define Ai(n) (argv[n].as_i())
|
524
|
+
#define Af(n) ((float) argv[n].as_f())
|
525
|
+
|
526
|
+
const char* name = argv[0].c_str();
|
527
|
+
if (argv[1].is_i())
|
528
|
+
{
|
529
|
+
switch (argc)
|
530
|
+
{
|
531
|
+
case 2: THIS->set_uniform(name, Ai(1)); break;
|
532
|
+
case 3: THIS->set_uniform(name, Ai(1), Ai(2)); break;
|
533
|
+
case 4: THIS->set_uniform(name, Ai(1), Ai(2), Ai(3)); break;
|
534
|
+
case 5: THIS->set_uniform(name, Ai(1), Ai(2), Ai(3), Ai(4)); break;
|
535
|
+
}
|
536
|
+
}
|
537
|
+
else if (argv[1].is_f())
|
538
|
+
{
|
539
|
+
switch (argc)
|
540
|
+
{
|
541
|
+
case 2: THIS->set_uniform(name, Af(1)); break;
|
542
|
+
case 3: THIS->set_uniform(name, Af(1), Af(2)); break;
|
543
|
+
case 4: THIS->set_uniform(name, Af(1), Af(2), Af(3)); break;
|
544
|
+
case 5: THIS->set_uniform(name, Af(1), Af(2), Af(3), Af(4)); break;
|
545
|
+
}
|
546
|
+
}
|
547
|
+
else
|
548
|
+
argument_error(__FILE__, __LINE__);
|
549
|
+
|
550
|
+
#undef Ai
|
551
|
+
#undef Af
|
552
|
+
|
553
|
+
return self;
|
554
|
+
}
|
555
|
+
RUCY_END
|
549
556
|
|
550
|
-
|
551
|
-
|
557
|
+
static
|
558
|
+
RUCY_DEF0(push_shader)
|
559
|
+
{
|
560
|
+
CHECK;
|
561
|
+
THIS->push_shader();
|
562
|
+
return self;
|
563
|
+
}
|
564
|
+
RUCY_END
|
552
565
|
|
566
|
+
static
|
567
|
+
RUCY_DEF0(pop_shader)
|
568
|
+
{
|
569
|
+
CHECK;
|
570
|
+
THIS->pop_shader();
|
553
571
|
return self;
|
554
572
|
}
|
555
|
-
|
573
|
+
RUCY_END
|
556
574
|
|
557
575
|
|
558
576
|
static
|
559
|
-
|
577
|
+
RUCY_DEFN(translate)
|
560
578
|
{
|
561
579
|
CHECK;
|
562
|
-
|
563
|
-
arg_count_error("Painter#translate", argc, 2, 3);
|
580
|
+
check_arg_count(__FILE__, __LINE__, "Painter#translate", argc, 2, 3);
|
564
581
|
|
565
582
|
coord xx = to<coord>(argv[0]);
|
566
583
|
coord yy = to<coord>(argv[1]);
|
567
584
|
coord zz = (argc >= 3) ? to<coord>(argv[2]) : 0;
|
568
|
-
|
569
|
-
rays_error("Painter#translate(%f %f %f) failed.", xx, yy, zz);
|
585
|
+
THIS->translate(xx, yy, zz);
|
570
586
|
|
571
587
|
return self;
|
572
588
|
}
|
573
|
-
|
589
|
+
RUCY_END
|
574
590
|
|
575
591
|
static
|
576
|
-
|
592
|
+
RUCY_DEFN(scale)
|
577
593
|
{
|
578
594
|
CHECK;
|
579
|
-
|
580
|
-
arg_count_error("Painter#scale", argc, 2, 3);
|
595
|
+
check_arg_count(__FILE__, __LINE__, "Painter#scale", argc, 2, 3);
|
581
596
|
|
582
597
|
coord xx = to<coord>(argv[0]);
|
583
598
|
coord yy = to<coord>(argv[1]);
|
584
599
|
coord zz = (argc >= 3) ? to<coord>(argv[2]) : 1;
|
585
|
-
|
586
|
-
rays_error("Painter#scale(%f %f %f) failed.", xx, yy, zz);
|
600
|
+
THIS->scale(xx, yy, zz);
|
587
601
|
|
588
602
|
return self;
|
589
603
|
}
|
590
|
-
|
604
|
+
RUCY_END
|
591
605
|
|
592
606
|
static
|
593
|
-
|
607
|
+
RUCY_DEFN(rotate)
|
594
608
|
{
|
595
609
|
CHECK;
|
596
|
-
|
597
|
-
arg_count_error("Painter#rotate", argc, 1, 3, 4);
|
610
|
+
check_arg_count(__FILE__, __LINE__, "Painter#rotate", argc, 1, 3, 4);
|
598
611
|
|
599
612
|
coord aa = to<coord>(argv[0]), xx = 0, yy = 0, zz = 1;
|
600
613
|
if (argc >= 3)
|
@@ -604,57 +617,46 @@ RUBY_DEFN(rotate)
|
|
604
617
|
zz = argc >= 4 ? to<coord>(argv[3]) : 0;
|
605
618
|
}
|
606
619
|
|
607
|
-
|
608
|
-
rays_error("Painter#rotate(%f %f %f %f) failed.", aa, xx, yy, zz);
|
620
|
+
THIS->rotate(aa, xx, yy, zz);
|
609
621
|
|
610
622
|
return self;
|
611
623
|
}
|
612
|
-
|
624
|
+
RUCY_END
|
613
625
|
|
614
626
|
static
|
615
|
-
|
627
|
+
RUCY_DEFN(set_matrix)
|
616
628
|
{
|
617
629
|
CHECK;
|
618
|
-
|
619
|
-
if (!THIS->set_matrix())
|
620
|
-
rays_error("Painter#set_matrix() failed.");
|
621
|
-
|
630
|
+
THIS->set_matrix();
|
622
631
|
return self;
|
623
632
|
}
|
624
|
-
|
633
|
+
RUCY_END
|
625
634
|
|
626
635
|
static
|
627
|
-
|
636
|
+
RUCY_DEF0(get_matrix)
|
628
637
|
{
|
629
638
|
CHECK;
|
630
|
-
|
631
639
|
return value(THIS->matrix());
|
632
640
|
}
|
633
|
-
|
641
|
+
RUCY_END
|
634
642
|
|
635
643
|
static
|
636
|
-
|
644
|
+
RUCY_DEF0(push_matrix)
|
637
645
|
{
|
638
646
|
CHECK;
|
639
|
-
|
640
|
-
if (!THIS->push_matrix())
|
641
|
-
rays_error("Painter#push_matrix() failed.");
|
642
|
-
|
647
|
+
THIS->push_matrix();
|
643
648
|
return self;
|
644
649
|
}
|
645
|
-
|
650
|
+
RUCY_END
|
646
651
|
|
647
652
|
static
|
648
|
-
|
653
|
+
RUCY_DEF0(pop_matrix)
|
649
654
|
{
|
650
655
|
CHECK;
|
651
|
-
|
652
|
-
if (!THIS->pop_matrix())
|
653
|
-
rays_error("Painter#pop_matrix() failed.");
|
654
|
-
|
656
|
+
THIS->pop_matrix();
|
655
657
|
return self;
|
656
658
|
}
|
657
|
-
|
659
|
+
RUCY_END
|
658
660
|
|
659
661
|
|
660
662
|
void
|
@@ -666,8 +668,8 @@ Init_painter ()
|
|
666
668
|
cPainter.define_alloc_func(alloc);
|
667
669
|
|
668
670
|
cPainter.define_method("canvas", canvas);
|
669
|
-
cPainter.
|
670
|
-
cPainter.
|
671
|
+
cPainter.define_private_method("begin_paint", begin_paint);
|
672
|
+
cPainter.define_private_method("end_paint", end_paint);
|
671
673
|
|
672
674
|
cPainter.define_method("line", line);
|
673
675
|
cPainter.define_method("rect", rect);
|
@@ -676,28 +678,50 @@ Init_painter ()
|
|
676
678
|
cPainter.define_method("image", image);
|
677
679
|
cPainter.define_method("text", text);
|
678
680
|
|
679
|
-
cPainter.define_method("
|
680
|
-
cPainter.define_method("
|
681
|
-
cPainter.
|
682
|
-
cPainter.
|
683
|
-
cPainter.define_method("
|
684
|
-
cPainter.
|
685
|
-
cPainter.
|
686
|
-
cPainter.define_method("
|
687
|
-
cPainter.
|
688
|
-
cPainter.
|
689
|
-
cPainter.define_method("
|
690
|
-
cPainter.
|
691
|
-
cPainter.
|
692
|
-
cPainter.define_method("
|
693
|
-
cPainter.
|
694
|
-
cPainter.
|
681
|
+
cPainter.define_method("clear", clear);
|
682
|
+
cPainter.define_method("bounds", bounds);
|
683
|
+
cPainter.define_private_method("set_background", set_background);
|
684
|
+
cPainter.define_private_method("get_background", get_background);
|
685
|
+
cPainter.define_method( "no_background", no_background);
|
686
|
+
cPainter.define_private_method("set_fill", set_fill);
|
687
|
+
cPainter.define_private_method("get_fill", get_fill);
|
688
|
+
cPainter.define_method( "no_fill", no_fill);
|
689
|
+
cPainter.define_private_method("set_stroke", set_stroke);
|
690
|
+
cPainter.define_private_method("get_stroke", get_stroke);
|
691
|
+
cPainter.define_method( "no_stroke", no_stroke);
|
692
|
+
cPainter.define_private_method("set_clip", set_clip);
|
693
|
+
cPainter.define_private_method("get_clip", get_clip);
|
694
|
+
cPainter.define_method( "no_clip", no_clip);
|
695
|
+
cPainter.define_private_method("set_font", set_font);
|
696
|
+
cPainter.define_private_method("get_font", get_font);
|
697
|
+
cPainter.define_method("push_attr", push_attr);
|
698
|
+
cPainter.define_method("pop_attr", pop_attr);
|
699
|
+
|
700
|
+
cPainter.define_private_method("attach_shader", attach_shader);
|
701
|
+
cPainter.define_private_method("detach_shader", detach_shader);
|
702
|
+
cPainter.define_private_method("set_uniform", set_uniform);
|
703
|
+
cPainter.define_method("push_shader", push_shader);
|
704
|
+
cPainter.define_method("pop_shader", pop_shader);
|
695
705
|
|
696
706
|
cPainter.define_method("translate", translate);
|
697
|
-
cPainter.define_method("scale",
|
698
|
-
cPainter.define_method("rotate",
|
699
|
-
cPainter.
|
700
|
-
cPainter.
|
707
|
+
cPainter.define_method("scale", scale);
|
708
|
+
cPainter.define_method("rotate", rotate);
|
709
|
+
cPainter.define_private_method("set_matrix", set_matrix);
|
710
|
+
cPainter.define_private_method("get_matrix", get_matrix);
|
701
711
|
cPainter.define_method("push_matrix", push_matrix);
|
702
712
|
cPainter.define_method("pop_matrix", pop_matrix);
|
703
713
|
}
|
714
|
+
|
715
|
+
|
716
|
+
namespace Rays
|
717
|
+
{
|
718
|
+
|
719
|
+
|
720
|
+
Class
|
721
|
+
painter_class ()
|
722
|
+
{
|
723
|
+
return cPainter;
|
724
|
+
}
|
725
|
+
|
726
|
+
|
727
|
+
}// Rays
|