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/.doc/ext/rays/bitmap.cpp
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
#include <rucy.h>
|
5
|
+
#include "rays/ruby/font.h"
|
5
6
|
#include "defs.h"
|
6
7
|
|
7
8
|
|
@@ -13,12 +14,13 @@ using Rays::ulong;
|
|
13
14
|
using Rays::coord;
|
14
15
|
|
15
16
|
|
17
|
+
static Class cBitmap;
|
18
|
+
|
19
|
+
|
16
20
|
namespace Rays
|
17
21
|
{
|
18
22
|
|
19
23
|
|
20
|
-
static Class cBitmap;
|
21
|
-
|
22
24
|
Class
|
23
25
|
bitmap_class ()
|
24
26
|
{
|
@@ -34,41 +36,62 @@ namespace Rucy
|
|
34
36
|
|
35
37
|
|
36
38
|
Value
|
37
|
-
value (const Rays::Bitmap&
|
39
|
+
value (const Rays::Bitmap& obj)
|
40
|
+
{
|
41
|
+
return new_type(cBitmap, new Rays::Bitmap(obj));
|
42
|
+
}
|
43
|
+
|
44
|
+
Value
|
45
|
+
value (const Rays::Bitmap* obj)
|
38
46
|
{
|
39
|
-
return
|
40
|
-
Rays::bitmap_class(), new Rays::Bitmap(bitmap));
|
47
|
+
return obj ? value(*obj) : nil();
|
41
48
|
}
|
42
49
|
|
43
50
|
|
44
51
|
}// Rucy
|
45
52
|
|
46
53
|
|
47
|
-
#define
|
54
|
+
#define THIS to<Rays::Bitmap*>(self)
|
48
55
|
|
49
|
-
#define CHECK
|
56
|
+
#define CHECK RUCY_CHECK_OBJECT(self, Rays::Bitmap, cBitmap)
|
50
57
|
|
51
58
|
|
52
59
|
static
|
53
60
|
VALUE alloc(VALUE klass)
|
54
61
|
{
|
55
|
-
return new_type<Rays::Bitmap>(klass
|
62
|
+
return new_type<Rays::Bitmap>(klass);
|
56
63
|
}
|
57
64
|
|
58
65
|
static
|
59
|
-
VALUE
|
66
|
+
VALUE setup(VALUE self, VALUE width, VALUE height, VALUE colorspace)
|
60
67
|
{
|
61
|
-
|
62
|
-
|
63
|
-
|
68
|
+
RUCY_CHECK_OBJ(self, Rays::Bitmap, cBitmap);
|
69
|
+
*THIS = Rays::Bitmap(
|
70
|
+
to<int>(width), to<int>(height),
|
71
|
+
(Rays::ColorSpaceType) to<uint>(colorspace));
|
72
|
+
return self;
|
73
|
+
}
|
64
74
|
|
65
|
-
|
75
|
+
static
|
76
|
+
VALUE draw_string(VALUE self)
|
77
|
+
{
|
78
|
+
CHECK;
|
79
|
+
if (argc < 1 || 4 < argc)
|
80
|
+
arg_count_error("Bitmap#draw_string", argc, 1, 2, 3, 4);
|
66
81
|
|
67
|
-
|
68
|
-
|
69
|
-
|
82
|
+
const char* str = to<const char*>(argv[0]);
|
83
|
+
coord x = argc >= 2 ? to<coord>(argv[1]) : 0;
|
84
|
+
coord y = argc >= 3 ? to<coord>(argv[2]) : 0;
|
85
|
+
const Rays::Font* font = argc >= 4
|
86
|
+
? to<Rays::Font*>(argv[3]) : &Rays::default_font();
|
87
|
+
|
88
|
+
if (!Rays::draw_string(THIS, str, x, y, *font))
|
89
|
+
{
|
90
|
+
rays_error(
|
91
|
+
"Bitmap#draw_string('%s', %f, %f, %s) failed.",
|
92
|
+
str, x, y, font->name().c_str());
|
93
|
+
}
|
70
94
|
|
71
|
-
*this = Rays::Bitmap(width, height, (Rays::ColorSpaceType) colorspace);
|
72
95
|
return self;
|
73
96
|
}
|
74
97
|
|
@@ -77,7 +100,7 @@ VALUE width(VALUE self)
|
|
77
100
|
{
|
78
101
|
CHECK;
|
79
102
|
|
80
|
-
return value(
|
103
|
+
return value(THIS->width());
|
81
104
|
}
|
82
105
|
|
83
106
|
static
|
@@ -85,7 +108,7 @@ VALUE height(VALUE self)
|
|
85
108
|
{
|
86
109
|
CHECK;
|
87
110
|
|
88
|
-
return value(
|
111
|
+
return value(THIS->height());
|
89
112
|
}
|
90
113
|
|
91
114
|
static
|
@@ -93,7 +116,7 @@ VALUE color_space(VALUE self)
|
|
93
116
|
{
|
94
117
|
CHECK;
|
95
118
|
|
96
|
-
return value(
|
119
|
+
return value(THIS->color_space().type());
|
97
120
|
}
|
98
121
|
|
99
122
|
static
|
@@ -102,14 +125,14 @@ VALUE at(VALUE self, VALUE x, VALUE y)
|
|
102
125
|
CHECK;
|
103
126
|
|
104
127
|
int xx = x.as_i(), yy = y.as_i();
|
105
|
-
void* pixel =
|
106
|
-
if (!pixel)
|
128
|
+
void* pixel = THIS->at<void*>(xx, yy);
|
129
|
+
if (!pixel) rays_error("Bitmap#at(%d, %d) failed.", xx, yy);
|
107
130
|
|
108
|
-
Value array(
|
109
|
-
if (
|
131
|
+
Value array(THIS->color_space().Bpp() / THIS->color_space().Bpc(), NULL);
|
132
|
+
if (THIS->color_space().is_float())
|
110
133
|
{
|
111
134
|
float* p = (float*) pixel;
|
112
|
-
switch (
|
135
|
+
switch (THIS->color_space().type())
|
113
136
|
{
|
114
137
|
case Rays::GRAY_float:
|
115
138
|
array.push(p[0]);
|
@@ -133,13 +156,13 @@ VALUE at(VALUE self, VALUE x, VALUE y)
|
|
133
156
|
array.push(p[3]).push(p[2]).push(p[1]).push(p[0]);
|
134
157
|
break;
|
135
158
|
default:
|
136
|
-
|
159
|
+
rays_error("Bitmap#at: unknown color space");
|
137
160
|
}
|
138
161
|
}
|
139
162
|
else
|
140
163
|
{
|
141
164
|
uchar* p = (uchar*) pixel;
|
142
|
-
switch (
|
165
|
+
switch (THIS->color_space().type())
|
143
166
|
{
|
144
167
|
case Rays::GRAY_8:
|
145
168
|
array.push(*(uchar*) pixel);
|
@@ -181,7 +204,7 @@ VALUE at(VALUE self, VALUE x, VALUE y)
|
|
181
204
|
array.push(p[3]).push(p[2]).push(p[1]);
|
182
205
|
break;
|
183
206
|
default:
|
184
|
-
|
207
|
+
rays_error("Bitmap#at: unknown color space");
|
185
208
|
}
|
186
209
|
}
|
187
210
|
|
@@ -194,14 +217,14 @@ VALUE assign_at(VALUE self, VALUE x, VALUE y, VALUE color)
|
|
194
217
|
CHECK;
|
195
218
|
|
196
219
|
int xx = x.as_i(), yy = y.as_i();
|
197
|
-
void* pixel =
|
198
|
-
if (!pixel)
|
220
|
+
void* pixel = THIS->at<void*>(xx, yy);
|
221
|
+
if (!pixel) rays_error("Bitmap#assign_at(%d, %d) failed.", xx, yy);
|
199
222
|
|
200
|
-
Value array(
|
201
|
-
if (
|
223
|
+
Value array(THIS->color_space().Bpp() / THIS->color_space().Bpc(), NULL);
|
224
|
+
if (THIS->color_space().is_float())
|
202
225
|
{
|
203
226
|
float* p = (float*) pixel;
|
204
|
-
switch (
|
227
|
+
switch (THIS->color_space().type())
|
205
228
|
{
|
206
229
|
#define C(n) ((float) color[n].as_f())
|
207
230
|
case Rays::GRAY_float:
|
@@ -227,13 +250,13 @@ VALUE assign_at(VALUE self, VALUE x, VALUE y, VALUE color)
|
|
227
250
|
break;
|
228
251
|
#undef C
|
229
252
|
default:
|
230
|
-
|
253
|
+
rays_error("Bitmap#at: unknown color space");
|
231
254
|
}
|
232
255
|
}
|
233
256
|
else
|
234
257
|
{
|
235
258
|
uchar* p = (uchar*) pixel;
|
236
|
-
switch (
|
259
|
+
switch (THIS->color_space().type())
|
237
260
|
{
|
238
261
|
#define C(n) ((uchar) color[n].as_i())
|
239
262
|
case Rays::GRAY_8:
|
@@ -277,7 +300,7 @@ VALUE assign_at(VALUE self, VALUE x, VALUE y, VALUE color)
|
|
277
300
|
break;
|
278
301
|
#undef C
|
279
302
|
default:
|
280
|
-
|
303
|
+
rays_error("Bitmap#at: unknown color space");
|
281
304
|
}
|
282
305
|
}
|
283
306
|
|
@@ -290,7 +313,7 @@ VALUE load(VALUE self, VALUE path)
|
|
290
313
|
{
|
291
314
|
Rays::Bitmap bmp;
|
292
315
|
if (!Rays::load_bitmap(&bmp, path.c_str()))
|
293
|
-
|
316
|
+
rays_error("Bitmap.load('%s') failed.", path.c_str());
|
294
317
|
|
295
318
|
return value(bmp);
|
296
319
|
}
|
@@ -299,20 +322,20 @@ VALUE load(VALUE self, VALUE path)
|
|
299
322
|
void
|
300
323
|
Init_bitmap ()
|
301
324
|
{
|
302
|
-
Module
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
rb_define_method(
|
312
|
-
rb_define_method(
|
313
|
-
rb_define_method(
|
314
|
-
rb_define_method(
|
315
|
-
|
316
|
-
|
317
|
-
rb_define_function(
|
325
|
+
Module mRays = rb_define_module("Rays");
|
326
|
+
|
327
|
+
mRays.define_const("GRAY", Rays::GRAY);
|
328
|
+
mRays.define_const("RGB", Rays::RGB);
|
329
|
+
mRays.define_const("RGBA", Rays::RGBA);
|
330
|
+
|
331
|
+
cBitmap = rb_define_class_under(mRays, "Bitmap", rb_cObject);
|
332
|
+
rb_define_alloc_func(cBitmap, alloc);
|
333
|
+
rb_define_private_method(cBitmap, "setup", RUBY_METHOD_FUNC(setup), 3);
|
334
|
+
rb_define_method(cBitmap, "draw_string", RUBY_METHOD_FUNC(draw_string), -1);
|
335
|
+
rb_define_method(cBitmap, "width", RUBY_METHOD_FUNC(width), 0);
|
336
|
+
rb_define_method(cBitmap, "height", RUBY_METHOD_FUNC(height), 0);
|
337
|
+
rb_define_method(cBitmap, "color_space", RUBY_METHOD_FUNC(color_space), 0);
|
338
|
+
cBitmap.define_method("[]", at);
|
339
|
+
cBitmap.define_method("[]=", assign_at);
|
340
|
+
rb_define_function(cBitmap, "load", RUBY_METHOD_FUNC(load), 1);
|
318
341
|
}
|
data/.doc/ext/rays/font.cpp
CHANGED
@@ -10,12 +10,13 @@ using namespace Rucy;
|
|
10
10
|
using Rays::coord;
|
11
11
|
|
12
12
|
|
13
|
+
static Class cFont;
|
14
|
+
|
15
|
+
|
13
16
|
namespace Rays
|
14
17
|
{
|
15
18
|
|
16
19
|
|
17
|
-
static Class cFont;
|
18
|
-
|
19
20
|
Class
|
20
21
|
font_class ()
|
21
22
|
{
|
@@ -31,37 +32,42 @@ namespace Rucy
|
|
31
32
|
|
32
33
|
|
33
34
|
Value
|
34
|
-
value (const Rays::Font&
|
35
|
+
value (const Rays::Font& obj)
|
35
36
|
{
|
36
|
-
return new_type
|
37
|
-
|
37
|
+
return new_type(cFont, new Rays::Font(obj));
|
38
|
+
}
|
39
|
+
|
40
|
+
Value
|
41
|
+
value (const Rays::Font* obj)
|
42
|
+
{
|
43
|
+
return obj ? value(*obj) : nil();
|
38
44
|
}
|
39
45
|
|
40
46
|
|
41
47
|
}// Rucy
|
42
48
|
|
43
49
|
|
44
|
-
#define
|
50
|
+
#define THIS to<Rays::Font*>(self)
|
45
51
|
|
46
|
-
#define CHECK
|
52
|
+
#define CHECK RUCY_CHECK_OBJECT(self, Rays::Font, cFont)
|
47
53
|
|
48
54
|
|
49
55
|
static
|
50
56
|
VALUE alloc(VALUE klass)
|
51
57
|
{
|
52
|
-
return new_type<Rays::Font>(klass
|
58
|
+
return new_type<Rays::Font>(klass);
|
53
59
|
}
|
54
60
|
|
55
61
|
static
|
56
62
|
VALUE initialize(VALUE self)
|
57
63
|
{
|
58
|
-
|
64
|
+
RUCY_CHECK_OBJ(self, Rays::Font, cFont);
|
59
65
|
if (argc < 0 || 2 < argc)
|
60
66
|
arg_count_error("Font#initialize", argc, 0, 1, 2);
|
61
67
|
|
62
68
|
const char* name = (argc >= 1) ? argv[0].c_str() : NULL;
|
63
69
|
float size = (argc >= 2) ? to<float>(argv[1]) : 0;
|
64
|
-
*
|
70
|
+
*THIS = Rays::Font(name, size);
|
65
71
|
|
66
72
|
return self;
|
67
73
|
}
|
@@ -71,7 +77,7 @@ VALUE name(VALUE self)
|
|
71
77
|
{
|
72
78
|
CHECK;
|
73
79
|
|
74
|
-
return value(
|
80
|
+
return value(THIS->name().c_str());
|
75
81
|
}
|
76
82
|
|
77
83
|
static
|
@@ -79,7 +85,7 @@ VALUE size(VALUE self)
|
|
79
85
|
{
|
80
86
|
CHECK;
|
81
87
|
|
82
|
-
return value(
|
88
|
+
return value(THIS->size());
|
83
89
|
}
|
84
90
|
|
85
91
|
static
|
@@ -88,8 +94,8 @@ VALUE width(VALUE self, VALUE str)
|
|
88
94
|
CHECK;
|
89
95
|
|
90
96
|
coord width = 0;
|
91
|
-
if (!
|
92
|
-
|
97
|
+
if (!THIS->get_width(&width, str.c_str()))
|
98
|
+
rays_error("Font#width(%s) failed.", str.inspect().c_str());
|
93
99
|
|
94
100
|
return value(width);
|
95
101
|
}
|
@@ -100,8 +106,8 @@ VALUE height(VALUE self)
|
|
100
106
|
CHECK;
|
101
107
|
|
102
108
|
coord height = 0;
|
103
|
-
if (!
|
104
|
-
|
109
|
+
if (!THIS->get_height(&height))
|
110
|
+
rays_error("Font#height() failed.");
|
105
111
|
|
106
112
|
return value(height);
|
107
113
|
}
|
@@ -110,15 +116,13 @@ VALUE height(VALUE self)
|
|
110
116
|
void
|
111
117
|
Init_font ()
|
112
118
|
{
|
113
|
-
Module
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
rb_define_method(
|
120
|
-
rb_define_method(
|
121
|
-
rb_define_method(
|
122
|
-
rb_define_method(c, "width", RUBY_METHOD_FUNC(width), 1);
|
123
|
-
rb_define_method(c, "height", RUBY_METHOD_FUNC(height), 0);
|
119
|
+
Module mRays = rb_define_module("Rays");
|
120
|
+
|
121
|
+
cFont = rb_define_class_under(mRays, "Font", rb_cObject);
|
122
|
+
rb_define_alloc_func(cFont, alloc);
|
123
|
+
rb_define_private_method(cFont, "initialize", RUBY_METHOD_FUNC(initialize), -1);
|
124
|
+
rb_define_method(cFont, "name", RUBY_METHOD_FUNC(name), 0);
|
125
|
+
rb_define_method(cFont, "size", RUBY_METHOD_FUNC(size), 0);
|
126
|
+
rb_define_method(cFont, "width", RUBY_METHOD_FUNC(width), 1);
|
127
|
+
rb_define_method(cFont, "height", RUBY_METHOD_FUNC(height), 0);
|
124
128
|
}
|
data/.doc/ext/rays/image.cpp
CHANGED
@@ -12,12 +12,13 @@ using namespace Rucy;
|
|
12
12
|
using Rays::coord;
|
13
13
|
|
14
14
|
|
15
|
+
static Class cImage;
|
16
|
+
|
17
|
+
|
15
18
|
namespace Rays
|
16
19
|
{
|
17
20
|
|
18
21
|
|
19
|
-
static Class cImage;
|
20
|
-
|
21
22
|
Class
|
22
23
|
image_class ()
|
23
24
|
{
|
@@ -33,51 +34,59 @@ namespace Rucy
|
|
33
34
|
|
34
35
|
|
35
36
|
Value
|
36
|
-
value (const Rays::Image&
|
37
|
+
value (const Rays::Image& obj)
|
37
38
|
{
|
38
|
-
return new_type
|
39
|
-
|
39
|
+
return new_type(cImage, new Rays::Image(obj));
|
40
|
+
}
|
41
|
+
|
42
|
+
Value
|
43
|
+
value (const Rays::Image* obj)
|
44
|
+
{
|
45
|
+
return obj ? value(*obj) : nil();
|
40
46
|
}
|
41
47
|
|
42
48
|
|
43
49
|
}// Rucy
|
44
50
|
|
45
51
|
|
46
|
-
#define
|
52
|
+
#define THIS to<Rays::Image*>(self)
|
47
53
|
|
48
|
-
#define CHECK
|
54
|
+
#define CHECK RUCY_CHECK_OBJECT(self, Rays::Image, cImage)
|
49
55
|
|
50
56
|
|
51
57
|
static
|
52
58
|
VALUE alloc(VALUE klass)
|
53
59
|
{
|
54
|
-
return new_type<Rays::Image>(klass
|
60
|
+
return new_type<Rays::Image>(klass);
|
55
61
|
}
|
56
62
|
|
57
63
|
static
|
58
64
|
VALUE initialize(VALUE self)
|
59
65
|
{
|
60
|
-
|
61
|
-
|
62
|
-
|
66
|
+
RUCY_CHECK_OBJ(self, Rays::Image, cImage);
|
67
|
+
|
68
|
+
if (argc < 1 || 3 < argc)
|
69
|
+
arg_count_error("Image#initialize", argc, 1, 2, 3);
|
63
70
|
|
64
71
|
if (argc == 0) return self;
|
65
72
|
|
66
|
-
if (argv[
|
73
|
+
if (argv[0].is_kind_of(Rays::bitmap_class()))
|
67
74
|
{
|
68
|
-
if (argc
|
69
|
-
arg_count_error("Image#initialize", argc,
|
75
|
+
if (argc < 1 || 2 < argc)
|
76
|
+
arg_count_error("Image#initialize", argc, 1, 2);
|
77
|
+
|
78
|
+
const Rays::Bitmap* bitmap = to<Rays::Bitmap*>(argv[0]);
|
79
|
+
if (!bitmap) argument_error();
|
70
80
|
|
71
|
-
|
72
|
-
|
73
|
-
*this = Rays::Image(bitmap, alphaonly);
|
81
|
+
bool alphaonly = (argc == 2) ? to<bool>(argv[1]) : false;
|
82
|
+
*THIS = Rays::Image(*bitmap, alphaonly);
|
74
83
|
}
|
75
84
|
else
|
76
85
|
{
|
77
86
|
int width = to<int>(argv[0]);
|
78
87
|
int height = to<int>(argv[1]);
|
79
88
|
uint colorspace = (argc == 3) ? to<uint>(argv[2]) : (uint) Rays::RGBA;
|
80
|
-
*
|
89
|
+
*THIS = Rays::Image(width, height, (Rays::ColorSpaceType) colorspace);
|
81
90
|
}
|
82
91
|
|
83
92
|
return self;
|
@@ -88,7 +97,7 @@ VALUE width(VALUE self)
|
|
88
97
|
{
|
89
98
|
CHECK;
|
90
99
|
|
91
|
-
return value(
|
100
|
+
return value(THIS->width());
|
92
101
|
}
|
93
102
|
|
94
103
|
static
|
@@ -96,7 +105,7 @@ VALUE height(VALUE self)
|
|
96
105
|
{
|
97
106
|
CHECK;
|
98
107
|
|
99
|
-
return value(
|
108
|
+
return value(THIS->height());
|
100
109
|
}
|
101
110
|
|
102
111
|
static
|
@@ -104,7 +113,7 @@ VALUE color_space(VALUE self)
|
|
104
113
|
{
|
105
114
|
CHECK;
|
106
115
|
|
107
|
-
return value(
|
116
|
+
return value(THIS->color_space().type());
|
108
117
|
}
|
109
118
|
|
110
119
|
static
|
@@ -112,7 +121,7 @@ VALUE bitmap(VALUE self)
|
|
112
121
|
{
|
113
122
|
CHECK;
|
114
123
|
|
115
|
-
return value(
|
124
|
+
return value(THIS->bitmap());
|
116
125
|
}
|
117
126
|
|
118
127
|
static
|
@@ -120,7 +129,7 @@ VALUE texture(VALUE self)
|
|
120
129
|
{
|
121
130
|
CHECK;
|
122
131
|
|
123
|
-
return value(
|
132
|
+
return value(THIS->texture());
|
124
133
|
}
|
125
134
|
|
126
135
|
|
@@ -135,7 +144,7 @@ VALUE load(VALUE self)
|
|
135
144
|
Rays::Image img;
|
136
145
|
if (!Rays::load_image(&img, path.c_str(), alphaonly))
|
137
146
|
{
|
138
|
-
|
147
|
+
rays_error(
|
139
148
|
"Image.load('%s', %s) failed.",
|
140
149
|
path.c_str(), alphaonly ? "true" : "false");
|
141
150
|
}
|
@@ -147,17 +156,15 @@ VALUE load(VALUE self)
|
|
147
156
|
void
|
148
157
|
Init_image ()
|
149
158
|
{
|
150
|
-
Module
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
rb_define_method(
|
157
|
-
rb_define_method(
|
158
|
-
rb_define_method(
|
159
|
-
rb_define_method(
|
160
|
-
|
161
|
-
rb_define_method(c, "texture", RUBY_METHOD_FUNC(texture), 0);
|
162
|
-
rb_define_function(c, "load", RUBY_METHOD_FUNC(load), -1);
|
159
|
+
Module mRays = rb_define_module("Rays");
|
160
|
+
|
161
|
+
cImage = rb_define_class_under(mRays, "Image", rb_cObject);
|
162
|
+
rb_define_alloc_func(cImage, alloc);
|
163
|
+
rb_define_private_method(cImage, "initialize", RUBY_METHOD_FUNC(initialize), -1);
|
164
|
+
rb_define_method(cImage, "width", RUBY_METHOD_FUNC(width), 0);
|
165
|
+
rb_define_method(cImage, "height", RUBY_METHOD_FUNC(height), 0);
|
166
|
+
rb_define_method(cImage, "color_space", RUBY_METHOD_FUNC(color_space), 0);
|
167
|
+
rb_define_method(cImage, "bitmap", RUBY_METHOD_FUNC(bitmap), 0);
|
168
|
+
rb_define_method(cImage, "texture", RUBY_METHOD_FUNC(texture), 0);
|
169
|
+
rb_define_function(cImage, "load", RUBY_METHOD_FUNC(load), -1);
|
163
170
|
}
|