rays 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. data/.doc/ext/rays/bitmap.cpp +76 -53
  2. data/.doc/ext/rays/font.cpp +31 -27
  3. data/.doc/ext/rays/image.cpp +44 -37
  4. data/.doc/ext/rays/native.cpp +6 -0
  5. data/.doc/ext/rays/painter.cpp +276 -160
  6. data/.doc/ext/rays/rays.cpp +8 -9
  7. data/.doc/ext/rays/texture.cpp +50 -28
  8. data/.gitignore +14 -0
  9. data/Rakefile +5 -30
  10. data/VERSION +1 -1
  11. data/ext/rays/bitmap.cpp +77 -53
  12. data/ext/rays/bounds.cpp +426 -0
  13. data/ext/rays/color.cpp +199 -0
  14. data/ext/rays/defs.h +1 -18
  15. data/ext/rays/extconf.rb +10 -8
  16. data/ext/rays/font.cpp +31 -27
  17. data/ext/rays/image.cpp +44 -37
  18. data/ext/rays/matrix.cpp +154 -0
  19. data/ext/rays/native.cpp +6 -0
  20. data/ext/rays/painter.cpp +288 -163
  21. data/ext/rays/point.cpp +175 -0
  22. data/ext/rays/rays.cpp +8 -9
  23. data/ext/rays/texture.cpp +52 -28
  24. data/include/rays.h +1 -2
  25. data/include/rays/bitmap.h +5 -3
  26. data/include/rays/bounds.h +94 -0
  27. data/include/rays/color.h +53 -0
  28. data/include/rays/colorspace.h +2 -2
  29. data/include/rays/exception.h +1 -1
  30. data/include/rays/font.h +7 -3
  31. data/include/rays/image.h +6 -2
  32. data/include/rays/matrix.h +63 -0
  33. data/include/rays/opengl.h +1 -1
  34. data/include/rays/painter.h +138 -39
  35. data/include/rays/point.h +39 -0
  36. data/include/rays/ruby.h +3 -0
  37. data/include/rays/ruby/bitmap.h +5 -3
  38. data/include/rays/ruby/bounds.h +41 -0
  39. data/include/rays/ruby/color.h +41 -0
  40. data/include/rays/ruby/font.h +5 -3
  41. data/include/rays/ruby/image.h +5 -3
  42. data/include/rays/ruby/matrix.h +41 -0
  43. data/include/rays/ruby/painter.h +5 -3
  44. data/include/rays/ruby/point.h +41 -0
  45. data/include/rays/ruby/texture.h +5 -3
  46. data/include/rays/texture.h +6 -2
  47. data/lib/rays.rb +3 -0
  48. data/lib/rays/autoinit.rb +1 -1
  49. data/lib/rays/bitmap.rb +15 -1
  50. data/lib/rays/bounds.rb +138 -0
  51. data/lib/rays/color.rb +52 -0
  52. data/lib/rays/ext.rb +4 -0
  53. data/lib/rays/image.rb +1 -1
  54. data/lib/rays/module.rb +9 -2
  55. data/lib/rays/painter.rb +40 -41
  56. data/lib/rays/point.rb +82 -0
  57. data/lib/rays/texture.rb +1 -1
  58. data/rays.gemspec +16 -37
  59. data/src/bounds.cpp +234 -0
  60. data/src/cocoa/bitmap.mm +4 -4
  61. data/src/cocoa/font.mm +35 -30
  62. data/src/cocoa/rays.mm +2 -0
  63. data/src/color.cpp +77 -0
  64. data/src/colorspace.cpp +3 -3
  65. data/src/exception.cpp +3 -18
  66. data/src/image.cpp +9 -2
  67. data/src/matrix.cpp +103 -0
  68. data/src/painter.cpp +475 -224
  69. data/src/point.cpp +52 -0
  70. data/src/texture.cpp +14 -2
  71. data/src/win32/bitmap.cpp +2 -2
  72. data/src/win32/gdi.cpp +22 -13
  73. data/src/win32/gdi.h +7 -7
  74. data/test/helpers.rb +1 -5
  75. data/test/test_bitmap.rb +9 -0
  76. data/test/test_bounds.rb +246 -0
  77. data/test/test_color.rb +88 -0
  78. data/test/test_font.rb +28 -0
  79. data/test/test_image.rb +9 -0
  80. data/test/test_painter.rb +1 -3
  81. data/test/test_point.rb +121 -0
  82. data/test/test_rays.rb +2 -3
  83. data/test/test_texture.rb +1 -3
  84. metadata +146 -75
  85. data/include/rays/helpers.h +0 -37
  86. data/include/rays/transform.h +0 -35
  87. data/src/helpers.cpp +0 -22
  88. data/src/transform.cpp +0 -88
@@ -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& 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 new_type<Rays::Bitmap>(
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 this to<Rays::Bitmap*>(self)
54
+ #define THIS to<Rays::Bitmap*>(self)
48
55
 
49
- #define CHECK CHECK_OBJECT(self, Rays::Bitmap, Rays::bitmap_class())
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, new Rays::Bitmap);
62
+ return new_type<Rays::Bitmap>(klass);
56
63
  }
57
64
 
58
65
  static
59
- VALUE initialize(VALUE self)
66
+ VALUE setup(VALUE self, VALUE width, VALUE height, VALUE colorspace)
60
67
  {
61
- CHECK_OBJ(self, Rays::Bitmap, Rays::bitmap_class());
62
- if (argc != 0 && argc != 2 && argc != 3)
63
- arg_count_error("Bitmap#initialize", argc, 0, 2, 3);
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
- if (argc == 0) return self;
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
- int width = to<int>(argv[0]);
68
- int height = to<int>(argv[1]);
69
- uint colorspace = (argc == 3) ? to<uint>(argv[2]) : (uint) Rays::RGBA;
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(this->width());
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(this->height());
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(this->color_space().type());
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 = this->at<void*>(xx, yy);
106
- if (!pixel) error("Bitmap#at(%d, %d) failed.", xx, yy);
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(this->color_space().Bpp() / this->color_space().Bpc(), NULL);
109
- if (this->color_space().is_float())
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 (this->color_space().type())
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
- error("Bitmap#at: unknown color space");
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 (this->color_space().type())
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
- error("Bitmap#at: unknown color space");
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 = this->at<void*>(xx, yy);
198
- if (!pixel) error("Bitmap#assign_at(%d, %d) failed.", xx, yy);
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(this->color_space().Bpp() / this->color_space().Bpc(), NULL);
201
- if (this->color_space().is_float())
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 (this->color_space().type())
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
- error("Bitmap#at: unknown color space");
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 (this->color_space().type())
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
- error("Bitmap#at: unknown color space");
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
- error("Bitmap.load('%s') failed.", path.c_str());
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 m = rb_define_module("Rays");
303
-
304
- m.define_const("RGB", Rays::RGB);
305
- m.define_const("RGBA", Rays::RGBA);
306
-
307
- Class c = rb_define_class_under(m, "Bitmap", rb_cObject);
308
- Rays::cBitmap = c;
309
-
310
- rb_define_alloc_func(c, alloc);
311
- rb_define_method(c, "initialize", RUBY_METHOD_FUNC(initialize), -1);
312
- rb_define_method(c, "width", RUBY_METHOD_FUNC(width), 0);
313
- rb_define_method(c, "height", RUBY_METHOD_FUNC(height), 0);
314
- rb_define_method(c, "color_space", RUBY_METHOD_FUNC(color_space), 0);
315
- c.define_method("[]", at);
316
- c.define_method("[]=", assign_at);
317
- rb_define_function(c, "load", RUBY_METHOD_FUNC(load), 1);
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
  }
@@ -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& font)
35
+ value (const Rays::Font& obj)
35
36
  {
36
- return new_type<Rays::Font>(
37
- Rays::font_class(), new Rays::Font(font));
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 this to<Rays::Font*>(self)
50
+ #define THIS to<Rays::Font*>(self)
45
51
 
46
- #define CHECK CHECK_OBJECT(self, Rays::Font, Rays::font_class())
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, new Rays::Font);
58
+ return new_type<Rays::Font>(klass);
53
59
  }
54
60
 
55
61
  static
56
62
  VALUE initialize(VALUE self)
57
63
  {
58
- CHECK_OBJ(self, Rays::Font, Rays::font_class());
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
- *this = Rays::Font(name, size);
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(this->name().c_str());
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(this->size());
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 (!this->get_extent(&width, NULL, str.c_str()))
92
- error("Font#width(%s) failed.", str.inspect().c_str());
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 (!this->get_extent(NULL, &height, NULL))
104
- error("Font#height() failed.");
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 m = rb_define_module("Rays");
114
-
115
- Class c = rb_define_class_under(m, "Font", rb_cObject);
116
- Rays::cFont = c;
117
-
118
- rb_define_alloc_func(c, alloc);
119
- rb_define_method(c, "initialize", RUBY_METHOD_FUNC(initialize), -1);
120
- rb_define_method(c, "name", RUBY_METHOD_FUNC(name), 0);
121
- rb_define_method(c, "size", RUBY_METHOD_FUNC(size), 0);
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
  }
@@ -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& image)
37
+ value (const Rays::Image& obj)
37
38
  {
38
- return new_type<Rays::Image>(
39
- Rays::image_class(), new Rays::Image(image));
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 this to<Rays::Image*>(self)
52
+ #define THIS to<Rays::Image*>(self)
47
53
 
48
- #define CHECK CHECK_OBJECT(self, Rays::Image, Rays::image_class())
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, new Rays::Image);
60
+ return new_type<Rays::Image>(klass);
55
61
  }
56
62
 
57
63
  static
58
64
  VALUE initialize(VALUE self)
59
65
  {
60
- CHECK_OBJ(self, Rays::Image, Rays::image_class());
61
- if (argc != 0 && argc != 1 && argc != 2 && argc != 3)
62
- arg_count_error("Image#initialize", argc, 0, 1, 2, 3);
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[1].is_kind_of(Rays::bitmap_class()))
73
+ if (argv[0].is_kind_of(Rays::bitmap_class()))
67
74
  {
68
- if (argc != 1 && argc != 2)
69
- arg_count_error("Image#initialize", argc, 0, 1, 2, 3);
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
- const Rays::Bitmap& bitmap = *to<Rays::Bitmap*>(argv[1]);
72
- bool alphaonly = (argc == 2) ? to<bool>(argv[2]) : false;
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
- *this = Rays::Image(width, height, (Rays::ColorSpaceType) colorspace);
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(this->width());
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(this->height());
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(this->color_space().type());
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(this->bitmap());
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(this->texture());
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
- error(
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 m = rb_define_module("Rays");
151
-
152
- Class c = rb_define_class_under(m, "Image", rb_cObject);
153
- Rays::cImage = c;
154
-
155
- rb_define_alloc_func(c, alloc);
156
- rb_define_method(c, "initialize", RUBY_METHOD_FUNC(initialize), -1);
157
- rb_define_method(c, "width", RUBY_METHOD_FUNC(width), 0);
158
- rb_define_method(c, "height", RUBY_METHOD_FUNC(height), 0);
159
- rb_define_method(c, "color_space", RUBY_METHOD_FUNC(color_space), 0);
160
- rb_define_method(c, "bitmap", RUBY_METHOD_FUNC(bitmap), 0);
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
  }