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/bounds.cpp
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
#include <rucy.h>
|
5
|
-
#include
|
5
|
+
#include "rays/ruby/point.h"
|
6
6
|
#include "defs.h"
|
7
7
|
|
8
8
|
|
@@ -13,60 +13,25 @@ using Rays::coord;
|
|
13
13
|
|
14
14
|
static Class cBounds;
|
15
15
|
|
16
|
+
RUCY_DEFINE_VALUE_FROM_TO(Rays::Bounds, cBounds)
|
16
17
|
|
17
|
-
|
18
|
-
{
|
19
|
-
|
20
|
-
|
21
|
-
Class
|
22
|
-
bounds_class ()
|
23
|
-
{
|
24
|
-
return cBounds;
|
25
|
-
}
|
26
|
-
|
27
|
-
|
28
|
-
}// Rays
|
29
|
-
|
30
|
-
|
31
|
-
namespace Rucy
|
32
|
-
{
|
33
|
-
|
34
|
-
|
35
|
-
Value
|
36
|
-
value (const Rays::Bounds& obj)
|
37
|
-
{
|
38
|
-
return new_type(cBounds, new Rays::Bounds(obj));
|
39
|
-
}
|
40
|
-
|
41
|
-
Value
|
42
|
-
value (const Rays::Bounds* obj)
|
43
|
-
{
|
44
|
-
return obj ? value(*obj) : nil();
|
45
|
-
}
|
46
|
-
|
47
|
-
|
48
|
-
}// Rucy
|
49
|
-
|
18
|
+
#define THIS to<Rays::Bounds*>(self)
|
50
19
|
|
51
|
-
#define
|
52
|
-
|
53
|
-
#define CHECK RUCY_CHECK_OBJ(self, Rays::Bounds, cBounds)
|
20
|
+
#define CHECK RUCY_CHECK_OBJ(Rays::Bounds, cBounds, self)
|
54
21
|
|
55
22
|
|
56
23
|
static
|
57
|
-
|
24
|
+
RUCY_DEF_ALLOC(alloc, klass)
|
58
25
|
{
|
59
26
|
return new_type<Rays::Bounds>(klass);
|
60
27
|
}
|
61
|
-
|
28
|
+
RUCY_END
|
62
29
|
|
63
30
|
static
|
64
|
-
|
31
|
+
RUCY_DEFN(initialize)
|
65
32
|
{
|
66
|
-
|
67
|
-
|
68
|
-
if (argc != 0 && argc != 1 && argc != 2 && argc != 3 && argc != 4 && argc != 6)
|
69
|
-
arg_count_error("Bounds#initialize", argc, 0, 1, 2, 3, 4, 6);
|
33
|
+
CHECK;
|
34
|
+
check_arg_count(__FILE__, __LINE__, "Bounds#initialize", argc, 0, 1, 2, 3, 4, 6);
|
70
35
|
|
71
36
|
if (argc == 0) return self;
|
72
37
|
|
@@ -100,131 +65,285 @@ RUBY_DEFN(initialize)
|
|
100
65
|
|
101
66
|
return self;
|
102
67
|
}
|
103
|
-
|
68
|
+
RUCY_END
|
69
|
+
|
70
|
+
static
|
71
|
+
RUCY_DEF1(initialize_copy, obj)
|
72
|
+
{
|
73
|
+
CHECK;
|
74
|
+
*THIS = to<Rays::Bounds&>(obj);
|
75
|
+
return self;
|
76
|
+
}
|
77
|
+
RUCY_END
|
78
|
+
|
79
|
+
static
|
80
|
+
RUCY_DEFN(intersect)
|
81
|
+
{
|
82
|
+
CHECK;
|
83
|
+
check_arg_count(__FILE__, __LINE__, "Bounds#intersect?", argc, 1, 2);
|
84
|
+
|
85
|
+
const Rays::Bounds& bounds = to<Rays::Bounds&>(argv[0]);
|
86
|
+
int dimension = argc >= 2 ? to<int>(argv[1]) : 2;
|
87
|
+
|
88
|
+
return value(THIS->is_intersect(bounds, dimension));
|
89
|
+
}
|
90
|
+
RUCY_END
|
91
|
+
|
92
|
+
static
|
93
|
+
RUCY_DEFN(include)
|
94
|
+
{
|
95
|
+
CHECK;
|
96
|
+
check_arg_count(__FILE__, __LINE__, "Bounds#include?", argc, 1, 2);
|
97
|
+
|
98
|
+
const Rays::Point& point = to<Rays::Point&>(argv[0]);
|
99
|
+
int dimension = argc >= 2 ? to<int>(argv[1]) : 2;
|
100
|
+
|
101
|
+
return value(THIS->is_include(point, dimension));
|
102
|
+
}
|
103
|
+
RUCY_END
|
104
|
+
|
105
|
+
static
|
106
|
+
RUCY_DEFN(move_to)
|
107
|
+
{
|
108
|
+
CHECK;
|
109
|
+
check_arg_count(__FILE__, __LINE__, "Bounds#move_to", argc, 1, 2, 3);
|
110
|
+
|
111
|
+
if (argv[0].is_kind_of(Rays::point_class()))
|
112
|
+
THIS->move_to(to<Rays::Point&>(argv[0]));
|
113
|
+
else
|
114
|
+
{
|
115
|
+
if (argv[0].is_array())
|
116
|
+
{
|
117
|
+
argc = argv[0].size();
|
118
|
+
argv = argv[0].as_array();
|
119
|
+
}
|
120
|
+
|
121
|
+
const Rays::Point& p = THIS->position();
|
122
|
+
coord x = (argc >= 1 && argv[0]) ? to<coord>(argv[0]) : p.x;
|
123
|
+
coord y = (argc >= 2 && argv[1]) ? to<coord>(argv[1]) : p.y;
|
124
|
+
coord z = (argc >= 3 && argv[2]) ? to<coord>(argv[2]) : p.z;
|
125
|
+
THIS->move_to(x, y, z);
|
126
|
+
}
|
127
|
+
|
128
|
+
return self;
|
129
|
+
}
|
130
|
+
RUCY_END
|
131
|
+
|
132
|
+
static
|
133
|
+
RUCY_DEFN(move_by)
|
134
|
+
{
|
135
|
+
CHECK;
|
136
|
+
check_arg_count(__FILE__, __LINE__, "Bounds#move_by", argc, 1, 2, 3);
|
137
|
+
|
138
|
+
if (argv[0].is_kind_of(Rays::point_class()))
|
139
|
+
THIS->move_by(to<Rays::Point&>(argv[0]));
|
140
|
+
else
|
141
|
+
{
|
142
|
+
if (argv[0].is_array())
|
143
|
+
{
|
144
|
+
argc = argv[0].size();
|
145
|
+
argv = argv[0].as_array();
|
146
|
+
}
|
147
|
+
|
148
|
+
coord x = (argc >= 1 && argv[0]) ? to<coord>(argv[0]) : 0;
|
149
|
+
coord y = (argc >= 2 && argv[1]) ? to<coord>(argv[1]) : 0;
|
150
|
+
coord z = (argc >= 3 && argv[2]) ? to<coord>(argv[2]) : 0;
|
151
|
+
THIS->move_by(x, y, z);
|
152
|
+
}
|
153
|
+
|
154
|
+
return self;
|
155
|
+
}
|
156
|
+
RUCY_END
|
104
157
|
|
105
158
|
static
|
106
|
-
|
159
|
+
RUCY_DEFN(resize_to)
|
107
160
|
{
|
108
|
-
|
161
|
+
CHECK;
|
162
|
+
check_arg_count(__FILE__, __LINE__, "Bounds#resize_to", argc, 1, 2, 3);
|
109
163
|
|
110
|
-
|
111
|
-
|
164
|
+
if (argv[0].is_kind_of(Rays::point_class()))
|
165
|
+
THIS->resize_to(to<Rays::Point&>(argv[0]));
|
166
|
+
else
|
167
|
+
{
|
168
|
+
if (argv[0].is_array())
|
169
|
+
{
|
170
|
+
argc = argv[0].size();
|
171
|
+
argv = argv[0].as_array();
|
172
|
+
}
|
173
|
+
|
174
|
+
const Rays::Point& p = THIS->size();
|
175
|
+
coord x = (argc >= 1 && argv[0]) ? to<coord>(argv[0]) : p.x;
|
176
|
+
coord y = (argc >= 2 && argv[1]) ? to<coord>(argv[1]) : p.y;
|
177
|
+
coord z = (argc >= 3 && argv[2]) ? to<coord>(argv[2]) : p.z;
|
178
|
+
THIS->resize_to(x, y, z);
|
179
|
+
}
|
112
180
|
|
113
|
-
*THIS = *bounds;
|
114
181
|
return self;
|
115
182
|
}
|
116
|
-
|
183
|
+
RUCY_END
|
117
184
|
|
118
185
|
static
|
119
|
-
|
186
|
+
RUCY_DEFN(resize_by)
|
187
|
+
{
|
188
|
+
CHECK;
|
189
|
+
check_arg_count(__FILE__, __LINE__, "Bounds#resize_by", argc, 1, 2, 3);
|
190
|
+
|
191
|
+
if (argv[0].is_kind_of(Rays::point_class()))
|
192
|
+
THIS->resize_by(to<Rays::Point&>(argv[0]));
|
193
|
+
else
|
194
|
+
{
|
195
|
+
if (argv[0].is_array())
|
196
|
+
{
|
197
|
+
argc = argv[0].size();
|
198
|
+
argv = argv[0].as_array();
|
199
|
+
}
|
200
|
+
|
201
|
+
coord x = (argc >= 1 && argv[0]) ? to<coord>(argv[0]) : 0;
|
202
|
+
coord y = (argc >= 2 && argv[1]) ? to<coord>(argv[1]) : 0;
|
203
|
+
coord z = (argc >= 3 && argv[2]) ? to<coord>(argv[2]) : 0;
|
204
|
+
THIS->resize_by(x, y, z);
|
205
|
+
}
|
206
|
+
|
207
|
+
return self;
|
208
|
+
}
|
209
|
+
RUCY_END
|
210
|
+
|
211
|
+
static
|
212
|
+
RUCY_DEFN(inset_by)
|
213
|
+
{
|
214
|
+
CHECK;
|
215
|
+
check_arg_count(__FILE__, __LINE__, "Bounds#inset_by", argc, 1, 2, 3);
|
216
|
+
|
217
|
+
if (argv[0].is_kind_of(Rays::point_class()))
|
218
|
+
THIS->inset_by(to<Rays::Point&>(argv[0]));
|
219
|
+
else
|
220
|
+
{
|
221
|
+
if (argv[0].is_array())
|
222
|
+
{
|
223
|
+
argc = argv[0].size();
|
224
|
+
argv = argv[0].as_array();
|
225
|
+
}
|
226
|
+
|
227
|
+
coord x = (argc >= 1 && argv[0]) ? to<coord>(argv[0]) : 0;
|
228
|
+
coord y = (argc >= 2 && argv[1]) ? to<coord>(argv[1]) : 0;
|
229
|
+
coord z = (argc >= 3 && argv[2]) ? to<coord>(argv[2]) : 0;
|
230
|
+
THIS->inset_by(x, y, z);
|
231
|
+
}
|
232
|
+
|
233
|
+
return self;
|
234
|
+
}
|
235
|
+
RUCY_END
|
236
|
+
|
237
|
+
static
|
238
|
+
RUCY_DEF1(set_x, x)
|
120
239
|
{
|
121
240
|
CHECK;
|
122
241
|
|
123
242
|
return value(THIS->x = to<coord>(x));
|
124
243
|
}
|
125
|
-
|
244
|
+
RUCY_END
|
126
245
|
|
127
246
|
static
|
128
|
-
|
247
|
+
RUCY_DEF0(get_x)
|
129
248
|
{
|
130
249
|
CHECK;
|
131
250
|
|
132
251
|
return value(THIS->x);
|
133
252
|
}
|
134
|
-
|
253
|
+
RUCY_END
|
135
254
|
|
136
255
|
static
|
137
|
-
|
256
|
+
RUCY_DEF1(set_y, y)
|
138
257
|
{
|
139
258
|
CHECK;
|
140
259
|
|
141
260
|
return value(THIS->y = to<coord>(y));
|
142
261
|
}
|
143
|
-
|
262
|
+
RUCY_END
|
144
263
|
|
145
264
|
static
|
146
|
-
|
265
|
+
RUCY_DEF0(get_y)
|
147
266
|
{
|
148
267
|
CHECK;
|
149
268
|
|
150
269
|
return value(THIS->y);
|
151
270
|
}
|
152
|
-
|
271
|
+
RUCY_END
|
153
272
|
|
154
273
|
static
|
155
|
-
|
274
|
+
RUCY_DEF1(set_z, z)
|
156
275
|
{
|
157
276
|
CHECK;
|
158
277
|
|
159
278
|
return value(THIS->z = to<coord>(z));
|
160
279
|
}
|
161
|
-
|
280
|
+
RUCY_END
|
162
281
|
|
163
282
|
static
|
164
|
-
|
283
|
+
RUCY_DEF0(get_z)
|
165
284
|
{
|
166
285
|
CHECK;
|
167
286
|
|
168
287
|
return value(THIS->z);
|
169
288
|
}
|
170
|
-
|
289
|
+
RUCY_END
|
171
290
|
|
172
291
|
static
|
173
|
-
|
292
|
+
RUCY_DEF1(set_width, width)
|
174
293
|
{
|
175
294
|
CHECK;
|
176
295
|
|
177
296
|
return value(THIS->width = to<coord>(width));
|
178
297
|
}
|
179
|
-
|
298
|
+
RUCY_END
|
180
299
|
|
181
300
|
static
|
182
|
-
|
301
|
+
RUCY_DEF0(get_width)
|
183
302
|
{
|
184
303
|
CHECK;
|
185
304
|
|
186
305
|
return value(THIS->width);
|
187
306
|
}
|
188
|
-
|
307
|
+
RUCY_END
|
189
308
|
|
190
309
|
static
|
191
|
-
|
310
|
+
RUCY_DEF1(set_height, height)
|
192
311
|
{
|
193
312
|
CHECK;
|
194
313
|
|
195
314
|
return value(THIS->height = to<coord>(height));
|
196
315
|
}
|
197
|
-
|
316
|
+
RUCY_END
|
198
317
|
|
199
318
|
static
|
200
|
-
|
319
|
+
RUCY_DEF0(get_height)
|
201
320
|
{
|
202
321
|
CHECK;
|
203
322
|
|
204
323
|
return value(THIS->height);
|
205
324
|
}
|
206
|
-
|
325
|
+
RUCY_END
|
207
326
|
|
208
327
|
static
|
209
|
-
|
328
|
+
RUCY_DEF1(set_depth, depth)
|
210
329
|
{
|
211
330
|
CHECK;
|
212
331
|
|
213
332
|
return value(THIS->depth = to<coord>(depth));
|
214
333
|
}
|
215
|
-
|
334
|
+
RUCY_END
|
216
335
|
|
217
336
|
static
|
218
|
-
|
337
|
+
RUCY_DEF0(get_depth)
|
219
338
|
{
|
220
339
|
CHECK;
|
221
340
|
|
222
341
|
return value(THIS->depth);
|
223
342
|
}
|
224
|
-
|
343
|
+
RUCY_END
|
225
344
|
|
226
345
|
static
|
227
|
-
|
346
|
+
RUCY_DEF1(set_left, left)
|
228
347
|
{
|
229
348
|
CHECK;
|
230
349
|
Rays::Bounds* this_ = THIS;
|
@@ -232,19 +351,19 @@ RUBY_DEF1(set_left, left)
|
|
232
351
|
this_->set_left(to<coord>(left));
|
233
352
|
return value(this_->left());
|
234
353
|
}
|
235
|
-
|
354
|
+
RUCY_END
|
236
355
|
|
237
356
|
static
|
238
|
-
|
357
|
+
RUCY_DEF0(get_left)
|
239
358
|
{
|
240
359
|
CHECK;
|
241
360
|
|
242
361
|
return value(THIS->left());
|
243
362
|
}
|
244
|
-
|
363
|
+
RUCY_END
|
245
364
|
|
246
365
|
static
|
247
|
-
|
366
|
+
RUCY_DEF1(set_right, right)
|
248
367
|
{
|
249
368
|
CHECK;
|
250
369
|
Rays::Bounds* this_ = THIS;
|
@@ -252,19 +371,19 @@ RUBY_DEF1(set_right, right)
|
|
252
371
|
this_->set_right(to<coord>(right));
|
253
372
|
return value(this_->right());
|
254
373
|
}
|
255
|
-
|
374
|
+
RUCY_END
|
256
375
|
|
257
376
|
static
|
258
|
-
|
377
|
+
RUCY_DEF0(get_right)
|
259
378
|
{
|
260
379
|
CHECK;
|
261
380
|
|
262
381
|
return value(THIS->right());
|
263
382
|
}
|
264
|
-
|
383
|
+
RUCY_END
|
265
384
|
|
266
385
|
static
|
267
|
-
|
386
|
+
RUCY_DEF1(set_top, top)
|
268
387
|
{
|
269
388
|
CHECK;
|
270
389
|
Rays::Bounds* this_ = THIS;
|
@@ -272,19 +391,19 @@ RUBY_DEF1(set_top, top)
|
|
272
391
|
this_->set_top(to<coord>(top));
|
273
392
|
return value(this_->top());
|
274
393
|
}
|
275
|
-
|
394
|
+
RUCY_END
|
276
395
|
|
277
396
|
static
|
278
|
-
|
397
|
+
RUCY_DEF0(get_top)
|
279
398
|
{
|
280
399
|
CHECK;
|
281
400
|
|
282
401
|
return value(THIS->top());
|
283
402
|
}
|
284
|
-
|
403
|
+
RUCY_END
|
285
404
|
|
286
405
|
static
|
287
|
-
|
406
|
+
RUCY_DEF1(set_bottom, bottom)
|
288
407
|
{
|
289
408
|
CHECK;
|
290
409
|
Rays::Bounds* this_ = THIS;
|
@@ -292,19 +411,19 @@ RUBY_DEF1(set_bottom, bottom)
|
|
292
411
|
this_->set_bottom(to<coord>(bottom));
|
293
412
|
return value(this_->bottom());
|
294
413
|
}
|
295
|
-
|
414
|
+
RUCY_END
|
296
415
|
|
297
416
|
static
|
298
|
-
|
417
|
+
RUCY_DEF0(get_bottom)
|
299
418
|
{
|
300
419
|
CHECK;
|
301
420
|
|
302
421
|
return value(THIS->bottom());
|
303
422
|
}
|
304
|
-
|
423
|
+
RUCY_END
|
305
424
|
|
306
425
|
static
|
307
|
-
|
426
|
+
RUCY_DEF1(set_back, back)
|
308
427
|
{
|
309
428
|
CHECK;
|
310
429
|
Rays::Bounds* this_ = THIS;
|
@@ -312,19 +431,19 @@ RUBY_DEF1(set_back, back)
|
|
312
431
|
this_->set_back(to<coord>(back));
|
313
432
|
return value(this_->back());
|
314
433
|
}
|
315
|
-
|
434
|
+
RUCY_END
|
316
435
|
|
317
436
|
static
|
318
|
-
|
437
|
+
RUCY_DEF0(get_back)
|
319
438
|
{
|
320
439
|
CHECK;
|
321
440
|
|
322
441
|
return value(THIS->back());
|
323
442
|
}
|
324
|
-
|
443
|
+
RUCY_END
|
325
444
|
|
326
445
|
static
|
327
|
-
|
446
|
+
RUCY_DEF1(set_front, front)
|
328
447
|
{
|
329
448
|
CHECK;
|
330
449
|
Rays::Bounds* this_ = THIS;
|
@@ -332,58 +451,146 @@ RUBY_DEF1(set_front, front)
|
|
332
451
|
this_->set_front(to<coord>(front));
|
333
452
|
return value(this_->front());
|
334
453
|
}
|
335
|
-
|
454
|
+
RUCY_END
|
336
455
|
|
337
456
|
static
|
338
|
-
|
457
|
+
RUCY_DEF0(get_front)
|
339
458
|
{
|
340
459
|
CHECK;
|
341
460
|
|
342
461
|
return value(THIS->front());
|
343
462
|
}
|
344
|
-
|
463
|
+
RUCY_END
|
345
464
|
|
346
465
|
static
|
347
|
-
|
466
|
+
RUCY_DEFN(set_position)
|
348
467
|
{
|
349
468
|
CHECK;
|
469
|
+
check_arg_count(__FILE__, __LINE__, "Bounds#set_position", argc, 1, 2, 3);
|
350
470
|
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
return value(THIS->position() = *p);
|
471
|
+
coord* pos = THIS->position().array;
|
472
|
+
for (int i = 0; i < 3; ++i)
|
473
|
+
if (argc > i && !argv[i].is_nil()) pos[i] = to<coord>(argv[i]);
|
355
474
|
}
|
356
|
-
|
475
|
+
RUCY_END
|
357
476
|
|
358
477
|
static
|
359
|
-
|
478
|
+
RUCY_DEF0(get_position)
|
360
479
|
{
|
361
480
|
CHECK;
|
362
481
|
|
363
482
|
return value(THIS->position());
|
364
483
|
}
|
365
|
-
|
484
|
+
RUCY_END
|
366
485
|
|
367
486
|
static
|
368
|
-
|
487
|
+
RUCY_DEFN(set_size)
|
369
488
|
{
|
370
489
|
CHECK;
|
490
|
+
check_arg_count(__FILE__, __LINE__, "Bounds#set_size", argc, 1, 2, 3);
|
371
491
|
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
return value(THIS->size() = *p);
|
492
|
+
coord* size = THIS->size().array;
|
493
|
+
for (int i = 0; i < 3; ++i)
|
494
|
+
if (argc > i && !argv[i].is_nil()) size[i] = to<coord>(argv[i]);
|
376
495
|
}
|
377
|
-
|
496
|
+
RUCY_END
|
378
497
|
|
379
498
|
static
|
380
|
-
|
499
|
+
RUCY_DEF0(get_size)
|
381
500
|
{
|
382
501
|
CHECK;
|
383
502
|
|
384
503
|
return value(THIS->size());
|
385
504
|
}
|
386
|
-
|
505
|
+
RUCY_END
|
506
|
+
|
507
|
+
static
|
508
|
+
RUCY_DEFN(set_center)
|
509
|
+
{
|
510
|
+
CHECK;
|
511
|
+
check_arg_count(__FILE__, __LINE__, "Bounds#set_center", argc, 1, 2, 3);
|
512
|
+
|
513
|
+
if (argv[0].is_kind_of(Rays::point_class()))
|
514
|
+
THIS->set_center(to<Rays::Point&>(argv[0]));
|
515
|
+
else
|
516
|
+
{
|
517
|
+
Rays::Point p = THIS->center();
|
518
|
+
coord x = (argc >= 1 && argv[0]) ? to<coord>(argv[0]) : p.x;
|
519
|
+
coord y = (argc >= 2 && argv[1]) ? to<coord>(argv[1]) : p.y;
|
520
|
+
coord z = (argc >= 3 && argv[2]) ? to<coord>(argv[2]) : p.z;
|
521
|
+
THIS->set_center(x, y, z);
|
522
|
+
}
|
523
|
+
|
524
|
+
return value(THIS->center());
|
525
|
+
}
|
526
|
+
RUCY_END
|
527
|
+
|
528
|
+
static
|
529
|
+
RUCY_DEF0(center)
|
530
|
+
{
|
531
|
+
CHECK;
|
532
|
+
|
533
|
+
return value(THIS->center());
|
534
|
+
}
|
535
|
+
RUCY_END
|
536
|
+
|
537
|
+
static
|
538
|
+
RUCY_DEF1(array_get, index)
|
539
|
+
{
|
540
|
+
CHECK;
|
541
|
+
|
542
|
+
int i = index.as_i();
|
543
|
+
if (i < 0 || 1 < i)
|
544
|
+
index_error(__FILE__, __LINE__);
|
545
|
+
|
546
|
+
return value((*THIS)[i]);
|
547
|
+
}
|
548
|
+
RUCY_END
|
549
|
+
|
550
|
+
static
|
551
|
+
RUCY_DEF2(array_set, index, value)
|
552
|
+
{
|
553
|
+
CHECK;
|
554
|
+
|
555
|
+
int i = index.as_i();
|
556
|
+
if (i < 0 || 1 < i)
|
557
|
+
index_error(__FILE__, __LINE__);
|
558
|
+
|
559
|
+
(*THIS)[i] = to<Rays::Point&>(value);
|
560
|
+
return value;
|
561
|
+
}
|
562
|
+
RUCY_END
|
563
|
+
|
564
|
+
static
|
565
|
+
RUCY_DEF1(and_, bounds)
|
566
|
+
{
|
567
|
+
CHECK;
|
568
|
+
|
569
|
+
Rays::Bounds b = *THIS;
|
570
|
+
b &= to<Rays::Bounds&>(bounds);
|
571
|
+
return value(b);
|
572
|
+
}
|
573
|
+
RUCY_END
|
574
|
+
|
575
|
+
static
|
576
|
+
RUCY_DEF1(or_, bounds)
|
577
|
+
{
|
578
|
+
CHECK;
|
579
|
+
|
580
|
+
Rays::Bounds b = *THIS;
|
581
|
+
b |= to<Rays::Bounds&>(bounds);
|
582
|
+
return value(b);
|
583
|
+
}
|
584
|
+
RUCY_END
|
585
|
+
|
586
|
+
static
|
587
|
+
RUCY_DEF0(inspect)
|
588
|
+
{
|
589
|
+
CHECK;
|
590
|
+
|
591
|
+
return value(Xot::stringf("#<Rays::Bounds %s>", THIS->inspect().c_str()));
|
592
|
+
}
|
593
|
+
RUCY_END
|
387
594
|
|
388
595
|
|
389
596
|
void
|
@@ -395,32 +602,121 @@ Init_bounds ()
|
|
395
602
|
cBounds.define_alloc_func(alloc);
|
396
603
|
cBounds.define_private_method("initialize", initialize);
|
397
604
|
cBounds.define_private_method("initialize_copy", initialize_copy);
|
398
|
-
cBounds.define_method("
|
399
|
-
cBounds.define_method("
|
400
|
-
cBounds.define_method("
|
401
|
-
cBounds.define_method("
|
402
|
-
cBounds.define_method("
|
403
|
-
cBounds.define_method("
|
404
|
-
cBounds.define_method("
|
405
|
-
cBounds.define_method("
|
605
|
+
cBounds.define_method("intersect?", intersect);
|
606
|
+
cBounds.define_method("include?", include);
|
607
|
+
cBounds.define_method("move_to!", move_to);
|
608
|
+
cBounds.define_method("move_by!", move_by);
|
609
|
+
cBounds.define_method("resize_to!", resize_to);
|
610
|
+
cBounds.define_method("resize_by!", resize_by);
|
611
|
+
cBounds.define_method("inset_by!", inset_by);
|
612
|
+
cBounds.define_method("x=", set_x);
|
613
|
+
cBounds.define_method("x", get_x);
|
614
|
+
cBounds.define_method("y=", set_y);
|
615
|
+
cBounds.define_method("y", get_y);
|
616
|
+
cBounds.define_method("z=", set_z);
|
617
|
+
cBounds.define_method("z", get_z);
|
618
|
+
cBounds.define_method("width=", set_width);
|
619
|
+
cBounds.define_method("width", get_width);
|
406
620
|
cBounds.define_method("height=", set_height);
|
407
|
-
cBounds.define_method("height",
|
408
|
-
cBounds.define_method("depth=",
|
409
|
-
cBounds.define_method("depth",
|
410
|
-
cBounds.define_method("left=",
|
411
|
-
cBounds.define_method("left",
|
412
|
-
cBounds.define_method("right=",
|
413
|
-
cBounds.define_method("right",
|
414
|
-
cBounds.define_method("top=",
|
415
|
-
cBounds.define_method("top",
|
621
|
+
cBounds.define_method("height", get_height);
|
622
|
+
cBounds.define_method("depth=", set_depth);
|
623
|
+
cBounds.define_method("depth", get_depth);
|
624
|
+
cBounds.define_method("left=", set_left);
|
625
|
+
cBounds.define_method("left", get_left);
|
626
|
+
cBounds.define_method("right=", set_right);
|
627
|
+
cBounds.define_method("right", get_right);
|
628
|
+
cBounds.define_method("top=", set_top);
|
629
|
+
cBounds.define_method("top", get_top);
|
416
630
|
cBounds.define_method("bottom=", set_bottom);
|
417
|
-
cBounds.define_method("bottom",
|
418
|
-
cBounds.define_method("back=",
|
419
|
-
cBounds.define_method("back",
|
420
|
-
cBounds.define_method("front=",
|
421
|
-
cBounds.define_method("front",
|
422
|
-
cBounds.define_method("
|
423
|
-
cBounds.define_method("position", get_position);
|
424
|
-
cBounds.define_method("
|
425
|
-
cBounds.define_method("size", get_size);
|
631
|
+
cBounds.define_method("bottom", get_bottom);
|
632
|
+
cBounds.define_method("back=", set_back);
|
633
|
+
cBounds.define_method("back", get_back);
|
634
|
+
cBounds.define_method("front=", set_front);
|
635
|
+
cBounds.define_method("front", get_front);
|
636
|
+
cBounds.define_method("set_position", set_position);
|
637
|
+
cBounds.define_method( "position", get_position);
|
638
|
+
cBounds.define_method("set_size", set_size);
|
639
|
+
cBounds.define_method( "size", get_size);
|
640
|
+
cBounds.define_method("set_center", set_center);
|
641
|
+
cBounds.define_method("center", center);
|
642
|
+
cBounds.define_method("[]", array_get);
|
643
|
+
cBounds.define_method("[]=", array_set);
|
644
|
+
cBounds.define_method("&", and_);
|
645
|
+
cBounds.define_method("|", or_);
|
646
|
+
cBounds.define_method("inspect", inspect);
|
426
647
|
}
|
648
|
+
|
649
|
+
|
650
|
+
namespace Rucy
|
651
|
+
{
|
652
|
+
|
653
|
+
|
654
|
+
template <> Rays::Bounds
|
655
|
+
value_to<Rays::Bounds> (Value value, bool convert)
|
656
|
+
{
|
657
|
+
if (convert)
|
658
|
+
{
|
659
|
+
size_t argc = 0;
|
660
|
+
Value* argv = NULL;
|
661
|
+
if (value.is_array())
|
662
|
+
{
|
663
|
+
argc = value.size();
|
664
|
+
argv = value.as_array();
|
665
|
+
}
|
666
|
+
else
|
667
|
+
{
|
668
|
+
argc = 1;
|
669
|
+
argv = &value;
|
670
|
+
}
|
671
|
+
|
672
|
+
if (argc < 1)
|
673
|
+
Rucy::argument_error(__FILE__, __LINE__);
|
674
|
+
|
675
|
+
if (argv[0].is_kind_of(Rays::bounds_class()))
|
676
|
+
value = argv[0];
|
677
|
+
else if (argv[0].is_kind_of(Rays::point_class()))
|
678
|
+
{
|
679
|
+
switch (argc)
|
680
|
+
{
|
681
|
+
#define V(i) to<Rays::Point&>(argv[i])
|
682
|
+
case 1: return Rays::Bounds(V(0));
|
683
|
+
case 2: return Rays::Bounds(V(0), V(1));
|
684
|
+
#undef V
|
685
|
+
default: Rucy::argument_error(__FILE__, __LINE__);
|
686
|
+
}
|
687
|
+
}
|
688
|
+
else if (argv[0].is_i() || argv[0].is_f())
|
689
|
+
{
|
690
|
+
switch (argc)
|
691
|
+
{
|
692
|
+
#define V(i) argv[i].as_f(true)
|
693
|
+
case 1: return Rays::Bounds(V(0));
|
694
|
+
case 2: return Rays::Bounds(V(0), V(1));
|
695
|
+
case 3: return Rays::Bounds(V(0), V(1), V(2));
|
696
|
+
case 4: return Rays::Bounds(V(0), V(1), V(2), V(3));
|
697
|
+
case 6: return Rays::Bounds(V(0), V(1), V(2), V(3), V(4), V(5));
|
698
|
+
#undef V
|
699
|
+
default: Rucy::argument_error(__FILE__, __LINE__);
|
700
|
+
}
|
701
|
+
}
|
702
|
+
}
|
703
|
+
|
704
|
+
return value_to<Rays::Bounds&>(value, convert);
|
705
|
+
}
|
706
|
+
|
707
|
+
|
708
|
+
}// Rucy
|
709
|
+
|
710
|
+
|
711
|
+
namespace Rays
|
712
|
+
{
|
713
|
+
|
714
|
+
|
715
|
+
Class
|
716
|
+
bounds_class ()
|
717
|
+
{
|
718
|
+
return cBounds;
|
719
|
+
}
|
720
|
+
|
721
|
+
|
722
|
+
}// Rays
|