rays 0.3.16 → 0.4.0

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 (58) hide show
  1. checksums.yaml +4 -4
  2. data/.doc/ext/rays/bitmap.cpp +1 -1
  3. data/.doc/ext/rays/bounds.cpp +1 -4
  4. data/.doc/ext/rays/camera.cpp +10 -2
  5. data/.doc/ext/rays/color.cpp +1 -3
  6. data/.doc/ext/rays/color_space.cpp +3 -3
  7. data/.doc/ext/rays/font.cpp +1 -4
  8. data/.doc/ext/rays/image.cpp +4 -3
  9. data/.doc/ext/rays/matrix.cpp +1 -4
  10. data/.doc/ext/rays/painter.cpp +8 -0
  11. data/.doc/ext/rays/point.cpp +1 -4
  12. data/.doc/ext/rays/polygon.cpp +11 -3
  13. data/.doc/ext/rays/polyline.cpp +13 -8
  14. data/.doc/ext/rays/rays.cpp +10 -6
  15. data/.doc/ext/rays/shader.cpp +13 -5
  16. data/.github/workflows/release-gem.yml +10 -1
  17. data/.github/workflows/test.yml +9 -0
  18. data/ChangeLog.md +10 -0
  19. data/VERSION +1 -1
  20. data/ext/rays/bitmap.cpp +1 -1
  21. data/ext/rays/bounds.cpp +1 -4
  22. data/ext/rays/camera.cpp +11 -2
  23. data/ext/rays/color.cpp +1 -3
  24. data/ext/rays/color_space.cpp +3 -3
  25. data/ext/rays/font.cpp +1 -4
  26. data/ext/rays/image.cpp +4 -3
  27. data/ext/rays/matrix.cpp +1 -4
  28. data/ext/rays/painter.cpp +9 -0
  29. data/ext/rays/point.cpp +1 -4
  30. data/ext/rays/polygon.cpp +12 -3
  31. data/ext/rays/polyline.cpp +14 -8
  32. data/ext/rays/rays.cpp +10 -6
  33. data/ext/rays/shader.cpp +14 -5
  34. data/include/rays/bitmap.h +1 -1
  35. data/include/rays/color_space.h +6 -2
  36. data/include/rays/defs.h +14 -4
  37. data/include/rays/image.h +2 -2
  38. data/lib/rays/camera.rb +1 -1
  39. data/lib/rays/extension.rb +1 -1
  40. data/lib/rays/image.rb +2 -2
  41. data/lib/rays/polygon.rb +1 -1
  42. data/lib/rays/polyline.rb +1 -1
  43. data/lib/rays/shader.rb +1 -1
  44. data/rays.gemspec +2 -2
  45. data/src/color_space.cpp +5 -5
  46. data/src/image.cpp +2 -2
  47. data/src/ios/bitmap.mm +3 -3
  48. data/src/ios/font.mm +3 -3
  49. data/src/opengl/bitmap.cpp +1 -1
  50. data/src/opengl/color_space.cpp +11 -2
  51. data/src/opengl/color_space.h +1 -1
  52. data/src/opengl/texture.cpp +5 -5
  53. data/src/osx/bitmap.mm +14 -3
  54. data/src/osx/font.mm +3 -3
  55. data/src/sdl/bitmap.cpp +28 -9
  56. data/src/texture.h +1 -1
  57. data/src/win32/bitmap.cpp +73 -35
  58. metadata +6 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6103dcc968b6fc21154ea86793205f78fdf698b5eea35ddbc88b504c2b5fdf03
4
- data.tar.gz: 06455c393ef928d7accf7e7639180d7b1bd599489d746af1cef9e989892559b8
3
+ metadata.gz: 3c4a61df95620a3670bc3c6ac06801ce4cb657bb6b2712766a369837289cc941
4
+ data.tar.gz: 9694b17c790a7c096053d69801e1d3f86efc90e7549be748392f2f420e38136a
5
5
  SHA512:
6
- metadata.gz: 9668987901e8ec97a694b3c760975b523d30588d4ac750c211e122d64036441b07ca44d02cf70ffb6779c1afdfc1743b2922cdd4f5c35244df3f837e60173e1d
7
- data.tar.gz: 87ce33df4fd7f581a673efdbc61847b1c2fb2c150bf69f10234f47c49bb091325750b368e5c54af41330cea357263668bd8a95d5a61bec60c1424b5b42d0f885
6
+ metadata.gz: a104aec9bf0808baad2503c28a8295f7be0b654f1fa1f7718b2a18c4c8d9fdfeb3220a5217f068fdd6e1eace5d2eaa10caf14801796147614d29252f43e03f1d
7
+ data.tar.gz: a83d43fdd44fbefeee5e60380e2f6541e6806521a4a93c896df29b7cbfeb128fda5738ade84b1bc7d79b7f14de5fe21ce781336b51ef9836053a72aea6381626
@@ -28,7 +28,7 @@ VALUE initialize(VALUE self)
28
28
 
29
29
  *THIS = Rays::Bitmap(
30
30
  to<int>(argv[0]), to<int>(argv[1]),
31
- argc >= 3 ? to<Rays::ColorSpace>(argv[2]) : Rays::RGBA);
31
+ argc >= 3 ? to<Rays::ColorSpace>(argv[2]) : Rays::DEFAULT_COLORSPACE);
32
32
 
33
33
  return self;
34
34
  }
@@ -1,7 +1,6 @@
1
1
  #include "rays/ruby/bounds.h"
2
2
 
3
3
 
4
- #include <assert.h>
5
4
  #include "rays/ruby/point.h"
6
5
  #include "defs.h"
7
6
 
@@ -589,14 +588,12 @@ namespace Rucy
589
588
  template <> RAYS_EXPORT Rays::Bounds
590
589
  value_to<Rays::Bounds> (int argc, const Value* argv, bool convert)
591
590
  {
592
- if (argc == 1 && argv->is_array())
591
+ if (argc == 1 && argv && argv->is_array())
593
592
  {
594
593
  argc = argv->size();
595
594
  argv = argv->as_array();
596
595
  }
597
596
 
598
- assert(argc == 0 || (argc > 0 && argv));
599
-
600
597
  if (convert)
601
598
  {
602
599
  if (argc == 0)
@@ -1,6 +1,7 @@
1
1
  #include "rays/ruby/camera.h"
2
2
 
3
3
 
4
+ #include "rays/exception.h"
4
5
  #include "rays/ruby/image.h"
5
6
  #include "defs.h"
6
7
 
@@ -19,7 +20,7 @@ VALUE alloc(VALUE klass)
19
20
  }
20
21
 
21
22
  static
22
- VALUE setup(VALUE self, VALUE device_name, VALUE min_width, VALUE min_height, VALUE resize, VALUE crop)
23
+ VALUE initialize(VALUE self, VALUE device_name, VALUE min_width, VALUE min_height, VALUE resize, VALUE crop)
23
24
  {
24
25
  RUCY_CHECK_OBJ(Rays::Camera, self);
25
26
 
@@ -30,6 +31,12 @@ VALUE setup(VALUE self, VALUE device_name, VALUE min_width, VALUE min_height, VA
30
31
  return self;
31
32
  }
32
33
 
34
+ static
35
+ VALUE initialize_copy(VALUE self, VALUE obj)
36
+ {
37
+ Rays::rays_error(__FILE__, __LINE__, "can not duplicate Camera");
38
+ }
39
+
33
40
  static
34
41
  VALUE start(VALUE self)
35
42
  {
@@ -140,7 +147,8 @@ Init_rays_camera ()
140
147
 
141
148
  cCamera = rb_define_class_under(mRays, "Camera", rb_cObject);
142
149
  rb_define_alloc_func(cCamera, alloc);
143
- rb_define_private_method(cCamera, "setup", RUBY_METHOD_FUNC(setup), 5);
150
+ cCamera.define_private_method("initialize!", initialize);
151
+ rb_define_private_method(cCamera, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
144
152
  rb_define_method(cCamera, "start", RUBY_METHOD_FUNC(start), 0);
145
153
  rb_define_method(cCamera, "stop", RUBY_METHOD_FUNC(stop), 0);
146
154
  cCamera.define_method("active?", is_active);
@@ -352,14 +352,12 @@ namespace Rucy
352
352
  template <> RAYS_EXPORT Rays::Color
353
353
  value_to<Rays::Color> (int argc, const Value*argv, bool convert)
354
354
  {
355
- if (argc == 1 && argv->is_array())
355
+ if (argc == 1 && argv && argv->is_array())
356
356
  {
357
357
  argc = argv->size();
358
358
  argv = argv->as_array();
359
359
  }
360
360
 
361
- assert(argc == 0 || (argc > 0 && argv));
362
-
363
361
  if (convert)
364
362
  {
365
363
  if (argc == 0)
@@ -1,7 +1,6 @@
1
1
  #include "rays/ruby/color_space.h"
2
2
 
3
3
 
4
- #include <assert.h>
5
4
  #include "defs.h"
6
5
 
7
6
 
@@ -209,13 +208,14 @@ namespace Rucy
209
208
  template <> RAYS_EXPORT Rays::ColorSpace
210
209
  value_to<Rays::ColorSpace> (int argc, const Value* argv, bool convert)
211
210
  {
212
- if (argc == 1 && argv->is_array())
211
+ if (argc == 1 && argv && argv->is_array())
213
212
  {
214
213
  argc = argv->size();
215
214
  argv = argv->as_array();
216
215
  }
217
216
 
218
- assert(argc > 0 && argv);
217
+ if (argc <= 0 || !argv)
218
+ argument_error(__FILE__, __LINE__);
219
219
 
220
220
  if (convert)
221
221
  {
@@ -1,7 +1,6 @@
1
1
  #include "rays/ruby/font.h"
2
2
 
3
3
 
4
- #include <assert.h>
5
4
  #include "defs.h"
6
5
 
7
6
 
@@ -176,14 +175,12 @@ namespace Rucy
176
175
  template <> RAYS_EXPORT Rays::Font
177
176
  value_to<Rays::Font> (int argc, const Value* argv, bool convert)
178
177
  {
179
- if (argc == 1 && argv->is_array())
178
+ if (argc == 1 && argv && argv->is_array())
180
179
  {
181
180
  argc = argv->size();
182
181
  argv = argv->as_array();
183
182
  }
184
183
 
185
- assert(argc == 0 || (argc > 0 && argv));
186
-
187
184
  if (convert)
188
185
  {
189
186
  if (argc == 0)
@@ -41,7 +41,7 @@ VALUE initialize(VALUE self, VALUE args, VALUE pixel_density, VALUE smooth)
41
41
  {
42
42
  int width = to<int>(args[0]);
43
43
  int height = to<int>(args[1]);
44
- auto cs = (argc >= 3) ? to<Rays::ColorSpace>(args[2]) : Rays::RGBA;
44
+ auto cs = (argc >= 3) ? to<Rays::ColorSpace>(args[2]) : Rays::DEFAULT_COLORSPACE;
45
45
  *THIS = Rays::Image(width, height, cs, pd, smooth);
46
46
  }
47
47
 
@@ -132,9 +132,10 @@ VALUE compare(VALUE self, VALUE other)
132
132
  }
133
133
 
134
134
  static
135
- VALUE load(VALUE self, VALUE path)
135
+ VALUE load(VALUE self, VALUE path, VALUE pixel_density, VALUE smooth)
136
136
  {
137
- return value(Rays::load_image(path.c_str()));
137
+ return value(Rays::load_image(
138
+ path.c_str(), to<float>(pixel_density), to<bool>(smooth)));
138
139
  }
139
140
 
140
141
 
@@ -1,7 +1,6 @@
1
1
  #include "rays/ruby/matrix.h"
2
2
 
3
3
 
4
- #include <assert.h>
5
4
  #include "rays/ruby/point.h"
6
5
  #include "defs.h"
7
6
 
@@ -284,14 +283,12 @@ namespace Rucy
284
283
  template <> RAYS_EXPORT Rays::Matrix
285
284
  value_to<Rays::Matrix> (int argc, const Value* argv, bool convert)
286
285
  {
287
- if (argc == 1 && argv->is_array())
286
+ if (argc == 1 && argv && argv->is_array())
288
287
  {
289
288
  argc = argv->size();
290
289
  argv = argv->as_array();
291
290
  }
292
291
 
293
- assert(argc == 0 || (argc > 0 && argv));
294
-
295
292
  if (convert)
296
293
  {
297
294
  if (argc == 0)
@@ -2,6 +2,7 @@
2
2
 
3
3
 
4
4
  #include <vector>
5
+ #include "rays/exception.h"
5
6
  #include "rays/ruby/point.h"
6
7
  #include "rays/ruby/bounds.h"
7
8
  #include "rays/ruby/color.h"
@@ -25,6 +26,12 @@ VALUE alloc(VALUE klass)
25
26
  return new_type<Rays::Painter>(klass);
26
27
  }
27
28
 
29
+ static
30
+ VALUE initialize_copy(VALUE self, VALUE obj)
31
+ {
32
+ Rays::rays_error(__FILE__, __LINE__, "can not duplicate Painter");
33
+ }
34
+
28
35
  static
29
36
  VALUE canvas(VALUE self)
30
37
  {
@@ -793,6 +800,7 @@ Init_rays_painter ()
793
800
 
794
801
  cPainter = rb_define_class_under(mRays, "Painter", rb_cObject);
795
802
  rb_define_alloc_func(cPainter, alloc);
803
+ rb_define_private_method(cPainter, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
796
804
 
797
805
  rb_define_method(cPainter, "canvas", RUBY_METHOD_FUNC(canvas), -1);
798
806
  rb_define_method(cPainter, "bounds", RUBY_METHOD_FUNC(bounds), 0);
@@ -1,7 +1,6 @@
1
1
  #include "rays/ruby/point.h"
2
2
 
3
3
 
4
- #include <assert.h>
5
4
  #include "defs.h"
6
5
 
7
6
 
@@ -282,14 +281,12 @@ namespace Rucy
282
281
  template <> RAYS_EXPORT Rays::Point
283
282
  value_to<Rays::Point> (int argc, const Value* argv, bool convert)
284
283
  {
285
- if (argc == 1 && argv->is_array())
284
+ if (argc == 1 && argv && argv->is_array())
286
285
  {
287
286
  argc = argv->size();
288
287
  argv = argv->as_array();
289
288
  }
290
289
 
291
- assert(argc == 0 || (argc > 0 && argv));
292
-
293
290
  if (convert)
294
291
  {
295
292
  if (argc == 0)
@@ -22,7 +22,7 @@ VALUE alloc(VALUE klass)
22
22
  }
23
23
 
24
24
  static
25
- VALUE setup(VALUE self, VALUE args, VALUE loop, VALUE colors, VALUE texcoords)
25
+ VALUE initialize(VALUE self, VALUE args, VALUE loop, VALUE colors, VALUE texcoords)
26
26
  {
27
27
  CHECK;
28
28
 
@@ -37,6 +37,13 @@ VALUE setup(VALUE self, VALUE args, VALUE loop, VALUE colors, VALUE texcoords)
37
37
  }
38
38
  }
39
39
 
40
+ static
41
+ VALUE initialize_copy(VALUE self, VALUE obj)
42
+ {
43
+ CHECK;
44
+ *THIS = to<Rays::Polygon&>(obj);
45
+ }
46
+
40
47
  static
41
48
  VALUE expand(VALUE self)
42
49
  {
@@ -98,7 +105,7 @@ VALUE each(VALUE self)
98
105
 
99
106
  Value ret = Qnil;
100
107
  for (const auto& polyline : *THIS)
101
- ret = rb_yield(value(polyline));
108
+ ret = yield(value(polyline));
102
109
  return ret;
103
110
  }
104
111
 
@@ -346,7 +353,8 @@ Init_rays_polygon ()
346
353
 
347
354
  cPolygon = rb_define_class_under(mRays, "Polygon", rb_cObject);
348
355
  rb_define_alloc_func(cPolygon, alloc);
349
- rb_define_private_method(cPolygon, "setup", RUBY_METHOD_FUNC(setup), 4);
356
+ cPolygon.define_private_method("initialize!", initialize);
357
+ rb_define_private_method(cPolygon, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
350
358
  rb_define_method(cPolygon, "expand", RUBY_METHOD_FUNC(expand), -1);
351
359
  rb_define_method(cPolygon, "bounds", RUBY_METHOD_FUNC(bounds), 0);
352
360
  rb_define_method(cPolygon, "size", RUBY_METHOD_FUNC(size), 0);
@@ -1,7 +1,6 @@
1
1
  #include "rays/ruby/polyline.h"
2
2
 
3
3
 
4
- #include <assert.h>
5
4
  #include <vector>
6
5
  #include "rays/ruby/color.h"
7
6
  #include "rays/ruby/point.h"
@@ -24,7 +23,7 @@ VALUE alloc(VALUE klass)
24
23
  }
25
24
 
26
25
  static
27
- VALUE setup(VALUE self, VALUE points, VALUE loop, VALUE fill, VALUE colors, VALUE texcoords, VALUE hole)
26
+ VALUE initialize(VALUE self, VALUE points, VALUE loop, VALUE fill, VALUE colors, VALUE texcoords, VALUE hole)
28
27
  {
29
28
  CHECK;
30
29
 
@@ -35,6 +34,13 @@ VALUE setup(VALUE self, VALUE points, VALUE loop, VALUE fill, VALUE colors, VALU
35
34
  hole);
36
35
  }
37
36
 
37
+ static
38
+ VALUE initialize_copy(VALUE self, VALUE obj)
39
+ {
40
+ CHECK;
41
+ *THIS = to<Rays::Polyline&>(obj);
42
+ }
43
+
38
44
  static
39
45
  VALUE expand(VALUE self)
40
46
  {
@@ -138,7 +144,7 @@ VALUE each_point(VALUE self)
138
144
 
139
145
  Value ret = Qnil;
140
146
  for (const auto& point : *THIS)
141
- ret = rb_yield(value(point));
147
+ ret = yield(value(point));
142
148
  return ret;
143
149
  }
144
150
 
@@ -154,7 +160,7 @@ VALUE each_color(VALUE self)
154
160
  {
155
161
  size_t size = THIS->size();
156
162
  for (size_t i = 0; i < size; ++i)
157
- ret = rb_yield(value(colors[i]));
163
+ ret = yield(value(colors[i]));
158
164
  }
159
165
  return ret;
160
166
  }
@@ -171,7 +177,7 @@ VALUE each_texcoord(VALUE self)
171
177
  {
172
178
  size_t size = THIS->size();
173
179
  for (size_t i = 0; i < size; ++i)
174
- ret = rb_yield(value(*(Rays::Point*) &texcoords[i]));
180
+ ret = yield(value(*(Rays::Point*) &texcoords[i]));
175
181
  }
176
182
  return ret;
177
183
  }
@@ -186,7 +192,8 @@ Init_rays_polyline ()
186
192
 
187
193
  cPolyline = rb_define_class_under(mRays, "Polyline", rb_cObject);
188
194
  rb_define_alloc_func(cPolyline, alloc);
189
- rb_define_private_method(cPolyline, "setup", RUBY_METHOD_FUNC(setup), 6);
195
+ cPolyline.define_private_method("initialize!", initialize);
196
+ rb_define_private_method(cPolyline, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
190
197
  rb_define_method(cPolyline, "expand", RUBY_METHOD_FUNC(expand), -1);
191
198
  rb_define_method(cPolyline, "bounds", RUBY_METHOD_FUNC(bounds), 0);
192
199
  cPolyline.define_method("loop?", is_loop);
@@ -211,8 +218,6 @@ namespace Rucy
211
218
  template <> RAYS_EXPORT Rays::Polyline
212
219
  value_to<Rays::Polyline> (int argc, const Value* argv, bool convert)
213
220
  {
214
- assert(argc == 0 || (argc > 0 && argv));
215
-
216
221
  if (convert)
217
222
  {
218
223
  if (argc <= 0)
@@ -1,7 +1,6 @@
1
1
  #include "rays/ruby/rays.h"
2
2
 
3
3
 
4
- #include <assert.h>
5
4
  #include <vector>
6
5
  #include "defs.h"
7
6
 
@@ -112,7 +111,8 @@ namespace Rucy
112
111
  template <> RAYS_EXPORT Rays::CapType
113
112
  value_to<Rays::CapType> (int argc, const Value* argv, bool convert)
114
113
  {
115
- assert(argc > 0 && argv);
114
+ if (argc <= 0 || !argv)
115
+ argument_error(__FILE__, __LINE__);
116
116
 
117
117
  if (convert)
118
118
  {
@@ -145,7 +145,8 @@ namespace Rucy
145
145
  template <> RAYS_EXPORT Rays::JoinType
146
146
  value_to<Rays::JoinType> (int argc, const Value* argv, bool convert)
147
147
  {
148
- assert(argc > 0 && argv);
148
+ if (argc <= 0 || !argv)
149
+ argument_error(__FILE__, __LINE__);
149
150
 
150
151
  if (convert)
151
152
  {
@@ -178,7 +179,8 @@ namespace Rucy
178
179
  template <> RAYS_EXPORT Rays::BlendMode
179
180
  value_to<Rays::BlendMode> (int argc, const Value* argv, bool convert)
180
181
  {
181
- assert(argc > 0 && argv);
182
+ if (argc <= 0 || !argv)
183
+ argument_error(__FILE__, __LINE__);
182
184
 
183
185
  if (convert)
184
186
  {
@@ -211,7 +213,8 @@ namespace Rucy
211
213
  template <> RAYS_EXPORT Rays::TexCoordMode
212
214
  value_to<Rays::TexCoordMode> (int argc, const Value* argv, bool convert)
213
215
  {
214
- assert(argc > 0 && argv);
216
+ if (argc <= 0 || !argv)
217
+ argument_error(__FILE__, __LINE__);
215
218
 
216
219
  if (convert)
217
220
  {
@@ -244,7 +247,8 @@ namespace Rucy
244
247
  template <> RAYS_EXPORT Rays::TexCoordWrap
245
248
  value_to<Rays::TexCoordWrap> (int argc, const Value* argv, bool convert)
246
249
  {
247
- assert(argc > 0 && argv);
250
+ if (argc <= 0 || !argv)
251
+ argument_error(__FILE__, __LINE__);
248
252
 
249
253
  if (convert)
250
254
  {
@@ -1,7 +1,7 @@
1
1
  #include "rays/ruby/shader.h"
2
2
 
3
3
 
4
- #include <assert.h>
4
+ #include "rays/exception.h"
5
5
  #include "rays/ruby/image.h"
6
6
  #include "defs.h"
7
7
 
@@ -19,6 +19,12 @@ VALUE alloc(VALUE klass)
19
19
  return new_type<Rays::Shader>(klass);
20
20
  }
21
21
 
22
+ static
23
+ VALUE initialize_copy(VALUE self, VALUE obj)
24
+ {
25
+ Rays::rays_error(__FILE__, __LINE__, "can not duplicate Shader");
26
+ }
27
+
22
28
  static const char*
23
29
  to_name (const Value& names, size_t index)
24
30
  {
@@ -81,7 +87,7 @@ make_env (const Value& names, const Value& ignore_no_uniform_location_error)
81
87
  }
82
88
 
83
89
  static
84
- VALUE setup(VALUE self, VALUE
90
+ VALUE initialize(VALUE self, VALUE
85
91
  fragment_shader_source, VALUE vertex_shader_source, VALUE
86
92
  builtin_variable_names, VALUE ignore_no_uniform_location_error)
87
93
  {
@@ -180,7 +186,8 @@ Init_rays_shader ()
180
186
 
181
187
  cShader = rb_define_class_under(mRays, "Shader", rb_cObject);
182
188
  rb_define_alloc_func(cShader, alloc);
183
- rb_define_private_method(cShader, "setup", RUBY_METHOD_FUNC(setup), 4);
189
+ cShader.define_private_method("initialize!", initialize);
190
+ rb_define_private_method(cShader, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
184
191
  rb_define_private_method(cShader, "set_uniform", RUBY_METHOD_FUNC(set_uniform), -1);
185
192
  rb_define_method(cShader, "vertex_shader_source", RUBY_METHOD_FUNC(get_vertex_shader_source), 0);
186
193
  rb_define_method(cShader, "fragment_shader_source", RUBY_METHOD_FUNC(get_fragment_shader_source), 0);
@@ -194,13 +201,14 @@ namespace Rucy
194
201
  template <> RAYS_EXPORT Rays::Shader
195
202
  value_to<Rays::Shader> (int argc, const Value* argv, bool convert)
196
203
  {
197
- if (argc == 1 && argv->is_array())
204
+ if (argc == 1 && argv && argv->is_array())
198
205
  {
199
206
  argc = argv->size();
200
207
  argv = argv->as_array();
201
208
  }
202
209
 
203
- assert(argc > 0 && argv);
210
+ if (argc <= 0 || !argv)
211
+ argument_error(__FILE__, __LINE__);
204
212
 
205
213
  if (convert)
206
214
  {
@@ -26,8 +26,17 @@ jobs:
26
26
  - name: setup dependencies
27
27
  run: "ruby -I.github/workflows -rutils -e 'setup_dependencies'"
28
28
 
29
+ - name: packages
30
+ run: bundle exec rake packages
31
+
32
+ - name: setup zig
33
+ if: github.event.repository.name == 'reflex-terminal'
34
+ uses: mlugg/setup-zig@v2
35
+ with:
36
+ version: 0.16.0
37
+
29
38
  - name: test
30
- run: bundle exec rake packages test
39
+ run: bundle exec rake test
31
40
 
32
41
  - name: create gem
33
42
  id: gem
@@ -27,6 +27,15 @@ jobs:
27
27
  - name: packages
28
28
  run: bundle exec rake verbose packages
29
29
 
30
+ - name: setup zig
31
+ if: github.event.repository.name == 'reflex-terminal'
32
+ uses: mlugg/setup-zig@v2
33
+ with:
34
+ version: 0.16.0
35
+
36
+ - name: vendor
37
+ run: bundle exec rake vendor
38
+
30
39
  - name: lib
31
40
  run: bundle exec rake verbose lib
32
41
 
data/ChangeLog.md CHANGED
@@ -1,6 +1,16 @@
1
1
  # rays ChangeLog
2
2
 
3
3
 
4
+ ## [v0.4.0] - 2026-08-04
5
+
6
+ - [BREAKING] Rename COLORSPACE_UNKNOWN to COLORSPACE_NONE
7
+ - [BREAKING] Default to BGRA color space on Windows
8
+ - Add pixel_density and smooth options to Image.load
9
+ - Support dup on value classes, reject it on stateful ones
10
+
11
+ - Fix crash when an empty array is passed where a Color, Point, Bounds, etc. is expected
12
+
13
+
4
14
  ## [v0.3.16] - 2026-06-23
5
15
 
6
16
  - Update dependencies
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.16
1
+ 0.4.0
data/ext/rays/bitmap.cpp CHANGED
@@ -29,7 +29,7 @@ RUCY_DEFN(initialize)
29
29
 
30
30
  *THIS = Rays::Bitmap(
31
31
  to<int>(argv[0]), to<int>(argv[1]),
32
- argc >= 3 ? to<Rays::ColorSpace>(argv[2]) : Rays::RGBA);
32
+ argc >= 3 ? to<Rays::ColorSpace>(argv[2]) : Rays::DEFAULT_COLORSPACE);
33
33
 
34
34
  return self;
35
35
  }
data/ext/rays/bounds.cpp CHANGED
@@ -1,7 +1,6 @@
1
1
  #include "rays/ruby/bounds.h"
2
2
 
3
3
 
4
- #include <assert.h>
5
4
  #include "rays/ruby/point.h"
6
5
  #include "defs.h"
7
6
 
@@ -636,14 +635,12 @@ namespace Rucy
636
635
  template <> RAYS_EXPORT Rays::Bounds
637
636
  value_to<Rays::Bounds> (int argc, const Value* argv, bool convert)
638
637
  {
639
- if (argc == 1 && argv->is_array())
638
+ if (argc == 1 && argv && argv->is_array())
640
639
  {
641
640
  argc = argv->size();
642
641
  argv = argv->as_array();
643
642
  }
644
643
 
645
- assert(argc == 0 || (argc > 0 && argv));
646
-
647
644
  if (convert)
648
645
  {
649
646
  if (argc == 0)
data/ext/rays/camera.cpp CHANGED
@@ -1,6 +1,7 @@
1
1
  #include "rays/ruby/camera.h"
2
2
 
3
3
 
4
+ #include "rays/exception.h"
4
5
  #include "rays/ruby/image.h"
5
6
  #include "defs.h"
6
7
 
@@ -20,7 +21,7 @@ RUCY_DEF_ALLOC(alloc, klass)
20
21
  RUCY_END
21
22
 
22
23
  static
23
- RUCY_DEF5(setup, device_name, min_width, min_height, resize, crop)
24
+ RUCY_DEF5(initialize, device_name, min_width, min_height, resize, crop)
24
25
  {
25
26
  RUCY_CHECK_OBJ(Rays::Camera, self);
26
27
 
@@ -32,6 +33,13 @@ RUCY_DEF5(setup, device_name, min_width, min_height, resize, crop)
32
33
  }
33
34
  RUCY_END
34
35
 
36
+ static
37
+ RUCY_DEF1(initialize_copy, obj)
38
+ {
39
+ Rays::rays_error(__FILE__, __LINE__, "can not duplicate Camera");
40
+ }
41
+ RUCY_END
42
+
35
43
  static
36
44
  RUCY_DEF0(start)
37
45
  {
@@ -155,7 +163,8 @@ Init_rays_camera ()
155
163
 
156
164
  cCamera = mRays.define_class("Camera");
157
165
  cCamera.define_alloc_func(alloc);
158
- cCamera.define_private_method("setup", setup);
166
+ cCamera.define_private_method("initialize!", initialize);
167
+ cCamera.define_private_method("initialize_copy", initialize_copy);
159
168
  cCamera.define_method("start", start);
160
169
  cCamera.define_method("stop", stop);
161
170
  cCamera.define_method("active?", is_active);
data/ext/rays/color.cpp CHANGED
@@ -366,14 +366,12 @@ namespace Rucy
366
366
  template <> RAYS_EXPORT Rays::Color
367
367
  value_to<Rays::Color> (int argc, const Value*argv, bool convert)
368
368
  {
369
- if (argc == 1 && argv->is_array())
369
+ if (argc == 1 && argv && argv->is_array())
370
370
  {
371
371
  argc = argv->size();
372
372
  argv = argv->as_array();
373
373
  }
374
374
 
375
- assert(argc == 0 || (argc > 0 && argv));
376
-
377
375
  if (convert)
378
376
  {
379
377
  if (argc == 0)
@@ -1,7 +1,6 @@
1
1
  #include "rays/ruby/color_space.h"
2
2
 
3
3
 
4
- #include <assert.h>
5
4
  #include "defs.h"
6
5
 
7
6
 
@@ -222,13 +221,14 @@ namespace Rucy
222
221
  template <> RAYS_EXPORT Rays::ColorSpace
223
222
  value_to<Rays::ColorSpace> (int argc, const Value* argv, bool convert)
224
223
  {
225
- if (argc == 1 && argv->is_array())
224
+ if (argc == 1 && argv && argv->is_array())
226
225
  {
227
226
  argc = argv->size();
228
227
  argv = argv->as_array();
229
228
  }
230
229
 
231
- assert(argc > 0 && argv);
230
+ if (argc <= 0 || !argv)
231
+ argument_error(__FILE__, __LINE__);
232
232
 
233
233
  if (convert)
234
234
  {