rays 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.doc/ext/rays/bitmap.cpp +76 -53
- data/.doc/ext/rays/font.cpp +31 -27
- data/.doc/ext/rays/image.cpp +44 -37
- data/.doc/ext/rays/native.cpp +6 -0
- data/.doc/ext/rays/painter.cpp +276 -160
- data/.doc/ext/rays/rays.cpp +8 -9
- data/.doc/ext/rays/texture.cpp +50 -28
- data/.gitignore +14 -0
- data/Rakefile +5 -30
- data/VERSION +1 -1
- data/ext/rays/bitmap.cpp +77 -53
- data/ext/rays/bounds.cpp +426 -0
- data/ext/rays/color.cpp +199 -0
- data/ext/rays/defs.h +1 -18
- data/ext/rays/extconf.rb +10 -8
- data/ext/rays/font.cpp +31 -27
- data/ext/rays/image.cpp +44 -37
- data/ext/rays/matrix.cpp +154 -0
- data/ext/rays/native.cpp +6 -0
- data/ext/rays/painter.cpp +288 -163
- data/ext/rays/point.cpp +175 -0
- data/ext/rays/rays.cpp +8 -9
- data/ext/rays/texture.cpp +52 -28
- data/include/rays.h +1 -2
- data/include/rays/bitmap.h +5 -3
- data/include/rays/bounds.h +94 -0
- data/include/rays/color.h +53 -0
- data/include/rays/colorspace.h +2 -2
- data/include/rays/exception.h +1 -1
- data/include/rays/font.h +7 -3
- data/include/rays/image.h +6 -2
- data/include/rays/matrix.h +63 -0
- data/include/rays/opengl.h +1 -1
- data/include/rays/painter.h +138 -39
- data/include/rays/point.h +39 -0
- data/include/rays/ruby.h +3 -0
- data/include/rays/ruby/bitmap.h +5 -3
- data/include/rays/ruby/bounds.h +41 -0
- data/include/rays/ruby/color.h +41 -0
- data/include/rays/ruby/font.h +5 -3
- data/include/rays/ruby/image.h +5 -3
- data/include/rays/ruby/matrix.h +41 -0
- data/include/rays/ruby/painter.h +5 -3
- data/include/rays/ruby/point.h +41 -0
- data/include/rays/ruby/texture.h +5 -3
- data/include/rays/texture.h +6 -2
- data/lib/rays.rb +3 -0
- data/lib/rays/autoinit.rb +1 -1
- data/lib/rays/bitmap.rb +15 -1
- data/lib/rays/bounds.rb +138 -0
- data/lib/rays/color.rb +52 -0
- data/lib/rays/ext.rb +4 -0
- data/lib/rays/image.rb +1 -1
- data/lib/rays/module.rb +9 -2
- data/lib/rays/painter.rb +40 -41
- data/lib/rays/point.rb +82 -0
- data/lib/rays/texture.rb +1 -1
- data/rays.gemspec +16 -37
- data/src/bounds.cpp +234 -0
- data/src/cocoa/bitmap.mm +4 -4
- data/src/cocoa/font.mm +35 -30
- data/src/cocoa/rays.mm +2 -0
- data/src/color.cpp +77 -0
- data/src/colorspace.cpp +3 -3
- data/src/exception.cpp +3 -18
- data/src/image.cpp +9 -2
- data/src/matrix.cpp +103 -0
- data/src/painter.cpp +475 -224
- data/src/point.cpp +52 -0
- data/src/texture.cpp +14 -2
- data/src/win32/bitmap.cpp +2 -2
- data/src/win32/gdi.cpp +22 -13
- data/src/win32/gdi.h +7 -7
- data/test/helpers.rb +1 -5
- data/test/test_bitmap.rb +9 -0
- data/test/test_bounds.rb +246 -0
- data/test/test_color.rb +88 -0
- data/test/test_font.rb +28 -0
- data/test/test_image.rb +9 -0
- data/test/test_painter.rb +1 -3
- data/test/test_point.rb +121 -0
- data/test/test_rays.rb +2 -3
- data/test/test_texture.rb +1 -3
- metadata +146 -75
- data/include/rays/helpers.h +0 -37
- data/include/rays/transform.h +0 -35
- data/src/helpers.cpp +0 -22
- data/src/transform.cpp +0 -88
data/ext/rays/bounds.cpp
ADDED
@@ -0,0 +1,426 @@
|
|
1
|
+
#include "rays/ruby/bounds.h"
|
2
|
+
|
3
|
+
|
4
|
+
#include <rucy.h>
|
5
|
+
#include <rays/ruby/point.h>
|
6
|
+
#include "defs.h"
|
7
|
+
|
8
|
+
|
9
|
+
using namespace Rucy;
|
10
|
+
|
11
|
+
using Rays::coord;
|
12
|
+
|
13
|
+
|
14
|
+
static Class cBounds;
|
15
|
+
|
16
|
+
|
17
|
+
namespace Rays
|
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
|
+
|
50
|
+
|
51
|
+
#define THIS to<Rays::Bounds*>(self)
|
52
|
+
|
53
|
+
#define CHECK RUCY_CHECK_OBJ(self, Rays::Bounds, cBounds)
|
54
|
+
|
55
|
+
|
56
|
+
static
|
57
|
+
RUBY_DEF_ALLOC(alloc, klass)
|
58
|
+
{
|
59
|
+
return new_type<Rays::Bounds>(klass);
|
60
|
+
}
|
61
|
+
RUBY_END
|
62
|
+
|
63
|
+
static
|
64
|
+
RUBY_DEFN(initialize)
|
65
|
+
{
|
66
|
+
RUCY_CHECK_OBJ(self, Rays::Bounds, cBounds);
|
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);
|
70
|
+
|
71
|
+
if (argc == 0) return self;
|
72
|
+
|
73
|
+
switch (argc)
|
74
|
+
{
|
75
|
+
case 1:
|
76
|
+
*THIS = Rays::Bounds(to<coord>(argv[0]));
|
77
|
+
break;
|
78
|
+
|
79
|
+
case 2:
|
80
|
+
*THIS = Rays::Bounds(to<coord>(argv[0]), to<coord>(argv[1]));
|
81
|
+
break;
|
82
|
+
|
83
|
+
case 3:
|
84
|
+
*THIS = Rays::Bounds(
|
85
|
+
to<coord>(argv[0]), to<coord>(argv[1]), to<coord>(argv[2]));
|
86
|
+
break;
|
87
|
+
|
88
|
+
case 4:
|
89
|
+
*THIS = Rays::Bounds(
|
90
|
+
to<coord>(argv[0]), to<coord>(argv[1]),
|
91
|
+
to<coord>(argv[2]), to<coord>(argv[3]));
|
92
|
+
break;
|
93
|
+
|
94
|
+
case 6:
|
95
|
+
*THIS = Rays::Bounds(
|
96
|
+
to<coord>(argv[0]), to<coord>(argv[1]), to<coord>(argv[2]),
|
97
|
+
to<coord>(argv[3]), to<coord>(argv[4]), to<coord>(argv[5]));
|
98
|
+
break;
|
99
|
+
}
|
100
|
+
|
101
|
+
return self;
|
102
|
+
}
|
103
|
+
RUBY_END
|
104
|
+
|
105
|
+
static
|
106
|
+
RUBY_DEF1(initialize_copy, obj)
|
107
|
+
{
|
108
|
+
RUCY_CHECK_OBJ(self, Rays::Bounds, cBounds);
|
109
|
+
|
110
|
+
Rays::Bounds* bounds = to<Rays::Bounds*>(obj);
|
111
|
+
if (!bounds) argument_error();
|
112
|
+
|
113
|
+
*THIS = *bounds;
|
114
|
+
return self;
|
115
|
+
}
|
116
|
+
RUBY_END
|
117
|
+
|
118
|
+
static
|
119
|
+
RUBY_DEF1(set_x, x)
|
120
|
+
{
|
121
|
+
CHECK;
|
122
|
+
|
123
|
+
return value(THIS->x = to<coord>(x));
|
124
|
+
}
|
125
|
+
RUBY_END
|
126
|
+
|
127
|
+
static
|
128
|
+
RUBY_DEF0(get_x)
|
129
|
+
{
|
130
|
+
CHECK;
|
131
|
+
|
132
|
+
return value(THIS->x);
|
133
|
+
}
|
134
|
+
RUBY_END
|
135
|
+
|
136
|
+
static
|
137
|
+
RUBY_DEF1(set_y, y)
|
138
|
+
{
|
139
|
+
CHECK;
|
140
|
+
|
141
|
+
return value(THIS->y = to<coord>(y));
|
142
|
+
}
|
143
|
+
RUBY_END
|
144
|
+
|
145
|
+
static
|
146
|
+
RUBY_DEF0(get_y)
|
147
|
+
{
|
148
|
+
CHECK;
|
149
|
+
|
150
|
+
return value(THIS->y);
|
151
|
+
}
|
152
|
+
RUBY_END
|
153
|
+
|
154
|
+
static
|
155
|
+
RUBY_DEF1(set_z, z)
|
156
|
+
{
|
157
|
+
CHECK;
|
158
|
+
|
159
|
+
return value(THIS->z = to<coord>(z));
|
160
|
+
}
|
161
|
+
RUBY_END
|
162
|
+
|
163
|
+
static
|
164
|
+
RUBY_DEF0(get_z)
|
165
|
+
{
|
166
|
+
CHECK;
|
167
|
+
|
168
|
+
return value(THIS->z);
|
169
|
+
}
|
170
|
+
RUBY_END
|
171
|
+
|
172
|
+
static
|
173
|
+
RUBY_DEF1(set_width, width)
|
174
|
+
{
|
175
|
+
CHECK;
|
176
|
+
|
177
|
+
return value(THIS->width = to<coord>(width));
|
178
|
+
}
|
179
|
+
RUBY_END
|
180
|
+
|
181
|
+
static
|
182
|
+
RUBY_DEF0(get_width)
|
183
|
+
{
|
184
|
+
CHECK;
|
185
|
+
|
186
|
+
return value(THIS->width);
|
187
|
+
}
|
188
|
+
RUBY_END
|
189
|
+
|
190
|
+
static
|
191
|
+
RUBY_DEF1(set_height, height)
|
192
|
+
{
|
193
|
+
CHECK;
|
194
|
+
|
195
|
+
return value(THIS->height = to<coord>(height));
|
196
|
+
}
|
197
|
+
RUBY_END
|
198
|
+
|
199
|
+
static
|
200
|
+
RUBY_DEF0(get_height)
|
201
|
+
{
|
202
|
+
CHECK;
|
203
|
+
|
204
|
+
return value(THIS->height);
|
205
|
+
}
|
206
|
+
RUBY_END
|
207
|
+
|
208
|
+
static
|
209
|
+
RUBY_DEF1(set_depth, depth)
|
210
|
+
{
|
211
|
+
CHECK;
|
212
|
+
|
213
|
+
return value(THIS->depth = to<coord>(depth));
|
214
|
+
}
|
215
|
+
RUBY_END
|
216
|
+
|
217
|
+
static
|
218
|
+
RUBY_DEF0(get_depth)
|
219
|
+
{
|
220
|
+
CHECK;
|
221
|
+
|
222
|
+
return value(THIS->depth);
|
223
|
+
}
|
224
|
+
RUBY_END
|
225
|
+
|
226
|
+
static
|
227
|
+
RUBY_DEF1(set_left, left)
|
228
|
+
{
|
229
|
+
CHECK;
|
230
|
+
Rays::Bounds* this_ = THIS;
|
231
|
+
|
232
|
+
this_->set_left(to<coord>(left));
|
233
|
+
return value(this_->left());
|
234
|
+
}
|
235
|
+
RUBY_END
|
236
|
+
|
237
|
+
static
|
238
|
+
RUBY_DEF0(get_left)
|
239
|
+
{
|
240
|
+
CHECK;
|
241
|
+
|
242
|
+
return value(THIS->left());
|
243
|
+
}
|
244
|
+
RUBY_END
|
245
|
+
|
246
|
+
static
|
247
|
+
RUBY_DEF1(set_right, right)
|
248
|
+
{
|
249
|
+
CHECK;
|
250
|
+
Rays::Bounds* this_ = THIS;
|
251
|
+
|
252
|
+
this_->set_right(to<coord>(right));
|
253
|
+
return value(this_->right());
|
254
|
+
}
|
255
|
+
RUBY_END
|
256
|
+
|
257
|
+
static
|
258
|
+
RUBY_DEF0(get_right)
|
259
|
+
{
|
260
|
+
CHECK;
|
261
|
+
|
262
|
+
return value(THIS->right());
|
263
|
+
}
|
264
|
+
RUBY_END
|
265
|
+
|
266
|
+
static
|
267
|
+
RUBY_DEF1(set_top, top)
|
268
|
+
{
|
269
|
+
CHECK;
|
270
|
+
Rays::Bounds* this_ = THIS;
|
271
|
+
|
272
|
+
this_->set_top(to<coord>(top));
|
273
|
+
return value(this_->top());
|
274
|
+
}
|
275
|
+
RUBY_END
|
276
|
+
|
277
|
+
static
|
278
|
+
RUBY_DEF0(get_top)
|
279
|
+
{
|
280
|
+
CHECK;
|
281
|
+
|
282
|
+
return value(THIS->top());
|
283
|
+
}
|
284
|
+
RUBY_END
|
285
|
+
|
286
|
+
static
|
287
|
+
RUBY_DEF1(set_bottom, bottom)
|
288
|
+
{
|
289
|
+
CHECK;
|
290
|
+
Rays::Bounds* this_ = THIS;
|
291
|
+
|
292
|
+
this_->set_bottom(to<coord>(bottom));
|
293
|
+
return value(this_->bottom());
|
294
|
+
}
|
295
|
+
RUBY_END
|
296
|
+
|
297
|
+
static
|
298
|
+
RUBY_DEF0(get_bottom)
|
299
|
+
{
|
300
|
+
CHECK;
|
301
|
+
|
302
|
+
return value(THIS->bottom());
|
303
|
+
}
|
304
|
+
RUBY_END
|
305
|
+
|
306
|
+
static
|
307
|
+
RUBY_DEF1(set_back, back)
|
308
|
+
{
|
309
|
+
CHECK;
|
310
|
+
Rays::Bounds* this_ = THIS;
|
311
|
+
|
312
|
+
this_->set_back(to<coord>(back));
|
313
|
+
return value(this_->back());
|
314
|
+
}
|
315
|
+
RUBY_END
|
316
|
+
|
317
|
+
static
|
318
|
+
RUBY_DEF0(get_back)
|
319
|
+
{
|
320
|
+
CHECK;
|
321
|
+
|
322
|
+
return value(THIS->back());
|
323
|
+
}
|
324
|
+
RUBY_END
|
325
|
+
|
326
|
+
static
|
327
|
+
RUBY_DEF1(set_front, front)
|
328
|
+
{
|
329
|
+
CHECK;
|
330
|
+
Rays::Bounds* this_ = THIS;
|
331
|
+
|
332
|
+
this_->set_front(to<coord>(front));
|
333
|
+
return value(this_->front());
|
334
|
+
}
|
335
|
+
RUBY_END
|
336
|
+
|
337
|
+
static
|
338
|
+
RUBY_DEF0(get_front)
|
339
|
+
{
|
340
|
+
CHECK;
|
341
|
+
|
342
|
+
return value(THIS->front());
|
343
|
+
}
|
344
|
+
RUBY_END
|
345
|
+
|
346
|
+
static
|
347
|
+
RUBY_DEF1(set_position, pos)
|
348
|
+
{
|
349
|
+
CHECK;
|
350
|
+
|
351
|
+
Rays::Point* p = to<Rays::Point*>(pos);
|
352
|
+
if (!p) argument_error("%s is not a Rays::Point.", pos.inspect().c_str());
|
353
|
+
|
354
|
+
return value(THIS->position() = *p);
|
355
|
+
}
|
356
|
+
RUBY_END
|
357
|
+
|
358
|
+
static
|
359
|
+
RUBY_DEF0(get_position)
|
360
|
+
{
|
361
|
+
CHECK;
|
362
|
+
|
363
|
+
return value(THIS->position());
|
364
|
+
}
|
365
|
+
RUBY_END
|
366
|
+
|
367
|
+
static
|
368
|
+
RUBY_DEF1(set_size, size)
|
369
|
+
{
|
370
|
+
CHECK;
|
371
|
+
|
372
|
+
Rays::Point* p = to<Rays::Point*>(size);
|
373
|
+
if (!p) argument_error("%s is not a Rays::Point.", size.inspect().c_str());
|
374
|
+
|
375
|
+
return value(THIS->size() = *p);
|
376
|
+
}
|
377
|
+
RUBY_END
|
378
|
+
|
379
|
+
static
|
380
|
+
RUBY_DEF0(get_size)
|
381
|
+
{
|
382
|
+
CHECK;
|
383
|
+
|
384
|
+
return value(THIS->size());
|
385
|
+
}
|
386
|
+
RUBY_END
|
387
|
+
|
388
|
+
|
389
|
+
void
|
390
|
+
Init_bounds ()
|
391
|
+
{
|
392
|
+
Module mRays = define_module("Rays");
|
393
|
+
|
394
|
+
cBounds = mRays.define_class("Bounds");
|
395
|
+
cBounds.define_alloc_func(alloc);
|
396
|
+
cBounds.define_private_method("initialize", initialize);
|
397
|
+
cBounds.define_private_method("initialize_copy", initialize_copy);
|
398
|
+
cBounds.define_method("x=", set_x);
|
399
|
+
cBounds.define_method("x", get_x);
|
400
|
+
cBounds.define_method("y=", set_y);
|
401
|
+
cBounds.define_method("y", get_y);
|
402
|
+
cBounds.define_method("z=", set_z);
|
403
|
+
cBounds.define_method("z", get_z);
|
404
|
+
cBounds.define_method("width=", set_width);
|
405
|
+
cBounds.define_method("width", get_width);
|
406
|
+
cBounds.define_method("height=", set_height);
|
407
|
+
cBounds.define_method("height", get_height);
|
408
|
+
cBounds.define_method("depth=", set_depth);
|
409
|
+
cBounds.define_method("depth", get_depth);
|
410
|
+
cBounds.define_method("left=", set_left);
|
411
|
+
cBounds.define_method("left", get_left);
|
412
|
+
cBounds.define_method("right=", set_right);
|
413
|
+
cBounds.define_method("right", get_right);
|
414
|
+
cBounds.define_method("top=", set_top);
|
415
|
+
cBounds.define_method("top", get_top);
|
416
|
+
cBounds.define_method("bottom=", set_bottom);
|
417
|
+
cBounds.define_method("bottom", get_bottom);
|
418
|
+
cBounds.define_method("back=", set_back);
|
419
|
+
cBounds.define_method("back", get_back);
|
420
|
+
cBounds.define_method("front=", set_front);
|
421
|
+
cBounds.define_method("front", get_front);
|
422
|
+
cBounds.define_method("position=", set_position);
|
423
|
+
cBounds.define_method("position", get_position);
|
424
|
+
cBounds.define_method("size=", set_size);
|
425
|
+
cBounds.define_method("size", get_size);
|
426
|
+
}
|
data/ext/rays/color.cpp
ADDED
@@ -0,0 +1,199 @@
|
|
1
|
+
#include "rays/ruby/color.h"
|
2
|
+
|
3
|
+
|
4
|
+
#include <rucy.h>
|
5
|
+
#include "defs.h"
|
6
|
+
|
7
|
+
|
8
|
+
using namespace Rucy;
|
9
|
+
|
10
|
+
|
11
|
+
static Class cColor;
|
12
|
+
|
13
|
+
|
14
|
+
namespace Rays
|
15
|
+
{
|
16
|
+
|
17
|
+
|
18
|
+
Class
|
19
|
+
color_class ()
|
20
|
+
{
|
21
|
+
return cColor;
|
22
|
+
}
|
23
|
+
|
24
|
+
|
25
|
+
}// Rays
|
26
|
+
|
27
|
+
|
28
|
+
namespace Rucy
|
29
|
+
{
|
30
|
+
|
31
|
+
|
32
|
+
Value
|
33
|
+
value (const Rays::Color& obj)
|
34
|
+
{
|
35
|
+
return new_type(cColor, new Rays::Color(obj));
|
36
|
+
}
|
37
|
+
|
38
|
+
Value
|
39
|
+
value (const Rays::Color* obj)
|
40
|
+
{
|
41
|
+
return obj ? value(*obj) : nil();
|
42
|
+
}
|
43
|
+
|
44
|
+
|
45
|
+
}// Rucy
|
46
|
+
|
47
|
+
|
48
|
+
#define THIS to<Rays::Color*>(self)
|
49
|
+
|
50
|
+
#define CHECK RUCY_CHECK_OBJ(self, Rays::Color, cColor)
|
51
|
+
|
52
|
+
|
53
|
+
static
|
54
|
+
RUBY_DEF_ALLOC(alloc, klass)
|
55
|
+
{
|
56
|
+
return new_type<Rays::Color>(klass);
|
57
|
+
}
|
58
|
+
RUBY_END
|
59
|
+
|
60
|
+
static
|
61
|
+
RUBY_DEFN(initialize)
|
62
|
+
{
|
63
|
+
RUCY_CHECK_OBJ(self, Rays::Color, cColor);
|
64
|
+
|
65
|
+
if (argc < 0 || 4 < argc)
|
66
|
+
arg_count_error("Color#initialize", argc, 0, 1, 2, 3, 4);
|
67
|
+
|
68
|
+
if (argc == 0) return self;
|
69
|
+
|
70
|
+
switch (argc)
|
71
|
+
{
|
72
|
+
case 1:
|
73
|
+
*THIS = Rays::Color(to<float>(argv[0]));
|
74
|
+
break;
|
75
|
+
|
76
|
+
case 2:
|
77
|
+
*THIS = Rays::Color(to<float>(argv[0]), to<float>(argv[1]));
|
78
|
+
break;
|
79
|
+
|
80
|
+
case 3:
|
81
|
+
*THIS = Rays::Color(
|
82
|
+
to<float>(argv[0]), to<float>(argv[1]), to<float>(argv[2]));
|
83
|
+
break;
|
84
|
+
|
85
|
+
case 4:
|
86
|
+
*THIS = Rays::Color(
|
87
|
+
to<float>(argv[0]), to<float>(argv[1]),
|
88
|
+
to<float>(argv[2]), to<float>(argv[3]));
|
89
|
+
break;
|
90
|
+
}
|
91
|
+
|
92
|
+
return self;
|
93
|
+
}
|
94
|
+
RUBY_END
|
95
|
+
|
96
|
+
static
|
97
|
+
RUBY_DEF1(initialize_copy, obj)
|
98
|
+
{
|
99
|
+
RUCY_CHECK_OBJ(self, Rays::Color, cColor);
|
100
|
+
|
101
|
+
Rays::Color* color = to<Rays::Color*>(obj);
|
102
|
+
if (!color) argument_error();
|
103
|
+
|
104
|
+
*THIS = *color;
|
105
|
+
return self;
|
106
|
+
}
|
107
|
+
RUBY_END
|
108
|
+
|
109
|
+
static
|
110
|
+
RUBY_DEF1(set_red, red)
|
111
|
+
{
|
112
|
+
CHECK;
|
113
|
+
|
114
|
+
return value(THIS->red = to<float>(red));
|
115
|
+
}
|
116
|
+
RUBY_END
|
117
|
+
|
118
|
+
static
|
119
|
+
RUBY_DEF0(get_red)
|
120
|
+
{
|
121
|
+
CHECK;
|
122
|
+
|
123
|
+
return value(THIS->red);
|
124
|
+
}
|
125
|
+
RUBY_END
|
126
|
+
|
127
|
+
static
|
128
|
+
RUBY_DEF1(set_green, green)
|
129
|
+
{
|
130
|
+
CHECK;
|
131
|
+
|
132
|
+
return value(THIS->green = to<float>(green));
|
133
|
+
}
|
134
|
+
RUBY_END
|
135
|
+
|
136
|
+
static
|
137
|
+
RUBY_DEF0(get_green)
|
138
|
+
{
|
139
|
+
CHECK;
|
140
|
+
|
141
|
+
return value(THIS->green);
|
142
|
+
}
|
143
|
+
RUBY_END
|
144
|
+
|
145
|
+
static
|
146
|
+
RUBY_DEF1(set_blue, blue)
|
147
|
+
{
|
148
|
+
CHECK;
|
149
|
+
|
150
|
+
return value(THIS->blue = to<float>(blue));
|
151
|
+
}
|
152
|
+
RUBY_END
|
153
|
+
|
154
|
+
static
|
155
|
+
RUBY_DEF0(get_blue)
|
156
|
+
{
|
157
|
+
CHECK;
|
158
|
+
|
159
|
+
return value(THIS->blue);
|
160
|
+
}
|
161
|
+
RUBY_END
|
162
|
+
|
163
|
+
static
|
164
|
+
RUBY_DEF1(set_alpha, alpha)
|
165
|
+
{
|
166
|
+
CHECK;
|
167
|
+
|
168
|
+
return value(THIS->alpha = to<float>(alpha));
|
169
|
+
}
|
170
|
+
RUBY_END
|
171
|
+
|
172
|
+
static
|
173
|
+
RUBY_DEF0(get_alpha)
|
174
|
+
{
|
175
|
+
CHECK;
|
176
|
+
|
177
|
+
return value(THIS->alpha);
|
178
|
+
}
|
179
|
+
RUBY_END
|
180
|
+
|
181
|
+
|
182
|
+
void
|
183
|
+
Init_color ()
|
184
|
+
{
|
185
|
+
Module mRays = define_module("Rays");
|
186
|
+
|
187
|
+
cColor = mRays.define_class("Color");
|
188
|
+
cColor.define_alloc_func(alloc);
|
189
|
+
cColor.define_private_method("initialize", initialize);
|
190
|
+
cColor.define_private_method("initialize_copy", initialize_copy);
|
191
|
+
cColor.define_method("red=", set_red);
|
192
|
+
cColor.define_method("red", get_red);
|
193
|
+
cColor.define_method("green=", set_green);
|
194
|
+
cColor.define_method("green", get_green);
|
195
|
+
cColor.define_method("blue=", set_blue);
|
196
|
+
cColor.define_method("blue", get_blue);
|
197
|
+
cColor.define_method("alpha=", set_alpha);
|
198
|
+
cColor.define_method("alpha", get_alpha);
|
199
|
+
}
|