rays 0.1.39 → 0.1.40

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f822523cc0b4b94ce7f76cfe73eecf06cec674230605d74999d03b4c47cafebc
4
- data.tar.gz: ce2f362baca442ada14c7e3b770e0194063334531733773329d4a5023d30e712
3
+ metadata.gz: f28cc1bd39b3a7b5a6e801693d0642fbd3e3a4af7871a800c8d7378f5ef9427d
4
+ data.tar.gz: ad0decfd29260689a65b38c12ca6fc4897730a79660865ab9fcf15d0458305ef
5
5
  SHA512:
6
- metadata.gz: '06429b08ad69b515da932a8a3d29055f19ee650c2d3c9b67b524c40fd2ecc40371edd1c5b4447b871835fc78fbae0ecc72a6354dd380c98edc38979792537e4a'
7
- data.tar.gz: df507d34e172092d10d6c4d50f43b9207e209ca45f521c99a74cc6330e556195b05f7deb35831ef978f09a67d953dc884a52203bc1c35b06918c9811f356d0ef
6
+ metadata.gz: f2412027656abd1d92fc21acd7197a7c3c4469248806e174f4b76bd9befe5cf5247f09a6539a2aababe72ff556700c93047dc46344f2a06d079137f07949de7c
7
+ data.tar.gz: b0355b91a402279278b4c892df9bd2c6312f46f3f536974e076c89bea940096d48ad9d14f6ee9fd37dfe274293e6d8c4fc3f1bfb9221abfafce03d7cc3a44015
@@ -67,17 +67,17 @@ VALUE color_space(VALUE self)
67
67
  }
68
68
 
69
69
  static
70
- VALUE set_at(VALUE self)
70
+ VALUE set_at(VALUE self, VALUE x, VALUE y, VALUE color)
71
71
  {
72
72
  CHECK;
73
- check_arg_count(__FILE__, __LINE__, "Bitmap#set_at", argc, 3, 4, 5, 6);
74
73
 
75
- int x = to<int>(argv[0]);
76
- int y = to<int>(argv[1]);
77
- Rays::Color color = to<Rays::Color>(argc - 2, argv + 2);
74
+ bool is_array = color.is_array();
75
+ size_t argc = is_array ? color.size() : 1;
76
+ const Value* argv = is_array ? color.as_array() : &color;
77
+ to<Rays::Color>(argc, argv)
78
+ .get(THIS->at<void>(to<int>(x), to<int>(y)), THIS->color_space());
78
79
 
79
- color.get(THIS->at<void>(x, y), THIS->color_space());
80
- return value(color);
80
+ return color;
81
81
  }
82
82
 
83
83
  static
data/ChangeLog.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # rays ChangeLog
2
2
 
3
3
 
4
+ ## [v0.1.40] - 2023-06-07
5
+
6
+ - Redesign parameters for Bitmap#[]=
7
+
8
+
4
9
  ## [v0.1.39] - 2023-05-29
5
10
 
6
11
  - Add Painter#painting?
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.39
1
+ 0.1.40
data/ext/rays/bitmap.cpp CHANGED
@@ -73,17 +73,17 @@ RUCY_DEF0(color_space)
73
73
  RUCY_END
74
74
 
75
75
  static
76
- RUCY_DEFN(set_at)
76
+ RUCY_DEF3(set_at, x, y, color)
77
77
  {
78
78
  CHECK;
79
- check_arg_count(__FILE__, __LINE__, "Bitmap#set_at", argc, 3, 4, 5, 6);
80
79
 
81
- int x = to<int>(argv[0]);
82
- int y = to<int>(argv[1]);
83
- Rays::Color color = to<Rays::Color>(argc - 2, argv + 2);
80
+ bool is_array = color.is_array();
81
+ size_t argc = is_array ? color.size() : 1;
82
+ const Value* argv = is_array ? color.as_array() : &color;
83
+ to<Rays::Color>(argc, argv)
84
+ .get(THIS->at<void>(to<int>(x), to<int>(y)), THIS->color_space());
84
85
 
85
- color.get(THIS->at<void>(x, y), THIS->color_space());
86
- return value(color);
86
+ return color;
87
87
  }
88
88
  RUCY_END
89
89
 
data/test/test_bitmap.rb CHANGED
@@ -34,8 +34,21 @@ class TestBitmap < Test::Unit::TestCase
34
34
  def test_at()
35
35
  o = bitmap
36
36
  assert_equal color(0, 0, 0, 0), o[0, 0]
37
- o[0, 0] = 1
37
+
38
+ o[0, 0] = 1
38
39
  assert_equal color(1, 1, 1, 1), o[0, 0]
40
+
41
+ o[0, 0] = [0, 1, 0]
42
+ assert_equal color(0, 1, 0, 1), o[0, 0]
43
+
44
+ o[0, 0] = [0, 1, 0, 0]
45
+ assert_equal color(0, 1, 0, 0), o[0, 0]
46
+
47
+ o[0, 0] = color(0, 0, 1)
48
+ assert_equal color(0, 0, 1, 1), o[0, 0]
49
+
50
+ o[0, 0] = color(0, 0, 1, 0)
51
+ assert_equal color(0, 0, 1, 0), o[0, 0]
39
52
  end
40
53
 
41
54
  def test_to_a()
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rays
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.39
4
+ version: 0.1.40
5
5
  platform: ruby
6
6
  authors:
7
7
  - xordog
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-29 00:00:00.000000000 Z
11
+ date: 2023-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xot