rays 0.1.11 → 0.1.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (168) hide show
  1. checksums.yaml +5 -5
  2. data/.doc/ext/rays/bitmap.cpp +22 -76
  3. data/.doc/ext/rays/bounds.cpp +95 -125
  4. data/.doc/ext/rays/camera.cpp +88 -0
  5. data/.doc/ext/rays/color.cpp +223 -45
  6. data/.doc/ext/rays/color_space.cpp +146 -46
  7. data/.doc/ext/rays/defs.cpp +183 -0
  8. data/.doc/ext/rays/font.cpp +69 -21
  9. data/.doc/ext/rays/image.cpp +26 -37
  10. data/.doc/ext/rays/matrix.cpp +186 -29
  11. data/.doc/ext/rays/native.cpp +14 -8
  12. data/.doc/ext/rays/noise.cpp +53 -0
  13. data/.doc/ext/rays/painter.cpp +187 -292
  14. data/.doc/ext/rays/point.cpp +96 -77
  15. data/.doc/ext/rays/polygon.cpp +313 -0
  16. data/.doc/ext/rays/polygon_line.cpp +96 -0
  17. data/.doc/ext/rays/polyline.cpp +167 -0
  18. data/.doc/ext/rays/rays.cpp +103 -12
  19. data/.doc/ext/rays/shader.cpp +83 -9
  20. data/LICENSE +21 -0
  21. data/README.md +1 -1
  22. data/Rakefile +24 -9
  23. data/VERSION +1 -1
  24. data/ext/rays/bitmap.cpp +22 -80
  25. data/ext/rays/bounds.cpp +100 -128
  26. data/ext/rays/camera.cpp +94 -0
  27. data/ext/rays/color.cpp +231 -51
  28. data/ext/rays/color_space.cpp +149 -47
  29. data/ext/rays/defs.cpp +183 -0
  30. data/ext/rays/defs.h +26 -2
  31. data/ext/rays/extconf.rb +2 -3
  32. data/ext/rays/font.cpp +74 -24
  33. data/ext/rays/image.cpp +28 -40
  34. data/ext/rays/matrix.cpp +198 -30
  35. data/ext/rays/native.cpp +14 -8
  36. data/ext/rays/noise.cpp +55 -0
  37. data/ext/rays/painter.cpp +203 -298
  38. data/ext/rays/point.cpp +105 -81
  39. data/ext/rays/polygon.cpp +329 -0
  40. data/ext/rays/polygon_line.cpp +99 -0
  41. data/ext/rays/polyline.cpp +176 -0
  42. data/ext/rays/rays.cpp +103 -13
  43. data/ext/rays/shader.cpp +84 -9
  44. data/include/rays.h +10 -2
  45. data/include/rays/bitmap.h +14 -26
  46. data/include/rays/bounds.h +21 -4
  47. data/include/rays/camera.h +49 -0
  48. data/include/rays/color.h +25 -14
  49. data/include/rays/color_space.h +15 -10
  50. data/include/rays/coord.h +114 -0
  51. data/include/rays/debug.h +22 -0
  52. data/include/rays/defs.h +36 -0
  53. data/include/rays/exception.h +6 -2
  54. data/include/rays/font.h +4 -4
  55. data/include/rays/image.h +12 -18
  56. data/include/rays/matrix.h +50 -24
  57. data/include/rays/noise.h +42 -0
  58. data/include/rays/opengl.h +2 -50
  59. data/include/rays/painter.h +89 -93
  60. data/include/rays/point.h +44 -51
  61. data/include/rays/polygon.h +198 -0
  62. data/include/rays/polyline.h +71 -0
  63. data/include/rays/rays.h +3 -0
  64. data/include/rays/ruby.h +7 -1
  65. data/include/rays/ruby/bounds.h +1 -1
  66. data/include/rays/ruby/camera.h +41 -0
  67. data/include/rays/ruby/color.h +1 -1
  68. data/include/rays/ruby/color_space.h +1 -1
  69. data/include/rays/ruby/font.h +1 -1
  70. data/include/rays/ruby/matrix.h +1 -1
  71. data/include/rays/ruby/point.h +1 -1
  72. data/include/rays/ruby/polygon.h +52 -0
  73. data/include/rays/ruby/polyline.h +41 -0
  74. data/include/rays/ruby/rays.h +8 -0
  75. data/include/rays/ruby/shader.h +1 -1
  76. data/include/rays/shader.h +36 -8
  77. data/lib/rays.rb +7 -2
  78. data/lib/rays/bitmap.rb +0 -15
  79. data/lib/rays/bounds.rb +17 -23
  80. data/lib/rays/camera.rb +21 -0
  81. data/lib/rays/color.rb +20 -47
  82. data/lib/rays/color_space.rb +13 -13
  83. data/lib/rays/image.rb +3 -7
  84. data/lib/rays/matrix.rb +28 -0
  85. data/lib/rays/module.rb +4 -19
  86. data/lib/rays/painter.rb +78 -93
  87. data/lib/rays/point.rb +13 -21
  88. data/lib/rays/polygon.rb +58 -0
  89. data/lib/rays/polygon_line.rb +36 -0
  90. data/lib/rays/polyline.rb +32 -0
  91. data/lib/rays/shader.rb +20 -1
  92. data/rays.gemspec +5 -7
  93. data/src/bitmap.h +36 -0
  94. data/src/bounds.cpp +74 -11
  95. data/src/color.cpp +58 -23
  96. data/src/color_space.cpp +52 -34
  97. data/src/color_space.h +22 -0
  98. data/src/coord.cpp +170 -0
  99. data/src/coord.h +35 -0
  100. data/src/font.cpp +118 -0
  101. data/src/font.h +64 -0
  102. data/src/frame_buffer.cpp +37 -71
  103. data/src/frame_buffer.h +4 -4
  104. data/src/image.cpp +172 -98
  105. data/src/image.h +25 -0
  106. data/src/ios/bitmap.h +21 -0
  107. data/src/ios/bitmap.mm +129 -110
  108. data/src/ios/camera.mm +236 -0
  109. data/src/ios/font.mm +50 -62
  110. data/src/ios/helper.h +2 -2
  111. data/src/ios/opengl.mm +19 -4
  112. data/src/ios/rays.mm +3 -0
  113. data/src/matrix.cpp +111 -26
  114. data/src/matrix.h +30 -0
  115. data/src/noise.cpp +74 -0
  116. data/src/opengl.cpp +9 -27
  117. data/src/opengl.h +37 -0
  118. data/src/osx/bitmap.h +21 -0
  119. data/src/osx/bitmap.mm +129 -110
  120. data/src/osx/camera.mm +236 -0
  121. data/src/osx/font.mm +49 -62
  122. data/src/osx/helper.h +2 -2
  123. data/src/osx/opengl.mm +19 -83
  124. data/src/osx/rays.mm +3 -0
  125. data/src/painter.cpp +845 -671
  126. data/src/painter.h +24 -0
  127. data/src/point.cpp +140 -119
  128. data/src/polygon.cpp +1266 -0
  129. data/src/polygon.h +32 -0
  130. data/src/polyline.cpp +160 -0
  131. data/src/polyline.h +69 -0
  132. data/src/render_buffer.cpp +11 -4
  133. data/src/render_buffer.h +2 -2
  134. data/src/shader.cpp +163 -106
  135. data/src/shader.h +38 -0
  136. data/src/shader_program.cpp +533 -0
  137. data/src/{program.h → shader_program.h} +28 -16
  138. data/src/shader_source.cpp +140 -0
  139. data/src/shader_source.h +52 -0
  140. data/src/texture.cpp +136 -160
  141. data/src/texture.h +65 -0
  142. data/src/win32/bitmap.cpp +62 -52
  143. data/src/win32/font.cpp +11 -13
  144. data/src/win32/font.h +24 -0
  145. data/src/win32/gdi.h +6 -6
  146. data/test/helper.rb +0 -3
  147. data/test/test_bitmap.rb +31 -7
  148. data/test/test_bounds.rb +36 -0
  149. data/test/test_color.rb +59 -19
  150. data/test/test_color_space.rb +95 -0
  151. data/test/test_font.rb +5 -0
  152. data/test/test_image.rb +24 -20
  153. data/test/test_matrix.rb +106 -0
  154. data/test/test_painter.rb +157 -51
  155. data/test/test_painter_shape.rb +102 -0
  156. data/test/test_point.rb +29 -0
  157. data/test/test_polygon.rb +234 -0
  158. data/test/test_polygon_line.rb +167 -0
  159. data/test/test_polyline.rb +171 -0
  160. data/test/test_shader.rb +9 -9
  161. metadata +102 -70
  162. data/.doc/ext/rays/texture.cpp +0 -138
  163. data/ext/rays/texture.cpp +0 -149
  164. data/include/rays/ruby/texture.h +0 -41
  165. data/include/rays/texture.h +0 -71
  166. data/lib/rays/texture.rb +0 -24
  167. data/src/program.cpp +0 -648
  168. data/test/test_texture.rb +0 -27
@@ -0,0 +1,183 @@
1
+ #include "defs.h"
2
+
3
+
4
+ #include <assert.h>
5
+ #include "rays/ruby/bounds.h"
6
+ #include "rays/ruby/point.h"
7
+
8
+
9
+ void
10
+ get_line_args (std::vector<Rays::Point>* points, int argc, const Value* argv)
11
+ {
12
+ assert(points && argv);
13
+
14
+ points->clear();
15
+
16
+ if (argc <= 0)
17
+ return;
18
+
19
+ if (argv[0].is_num())
20
+ {
21
+ if (argc % 2 != 0)
22
+ argument_error(__FILE__, __LINE__);
23
+
24
+ points->reserve(argc / 2);
25
+ for (int i = 0; i < argc; i += 2)
26
+ {
27
+ coord x = to<coord>(argv[i + 0]);
28
+ coord y = to<coord>(argv[i + 1]);
29
+ points->emplace_back(Rays::Point(x, y));
30
+ }
31
+ }
32
+ else
33
+ {
34
+ points->reserve(argc);
35
+ for (int i = 0; i < argc; ++i)
36
+ points->emplace_back(to<Rays::Point>(argv[i]));
37
+ }
38
+ }
39
+
40
+ static uint
41
+ get_nsegment (Value nsegment)
42
+ {
43
+ int value = nsegment ? to<int>(nsegment) : 0;
44
+ if (value < 0) value = 0;
45
+ return (uint) value;
46
+ }
47
+
48
+ void get_rect_args (
49
+ coord* x, coord* y, coord* w, coord* h,
50
+ coord* lt, coord* rt, coord* lb, coord* rb,
51
+ uint* nseg,
52
+ int argc, const Value* argv,
53
+ Value round, Value lefttop, Value righttop, Value leftbottom, Value rightbottom,
54
+ Value nsegment)
55
+ {
56
+ assert(x && y && w && h && lt && rt && lb && rb && nseg && argv);
57
+
58
+ if (argc <= 0)
59
+ argument_error(__FILE__, __LINE__);
60
+
61
+ if (argv[0].is_kind_of(Rays::bounds_class()))
62
+ {
63
+ Rays::Bounds& b = to<Rays::Bounds&>(argv[0]);
64
+ *x = b.x;
65
+ *y = b.y;
66
+ *w = b.w;
67
+ *h = b.h;
68
+ *lt = argc >= 2 ? to<coord>(argv[1]) : 0;
69
+ *rt = argc >= 3 ? to<coord>(argv[2]) : *lt;
70
+ *lb = argc >= 4 ? to<coord>(argv[3]) : *lt;
71
+ *rb = argc >= 5 ? to<coord>(argv[4]) : *lt;
72
+ }
73
+ else if (argv[0].is_kind_of(Rays::point_class()))
74
+ {
75
+ if (argc < 2)
76
+ argument_error(__FILE__, __LINE__);
77
+
78
+ Rays::Point& p = to<Rays::Point&>(argv[0]);
79
+ *x = p.x;
80
+ *y = p.y;
81
+ *w = to<coord>(argv[1]);
82
+ *h = argc >= 3 ? to<coord>(argv[2]) : *w;
83
+ *lt = argc >= 4 ? to<coord>(argv[3]) : 0;
84
+ *rt = argc >= 5 ? to<coord>(argv[4]) : *lt;
85
+ *lb = argc >= 6 ? to<coord>(argv[5]) : *lt;
86
+ *rb = argc >= 7 ? to<coord>(argv[6]) : *lt;
87
+ }
88
+ else if (argc <= 2)
89
+ {
90
+ *x = *y = *lt = *rt = *lb = *rb = 0;
91
+ *w = to<coord>(argv[0]);
92
+ *h = argc >= 2 ? to<coord>(argv[1]) : *w;
93
+ }
94
+ else
95
+ {
96
+ *x = to<coord>(argv[0]);
97
+ *y = to<coord>(argv[1]);
98
+ *w = to<coord>(argv[2]);
99
+ *h = argc >= 4 ? to<coord>(argv[3]) : *w;
100
+ *lt = argc >= 5 ? to<coord>(argv[4]) : 0;
101
+ *rt = argc >= 6 ? to<coord>(argv[5]) : *lt;
102
+ *lb = argc >= 7 ? to<coord>(argv[6]) : *lt;
103
+ *rb = argc >= 8 ? to<coord>(argv[7]) : *lt;
104
+ }
105
+
106
+ if (! lefttop) lefttop = round;
107
+ if (!righttop) righttop = round;
108
+ if (! leftbottom) leftbottom = round;
109
+ if (!rightbottom) rightbottom = round;
110
+
111
+ if ( lefttop) *lt = to<coord>( lefttop);
112
+ if (righttop) *rt = to<coord>(righttop);
113
+ if ( leftbottom) *lb = to<coord>( leftbottom);
114
+ if (rightbottom) *rb = to<coord>(rightbottom);
115
+
116
+ *nseg = get_nsegment(nsegment);
117
+ }
118
+
119
+ void get_ellipse_args (
120
+ coord* x, coord* y, coord* w, coord* h,
121
+ Rays::Point* hole_size, float* from, float* to_,
122
+ uint* nseg,
123
+ int argc, const Value* argv,
124
+ Value center, Value radius, Value hole, Value angle_from, Value angle_to,
125
+ Value nsegment)
126
+ {
127
+ assert(x && y && w && h && hole_size && from && to_ && nseg && argv);
128
+
129
+ if (argc <= 0)
130
+ argument_error(__FILE__, __LINE__);
131
+
132
+ if (argv[0].is_kind_of(Rays::bounds_class()))
133
+ {
134
+ const Rays::Bounds& b = to<Rays::Bounds&>(argv[0]);
135
+ *x = b.x;
136
+ *y = b.y;
137
+ *w = b.w;
138
+ *h = b.h;
139
+ }
140
+ else if (argv[0].is_kind_of(Rays::point_class()))
141
+ {
142
+ if (argc < 2)
143
+ argument_error(__FILE__, __LINE__);
144
+
145
+ const Rays::Point& p = to<Rays::Point&>(argv[0]);
146
+ *x = p.x;
147
+ *y = p.y;
148
+ *w = to<coord>(argv[1]);
149
+ *h = argc >= 3 ? to<coord>(argv[2]) : *w;
150
+ }
151
+ else if (argc <= 2)
152
+ {
153
+ *x = *y = 0;
154
+ *w = to<coord>(argv[0]);
155
+ *h = argc >= 2 ? to<coord>(argv[1]) : *w;
156
+ }
157
+ else
158
+ {
159
+ *x = to<coord>(argv[0]);
160
+ *y = to<coord>(argv[1]);
161
+ *w = to<coord>(argv[2]);
162
+ *h = argc >= 4 ? to<coord>(argv[3]) : *w;
163
+ }
164
+
165
+ if (center)
166
+ {
167
+ Rays::Point p = to<Rays::Point>(center);
168
+ *x = p.x;
169
+ *y = p.y;
170
+ }
171
+
172
+ if (radius)
173
+ {
174
+ Rays::Point p = to<Rays::Point>(radius);
175
+ *w = p.x * 2;
176
+ *h = p.y * 2;
177
+ }
178
+
179
+ *hole_size = hole ? to<Rays::Point>(hole) : 0;
180
+ *from = angle_from ? to<float>(angle_from) : 0;
181
+ *to_ = angle_to ? to<float>(angle_to) : 360;
182
+ *nseg = get_nsegment(nsegment);
183
+ }
@@ -4,10 +4,34 @@
4
4
  #define __RAYS_EXT_DEFS_H__
5
5
 
6
6
 
7
- #include <rays/exception.h>
7
+ #include <vector>
8
+ #include <rucy.h>
9
+ #include <rays/defs.h>
10
+ #include <rays/point.h>
8
11
 
9
12
 
10
- using Rays::rays_error;
13
+ using namespace Rucy;
14
+
15
+ using Rays::coord;
16
+
17
+
18
+ void get_line_args (
19
+ std::vector<Rays::Point>* points,
20
+ int argc, const Value* argv);
21
+
22
+ void get_rect_args (
23
+ coord* x, coord* y, coord* w, coord* h,
24
+ coord* lt, coord* rt, coord* lb, coord* rb, uint* nseg,
25
+ int argc, const Value* argv,
26
+ Value round, Value lefttop, Value righttop, Value leftbottom, Value rightbottom,
27
+ Value nsegment);
28
+
29
+ void get_ellipse_args (
30
+ coord* x, coord* y, coord* w, coord* h,
31
+ Rays::Point* hole_size, float* from, float* to, uint* nseg,
32
+ int argc, const Value* argv,
33
+ Value center, Value radius, Value hole, Value angel_from, Value angle_to,
34
+ Value nsegment);
11
35
 
12
36
 
13
37
  #endif//EOH
@@ -14,13 +14,12 @@ require 'rays/module'
14
14
 
15
15
  Xot::ExtConf.new Xot, Rucy, Rays do
16
16
  setup do
17
- headers << 'boost/noncopyable.hpp' << 'ruby.h'
17
+ headers << 'ruby.h'
18
18
  local_libs << 'rucy'
19
19
  libs.unshift 'gdi21', 'opengl32' if win32?
20
- frameworks << 'AppKit' << 'OpenGL' if osx?
20
+ frameworks << 'AppKit' << 'OpenGL' << 'AVFoundation' if osx?
21
21
  $LDFLAGS << ' -Wl,--out-implib=native.dll.a' if cygwin?
22
22
  end
23
23
 
24
- dir_config 'boost'
25
24
  create_makefile 'rays/native'
26
25
  end
@@ -1,16 +1,10 @@
1
1
  #include "rays/ruby/font.h"
2
2
 
3
3
 
4
- #include <rucy.h>
5
4
  #include "defs.h"
6
5
 
7
6
 
8
- using namespace Rucy;
9
-
10
- using Rays::coord;
11
-
12
-
13
- RUCY_DEFINE_VALUE_FROM_TO(Rays::Font)
7
+ RUCY_DEFINE_VALUE_OR_ARRAY_FROM_TO(Rays::Font)
14
8
 
15
9
  #define THIS to<Rays::Font*>(self)
16
10
 
@@ -30,20 +24,7 @@ RUCY_DEFN(initialize)
30
24
  RUCY_CHECK_OBJ(Rays::Font, self);
31
25
  check_arg_count(__FILE__, __LINE__, "Font#initialize", argc, 0, 1, 2);
32
26
 
33
- const char* name = (argc >= 1) ? argv[0].c_str() : NULL;
34
- float size = (argc >= 2) ? to<float>(argv[1]) : 0;
35
- *THIS = Rays::Font(name, size);
36
-
37
- return self;
38
- }
39
- RUCY_END
40
-
41
- static
42
- RUCY_DEF1(initialize_copy, obj)
43
- {
44
- RUCY_CHECK_OBJ(Rays::Font, self);
45
-
46
- *THIS = to<Rays::Font&>(obj).copy();
27
+ *THIS = to<Rays::Font>(argc, argv);
47
28
  return self;
48
29
  }
49
30
  RUCY_END
@@ -80,6 +61,36 @@ RUCY_DEF0(height)
80
61
  }
81
62
  RUCY_END
82
63
 
64
+ static
65
+ RUCY_DEF0(ascent)
66
+ {
67
+ CHECK;
68
+ coord ascent = 0;
69
+ THIS->get_height(&ascent);
70
+ return value(ascent);
71
+ }
72
+ RUCY_END
73
+
74
+ static
75
+ RUCY_DEF0(descent)
76
+ {
77
+ CHECK;
78
+ coord descent = 0;
79
+ THIS->get_height(NULL, &descent);
80
+ return value(descent);
81
+ }
82
+ RUCY_END
83
+
84
+ static
85
+ RUCY_DEF0(leading)
86
+ {
87
+ CHECK;
88
+ coord leading = 0;
89
+ THIS->get_height(NULL, NULL, &leading);
90
+ return value(leading);
91
+ }
92
+ RUCY_END
93
+
83
94
 
84
95
  static Class cFont;
85
96
 
@@ -91,14 +102,53 @@ Init_font ()
91
102
  cFont = mRays.define_class("Font");
92
103
  cFont.define_alloc_func(alloc);
93
104
  cFont.define_private_method("initialize", initialize);
94
- cFont.define_private_method("initialize_copy", initialize_copy);
95
105
  cFont.define_method("name", name);
96
106
  cFont.define_method("size", size);
97
- cFont.define_method("width", width);
98
- cFont.define_method("height", height);
107
+ cFont.define_method("width", width);
108
+ cFont.define_method("height", height);
109
+ cFont.define_method("ascent", ascent);
110
+ cFont.define_method("descent", descent);
111
+ cFont.define_method("leading", leading);
99
112
  }
100
113
 
101
114
 
115
+ namespace Rucy
116
+ {
117
+
118
+
119
+ template <> Rays::Font
120
+ value_to<Rays::Font> (int argc, const Value* argv, bool convert)
121
+ {
122
+ if (argc == 1 && argv->is_array())
123
+ {
124
+ argc = argv->size();
125
+ argv = argv->as_array();
126
+ }
127
+
128
+ assert(argc == 0 || (argc > 0 && argv));
129
+
130
+ if (convert)
131
+ {
132
+ if (argc == 0)
133
+ return Rays::default_font();
134
+
135
+ coord size = argc >= 2 ? to<coord>(argv[1]) : 0;
136
+ if (argv->is_nil())
137
+ return Rays::Font(NULL, size);
138
+ else if (argv->is_s() || argv->is_sym())
139
+ return Rays::Font(argv[0].c_str(), size);
140
+ }
141
+
142
+ if (argc != 1)
143
+ argument_error(__FILE__, __LINE__);
144
+
145
+ return value_to<Rays::Font&>(*argv, convert);
146
+ }
147
+
148
+
149
+ }// Rucy
150
+
151
+
102
152
  namespace Rays
103
153
  {
104
154
 
@@ -1,19 +1,12 @@
1
1
  #include "rays/ruby/image.h"
2
2
 
3
3
 
4
- #include <rucy.h>
5
4
  #include "rays/ruby/color_space.h"
6
5
  #include "rays/ruby/bitmap.h"
7
- #include "rays/ruby/texture.h"
8
6
  #include "rays/ruby/painter.h"
9
7
  #include "defs.h"
10
8
 
11
9
 
12
- using namespace Rucy;
13
-
14
- using Rays::coord;
15
-
16
-
17
10
  RUCY_DEFINE_VALUE_FROM_TO(Rays::Image)
18
11
 
19
12
  #define THIS to<Rays::Image*>(self)
@@ -32,26 +25,28 @@ static
32
25
  RUCY_DEFN(initialize)
33
26
  {
34
27
  RUCY_CHECK_OBJ(Rays::Image, self);
35
- check_arg_count(__FILE__, __LINE__, "Image#initialize", argc, 1, 2, 3);
36
-
37
- if (argc == 0) return self;
28
+ check_arg_count(__FILE__, __LINE__, "Image#initialize", argc, 1, 2, 3, 4);
38
29
 
39
30
  if (argv[0].is_kind_of(Rays::bitmap_class()))
40
31
  {
41
32
  check_arg_count(__FILE__, __LINE__, "Image#initialize", argc, 1, 2);
42
33
 
43
34
  const Rays::Bitmap* bitmap = to<Rays::Bitmap*>(argv[0]);
44
- if (!bitmap) argument_error(__FILE__, __LINE__);
35
+ if (!bitmap)
36
+ argument_error(__FILE__, __LINE__);
45
37
 
46
- bool alpha_only = (argc == 2) ? to<bool>(argv[1]) : false;
47
- *THIS = Rays::Image(*bitmap, alpha_only);
38
+ float pixel_density = (argc >= 2) ? to<float>(argv[1]) : 1;
39
+ *THIS = Rays::Image(*bitmap, pixel_density);
48
40
  }
49
41
  else
50
42
  {
51
- int width = to<int>(argv[0]);
52
- int height = to<int>(argv[1]);
53
- uint colorspace = (argc == 3) ? to<uint>(argv[2]) : (uint) Rays::RGBA;
54
- *THIS = Rays::Image(width, height, (Rays::ColorSpaceType) colorspace);
43
+ check_arg_count(__FILE__, __LINE__, "Image#initialize", argc, 2, 3, 4);
44
+
45
+ int width = to<int>(argv[0]);
46
+ int height = to<int>(argv[1]);
47
+ Rays::ColorSpace cs = (argc >= 3) ? to<Rays::ColorSpace>(argv[2]) : Rays::RGBA;
48
+ float pixel_density = (argc >= 4) ? to<float>(argv[3]) : 1;
49
+ *THIS = Rays::Image(width, height, cs, pixel_density);
55
50
  }
56
51
 
57
52
  return self;
@@ -63,19 +58,11 @@ RUCY_DEF1(initialize_copy, obj)
63
58
  {
64
59
  RUCY_CHECK_OBJ(Rays::Image, self);
65
60
 
66
- *THIS = to<Rays::Image&>(obj).copy();
61
+ *THIS = to<Rays::Image&>(obj).dup();
67
62
  return self;
68
63
  }
69
64
  RUCY_END
70
65
 
71
- static
72
- RUCY_DEF0(painter)
73
- {
74
- CHECK;
75
- return value(THIS->painter());
76
- }
77
- RUCY_END
78
-
79
66
  static
80
67
  RUCY_DEF0(width)
81
68
  {
@@ -101,26 +88,26 @@ RUCY_DEF0(color_space)
101
88
  RUCY_END
102
89
 
103
90
  static
104
- RUCY_DEF0(alpha_only)
91
+ RUCY_DEF0(pixel_density)
105
92
  {
106
93
  CHECK;
107
- return value(THIS->alpha_only());
94
+ return value(THIS->pixel_density());
108
95
  }
109
96
  RUCY_END
110
97
 
111
98
  static
112
- RUCY_DEF0(bitmap)
99
+ RUCY_DEF0(painter)
113
100
  {
114
101
  CHECK;
115
- return value(THIS->bitmap());
102
+ return value(THIS->painter());
116
103
  }
117
104
  RUCY_END
118
105
 
119
106
  static
120
- RUCY_DEF0(texture)
107
+ RUCY_DEF0(bitmap)
121
108
  {
122
109
  CHECK;
123
- return value(THIS->texture());
110
+ return value(THIS->bitmap());
124
111
  }
125
112
  RUCY_END
126
113
 
@@ -135,9 +122,11 @@ RUCY_END
135
122
 
136
123
 
137
124
  static
138
- RUCY_DEF2(load, path, alpha_only)
125
+ RUCY_DEFN(load)
139
126
  {
140
- return value(Rays::load_image(path.c_str(), to<bool>(alpha_only)));
127
+ check_arg_count(__FILE__, __LINE__, "Image.load", argc, 1);
128
+
129
+ return value(Rays::load_image(argv[0].c_str()));
141
130
  }
142
131
  RUCY_END
143
132
 
@@ -151,17 +140,16 @@ Init_image ()
151
140
 
152
141
  cImage = mRays.define_class("Image");
153
142
  cImage.define_alloc_func(alloc);
154
- cImage.define_private_method("initialize", initialize);
143
+ cImage.define_private_method("initialize", initialize);
155
144
  cImage.define_private_method("initialize_copy", initialize_copy);
156
- cImage.define_method("painter", painter);
157
- cImage.define_method("width", width);
145
+ cImage.define_method("width", width);
158
146
  cImage.define_method("height", height);
159
147
  cImage.define_method("color_space", color_space);
160
- cImage.define_method("alpha_only", alpha_only);
148
+ cImage.define_method("pixel_density", pixel_density);
149
+ cImage.define_method("painter", painter);
161
150
  cImage.define_method("bitmap", bitmap);
162
- cImage.define_method("texture", texture);
163
151
  cImage.define_method("save", save);
164
- cImage.define_function("load_image", load);
152
+ cImage.define_module_function("load", load);
165
153
  }
166
154
 
167
155