rays 0.1.12 → 0.1.17

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 +171 -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 +23 -81
  25. data/ext/rays/bounds.cpp +100 -128
  26. data/ext/rays/camera.cpp +186 -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 +74 -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 +24 -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 +23 -0
  107. data/src/ios/bitmap.mm +133 -110
  108. data/src/ios/camera.mm +510 -0
  109. data/src/ios/font.mm +50 -62
  110. data/src/ios/helper.h +4 -4
  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 +23 -0
  119. data/src/osx/bitmap.mm +133 -110
  120. data/src/osx/camera.mm +451 -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
@@ -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)
@@ -31,26 +24,28 @@ static
31
24
  VALUE initialize(VALUE self)
32
25
  {
33
26
  RUCY_CHECK_OBJ(Rays::Image, self);
34
- check_arg_count(__FILE__, __LINE__, "Image#initialize", argc, 1, 2, 3);
35
-
36
- if (argc == 0) return self;
27
+ check_arg_count(__FILE__, __LINE__, "Image#initialize", argc, 1, 2, 3, 4);
37
28
 
38
29
  if (argv[0].is_kind_of(Rays::bitmap_class()))
39
30
  {
40
31
  check_arg_count(__FILE__, __LINE__, "Image#initialize", argc, 1, 2);
41
32
 
42
33
  const Rays::Bitmap* bitmap = to<Rays::Bitmap*>(argv[0]);
43
- if (!bitmap) argument_error(__FILE__, __LINE__);
34
+ if (!bitmap)
35
+ argument_error(__FILE__, __LINE__);
44
36
 
45
- bool alpha_only = (argc == 2) ? to<bool>(argv[1]) : false;
46
- *THIS = Rays::Image(*bitmap, alpha_only);
37
+ float pixel_density = (argc >= 2) ? to<float>(argv[1]) : 1;
38
+ *THIS = Rays::Image(*bitmap, pixel_density);
47
39
  }
48
40
  else
49
41
  {
50
- int width = to<int>(argv[0]);
51
- int height = to<int>(argv[1]);
52
- uint colorspace = (argc == 3) ? to<uint>(argv[2]) : (uint) Rays::RGBA;
53
- *THIS = Rays::Image(width, height, (Rays::ColorSpaceType) colorspace);
42
+ check_arg_count(__FILE__, __LINE__, "Image#initialize", argc, 2, 3, 4);
43
+
44
+ int width = to<int>(argv[0]);
45
+ int height = to<int>(argv[1]);
46
+ Rays::ColorSpace cs = (argc >= 3) ? to<Rays::ColorSpace>(argv[2]) : Rays::RGBA;
47
+ float pixel_density = (argc >= 4) ? to<float>(argv[3]) : 1;
48
+ *THIS = Rays::Image(width, height, cs, pixel_density);
54
49
  }
55
50
 
56
51
  return self;
@@ -61,17 +56,10 @@ VALUE initialize_copy(VALUE self, VALUE obj)
61
56
  {
62
57
  RUCY_CHECK_OBJ(Rays::Image, self);
63
58
 
64
- *THIS = to<Rays::Image&>(obj).copy();
59
+ *THIS = to<Rays::Image&>(obj).dup();
65
60
  return self;
66
61
  }
67
62
 
68
- static
69
- VALUE painter(VALUE self)
70
- {
71
- CHECK;
72
- return value(THIS->painter());
73
- }
74
-
75
63
  static
76
64
  VALUE width(VALUE self)
77
65
  {
@@ -94,24 +82,24 @@ VALUE color_space(VALUE self)
94
82
  }
95
83
 
96
84
  static
97
- VALUE alpha_only(VALUE self)
85
+ VALUE pixel_density(VALUE self)
98
86
  {
99
87
  CHECK;
100
- return value(THIS->alpha_only());
88
+ return value(THIS->pixel_density());
101
89
  }
102
90
 
103
91
  static
104
- VALUE bitmap(VALUE self)
92
+ VALUE painter(VALUE self)
105
93
  {
106
94
  CHECK;
107
- return value(THIS->bitmap());
95
+ return value(THIS->painter());
108
96
  }
109
97
 
110
98
  static
111
- VALUE texture(VALUE self)
99
+ VALUE bitmap(VALUE self)
112
100
  {
113
101
  CHECK;
114
- return value(THIS->texture());
102
+ return value(THIS->bitmap());
115
103
  }
116
104
 
117
105
  static
@@ -124,9 +112,11 @@ VALUE save(VALUE self, VALUE path)
124
112
 
125
113
 
126
114
  static
127
- VALUE load(VALUE self, VALUE path, VALUE alpha_only)
115
+ VALUE load(VALUE self)
128
116
  {
129
- return value(Rays::load_image(path.c_str(), to<bool>(alpha_only)));
117
+ check_arg_count(__FILE__, __LINE__, "Image.load", argc, 1);
118
+
119
+ return value(Rays::load_image(argv[0].c_str()));
130
120
  }
131
121
 
132
122
 
@@ -141,15 +131,14 @@ Init_image ()
141
131
  rb_define_alloc_func(cImage, alloc);
142
132
  rb_define_private_method(cImage, "initialize", RUBY_METHOD_FUNC(initialize), -1);
143
133
  rb_define_private_method(cImage, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
144
- rb_define_method(cImage, "painter", RUBY_METHOD_FUNC(painter), 0);
145
134
  rb_define_method(cImage, "width", RUBY_METHOD_FUNC(width), 0);
146
135
  rb_define_method(cImage, "height", RUBY_METHOD_FUNC(height), 0);
147
136
  rb_define_method(cImage, "color_space", RUBY_METHOD_FUNC(color_space), 0);
148
- rb_define_method(cImage, "alpha_only", RUBY_METHOD_FUNC(alpha_only), 0);
137
+ rb_define_method(cImage, "pixel_density", RUBY_METHOD_FUNC(pixel_density), 0);
138
+ rb_define_method(cImage, "painter", RUBY_METHOD_FUNC(painter), 0);
149
139
  rb_define_method(cImage, "bitmap", RUBY_METHOD_FUNC(bitmap), 0);
150
- rb_define_method(cImage, "texture", RUBY_METHOD_FUNC(texture), 0);
151
140
  rb_define_method(cImage, "save", RUBY_METHOD_FUNC(save), 1);
152
- rb_define_function(cImage, "load_image", RUBY_METHOD_FUNC(load), 2);
141
+ rb_define_module_function(cImage, "load", RUBY_METHOD_FUNC(load), -1);
153
142
  }
154
143
 
155
144
 
@@ -1,14 +1,11 @@
1
1
  #include "rays/ruby/matrix.h"
2
2
 
3
3
 
4
- #include <rucy.h>
4
+ #include "rays/ruby/point.h"
5
5
  #include "defs.h"
6
6
 
7
7
 
8
- using namespace Rucy;
9
-
10
-
11
- RUCY_DEFINE_VALUE_FROM_TO(Rays::Matrix)
8
+ RUCY_DEFINE_VALUE_OR_ARRAY_FROM_TO(Rays::Matrix)
12
9
 
13
10
  #define THIS to<Rays::Matrix*>(self)
14
11
 
@@ -27,22 +24,8 @@ VALUE initialize(VALUE self)
27
24
  CHECK;
28
25
  check_arg_count(__FILE__, __LINE__, "Matrix#initialize", argc, 0, 1, 16);
29
26
 
30
- if (argc == 0) return self;
31
-
32
- switch (argc)
33
- {
34
- case 1:
35
- *THIS = Rays::Matrix(to<float>(argv[0]));
36
- break;
37
-
38
- case 16:
39
- *THIS = Rays::Matrix(
40
- to<float>(argv[0]), to<float>(argv[1]), to<float>(argv[2]), to<float>(argv[3]),
41
- to<float>(argv[4]), to<float>(argv[5]), to<float>(argv[6]), to<float>(argv[7]),
42
- to<float>(argv[8]), to<float>(argv[9]), to<float>(argv[10]), to<float>(argv[11]),
43
- to<float>(argv[12]), to<float>(argv[13]), to<float>(argv[14]), to<float>(argv[15]));
44
- break;
45
- }
27
+ if (argc > 0)
28
+ *THIS = to<Rays::Matrix>(argc, argv);
46
29
 
47
30
  return self;
48
31
  }
@@ -56,23 +39,23 @@ VALUE initialize_copy(VALUE self, VALUE obj)
56
39
  }
57
40
 
58
41
  static
59
- VALUE set(VALUE self)
42
+ VALUE reset(VALUE self)
60
43
  {
61
44
  CHECK;
62
- check_arg_count(__FILE__, __LINE__, "Matrix#initialize", argc, 0, 1, 16);
45
+ check_arg_count(__FILE__, __LINE__, "Matrix#reset", argc, 0, 1, 16);
63
46
 
64
47
  switch (argc)
65
48
  {
66
49
  case 0:
67
- *THIS = Rays::Matrix();
50
+ THIS->reset();
68
51
  break;
69
52
 
70
53
  case 1:
71
- *THIS = Rays::Matrix(to<float>(argv[0]));
54
+ THIS->reset(to<float>(argv[0]));
72
55
  break;
73
56
 
74
57
  case 16:
75
- *THIS = Rays::Matrix(
58
+ THIS->reset(
76
59
  to<float>(argv[0]), to<float>(argv[1]), to<float>(argv[2]), to<float>(argv[3]),
77
60
  to<float>(argv[4]), to<float>(argv[5]), to<float>(argv[6]), to<float>(argv[7]),
78
61
  to<float>(argv[8]), to<float>(argv[9]), to<float>(argv[10]), to<float>(argv[11]),
@@ -84,12 +67,128 @@ VALUE set(VALUE self)
84
67
  }
85
68
 
86
69
  static
87
- VALUE at(VALUE self, VALUE row, VALUE column)
70
+ VALUE translate(VALUE self)
71
+ {
72
+ CHECK;
73
+ check_arg_count(__FILE__, __LINE__, "Matrix#translate", argc, 1, 2, 3);
74
+
75
+ THIS->translate(to<Rays::Point>(argc, argv));
76
+ return self;
77
+ }
78
+
79
+ static
80
+ VALUE scale(VALUE self)
81
+ {
82
+ CHECK;
83
+ check_arg_count(__FILE__, __LINE__, "Matrix#scale", argc, 1, 2, 3);
84
+
85
+ THIS->scale(to<Rays::Point>(argc, argv));
86
+ return self;
87
+ }
88
+
89
+ static
90
+ VALUE rotate(VALUE self)
91
+ {
92
+ CHECK;
93
+ check_arg_count(__FILE__, __LINE__, "Matrix#rotate", argc, 1, 2, 4);
94
+
95
+ float degree = to<float>(argv[0]);
96
+
97
+ if (argc == 1)
98
+ THIS->rotate(degree);
99
+ else
100
+ THIS->rotate(degree, to<Rays::Point>(argc - 1, argv + 1));
101
+
102
+ return self;
103
+ }
104
+
105
+ static
106
+ VALUE to_a(VALUE self)
107
+ {
108
+ CHECK;
109
+ return array(
110
+ THIS->x0, THIS->y0, THIS->z0, THIS->w0,
111
+ THIS->x1, THIS->y1, THIS->z1, THIS->w1,
112
+ THIS->x2, THIS->y2, THIS->z2, THIS->w2,
113
+ THIS->x3, THIS->y3, THIS->z3, THIS->w3);
114
+ }
115
+
116
+ static
117
+ VALUE mult(VALUE self, VALUE val)
118
+ {
119
+ CHECK;
120
+
121
+ if (val.is_kind_of(Rays::matrix_class()))
122
+ return value(*THIS * to<Rays::Matrix&>(val));
123
+
124
+ if (val.is_kind_of(Rays::point_class()))
125
+ return value(*THIS * to<Rays::Point&>(val));
126
+
127
+ if (val.is_array())
128
+ {
129
+ if (val.size() == 16)
130
+ return value(*THIS * to<Rays::Matrix>(val));
131
+ else
132
+ return value(*THIS * to<Rays::Point>(val));
133
+ }
134
+
135
+ argument_error(__FILE__, __LINE__);
136
+ }
137
+
138
+ static
139
+ VALUE set_at(VALUE self, VALUE row, VALUE column, VALUE val)
140
+ {
141
+ CHECK;
142
+ return value(THIS->at(row.as_i(), column.as_i()) = to<float>(val));
143
+ }
144
+
145
+ static
146
+ VALUE get_at(VALUE self, VALUE row, VALUE column)
88
147
  {
89
148
  CHECK;
90
149
  return value(THIS->at(row.as_i(), column.as_i()));
91
150
  }
92
151
 
152
+ static
153
+ VALUE compare(VALUE self, VALUE other)
154
+ {
155
+ CHECK;
156
+
157
+ const Rays::Matrix& a = *THIS;
158
+ const Rays::Matrix& b = to<const Rays::Matrix&>(other);
159
+ for (int i = 0; i < Rays::Matrix::NELEM; ++i)
160
+ {
161
+ if (a[i] == b[i]) continue;
162
+ return value(a[i] < b[i] ? -1 : +1);
163
+ }
164
+ return value(0);
165
+ }
166
+
167
+ static
168
+ VALUE inspect(VALUE self)
169
+ {
170
+ CHECK;
171
+ return value(Xot::stringf("#<Rays::Matrix %s>", THIS->inspect().c_str()));
172
+ }
173
+
174
+ static
175
+ VALUE s_translate(VALUE self)
176
+ {
177
+ return translate(argc, argv, value(Rays::Matrix()));
178
+ }
179
+
180
+ static
181
+ VALUE s_scale(VALUE self)
182
+ {
183
+ return scale(argc, argv, value(Rays::Matrix()));
184
+ }
185
+
186
+ static
187
+ VALUE s_rotate(VALUE self)
188
+ {
189
+ return rotate(argc, argv, value(Rays::Matrix()));
190
+ }
191
+
93
192
 
94
193
  static Class cMatrix;
95
194
 
@@ -102,11 +201,69 @@ Init_matrix ()
102
201
  rb_define_alloc_func(cMatrix, alloc);
103
202
  rb_define_private_method(cMatrix, "initialize", RUBY_METHOD_FUNC(initialize), -1);
104
203
  rb_define_private_method(cMatrix, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
105
- rb_define_method(cMatrix, "set", RUBY_METHOD_FUNC(set), -1);
106
- rb_define_method(cMatrix, "at", RUBY_METHOD_FUNC(at), 2);
204
+ rb_define_method(cMatrix, "reset", RUBY_METHOD_FUNC(reset), -1);
205
+ rb_define_method(cMatrix, "translate", RUBY_METHOD_FUNC(translate), -1);
206
+ rb_define_method(cMatrix, "scale", RUBY_METHOD_FUNC(scale), -1);
207
+ rb_define_method(cMatrix, "rotate", RUBY_METHOD_FUNC(rotate), -1);
208
+ rb_define_method(cMatrix, "to_a", RUBY_METHOD_FUNC(to_a), 0);
209
+ cMatrix.define_method("*", mult);
210
+ cMatrix.define_method("[]=", set_at);
211
+ cMatrix.define_method("[]", get_at);
212
+ cMatrix.define_method("<=>", compare);
213
+ rb_define_method(cMatrix, "inspect", RUBY_METHOD_FUNC(inspect), 0);
214
+
215
+ rb_define_singleton_method(cMatrix, "translate", RUBY_METHOD_FUNC(s_translate), -1);
216
+ rb_define_singleton_method(cMatrix, "scale", RUBY_METHOD_FUNC(s_scale), -1);
217
+ rb_define_singleton_method(cMatrix, "rotate", RUBY_METHOD_FUNC(s_rotate), -1);
107
218
  }
108
219
 
109
220
 
221
+ namespace Rucy
222
+ {
223
+
224
+
225
+ template <> Rays::Matrix
226
+ value_to<Rays::Matrix> (int argc, const Value* argv, bool convert)
227
+ {
228
+ if (argc == 1 && argv->is_array())
229
+ {
230
+ argc = argv->size();
231
+ argv = argv->as_array();
232
+ }
233
+
234
+ assert(argc == 0 || (argc > 0 && argv));
235
+
236
+ if (convert)
237
+ {
238
+ if (argc == 0)
239
+ return Rays::Matrix();
240
+ else if (argv->is_num())
241
+ {
242
+ switch (argc)
243
+ {
244
+ #define V(i) argv[i].as_f(true)
245
+ case 1: return Rays::Matrix(V(0));
246
+ case 16: return Rays::Matrix(
247
+ V(0), V(1), V(2), V(3),
248
+ V(4), V(5), V(6), V(7),
249
+ V(8), V(9), V(10), V(11),
250
+ V(12), V(13), V(14), V(15));
251
+ #undef V
252
+ default: argument_error(__FILE__, __LINE__);
253
+ }
254
+ }
255
+ }
256
+
257
+ if (argc != 1)
258
+ argument_error(__FILE__, __LINE__);
259
+
260
+ return value_to<Rays::Matrix&>(*argv, convert);
261
+ }
262
+
263
+
264
+ }// Rucy
265
+
266
+
110
267
  namespace Rays
111
268
  {
112
269
 
@@ -1,24 +1,25 @@
1
- #include <rucy.h>
2
1
  #include "defs.h"
3
2
 
4
3
 
5
- using namespace Rucy;
6
-
7
-
8
4
  void Init_rays ();
9
5
 
10
6
  void Init_point ();
11
7
  void Init_bounds ();
12
8
  void Init_color ();
13
9
  void Init_color_space ();
10
+ void Init_matrix ();
14
11
 
12
+ void Init_painter ();
13
+ void Init_polyline ();
14
+ void Init_polygon_line ();
15
+ void Init_polygon ();
15
16
  void Init_bitmap ();
16
- void Init_texture ();
17
17
  void Init_image ();
18
18
  void Init_font ();
19
19
  void Init_shader ();
20
+ void Init_camera ();
20
21
 
21
- void Init_painter ();
22
+ void Init_noise ();
22
23
 
23
24
 
24
25
  extern "C" void
@@ -38,14 +39,19 @@ extern "C" void
38
39
  Init_bounds();
39
40
  Init_color();
40
41
  Init_color_space();
42
+ Init_matrix();
41
43
 
44
+ Init_painter();
45
+ Init_polyline();
46
+ Init_polygon_line();
47
+ Init_polygon();
42
48
  Init_bitmap();
43
- Init_texture();
44
49
  Init_image();
45
50
  Init_font();
46
51
  Init_shader();
52
+ Init_camera();
47
53
 
48
- Init_painter();
54
+ Init_noise();
49
55
 
50
56
  RUCY_CATCH
51
57
  }