rays 0.1.38 → 0.1.40

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4d8008c8c0fe9414db2333e20971b633342c24bbf52d6108a4199cd9c92c5d00
4
- data.tar.gz: 243f04b1d915583c8c0f8d2826bf1c8a38779ffd0ceaa10a714bb3e201af850f
3
+ metadata.gz: f28cc1bd39b3a7b5a6e801693d0642fbd3e3a4af7871a800c8d7378f5ef9427d
4
+ data.tar.gz: ad0decfd29260689a65b38c12ca6fc4897730a79660865ab9fcf15d0458305ef
5
5
  SHA512:
6
- metadata.gz: 953fa337b45367938f609476c4d5ea68c4aeb3fc4bd67c8041f5c9518ac58a065188992f1c0c374652d4d39a1df84fb800f648e80a6d5fabfbb994e0c1ad8de6
7
- data.tar.gz: 8d36ccf2bf66bf4d1014d73935eb792972c3a479e12ccb5b65d027a34fccddbf688cb4c5e7d5828ebaf69698f0d0d0f2eeb553e0028ec33eb9873af6ba565b93
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
@@ -106,6 +106,13 @@ VALUE end_paint(VALUE self)
106
106
  return self;
107
107
  }
108
108
 
109
+ static
110
+ VALUE is_painting(VALUE self)
111
+ {
112
+ CHECK;
113
+ return value(THIS->painting());
114
+ }
115
+
109
116
  static
110
117
  VALUE clear(VALUE self)
111
118
  {
@@ -615,6 +622,7 @@ Init_rays_painter ()
615
622
 
616
623
  rb_define_private_method(cPainter, "begin_paint", RUBY_METHOD_FUNC(begin_paint), 0);
617
624
  rb_define_private_method(cPainter, "end_paint", RUBY_METHOD_FUNC(end_paint), 0);
625
+ cPainter.define_method( "painting?", is_painting);
618
626
  rb_define_method(cPainter, "clear", RUBY_METHOD_FUNC(clear), 0);
619
627
  rb_define_method(cPainter, "polygon", RUBY_METHOD_FUNC(polygon), 1);
620
628
  rb_define_private_method(cPainter, "draw_line", RUBY_METHOD_FUNC(line), 2);
data/ChangeLog.md CHANGED
@@ -1,6 +1,16 @@
1
1
  # rays ChangeLog
2
2
 
3
3
 
4
+ ## [v0.1.40] - 2023-06-07
5
+
6
+ - Redesign parameters for Bitmap#[]=
7
+
8
+
9
+ ## [v0.1.39] - 2023-05-29
10
+
11
+ - Add Painter#painting?
12
+
13
+
4
14
  ## [v0.1.38] - 2023-05-27
5
15
 
6
16
  - required_ruby_version >= 3.0.0
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.38
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/ext/rays/painter.cpp CHANGED
@@ -112,6 +112,14 @@ RUCY_DEF0(end_paint)
112
112
  }
113
113
  RUCY_END
114
114
 
115
+ static
116
+ RUCY_DEF0(is_painting)
117
+ {
118
+ CHECK;
119
+ return value(THIS->painting());
120
+ }
121
+ RUCY_END
122
+
115
123
  static
116
124
  RUCY_DEF0(clear)
117
125
  {
@@ -667,8 +675,9 @@ Init_rays_painter ()
667
675
  cPainter.define_method("bounds", bounds);
668
676
  cPainter.define_method("pixel_density", pixel_density);
669
677
 
670
- cPainter.define_private_method("begin_paint", begin_paint);
671
- cPainter.define_private_method( "end_paint", end_paint);
678
+ cPainter.define_private_method("begin_paint", begin_paint);
679
+ cPainter.define_private_method( "end_paint", end_paint);
680
+ cPainter.define_method( "painting?", is_painting);
672
681
  cPainter.define_method("clear", clear);
673
682
  cPainter.define_method("polygon", polygon);
674
683
  cPainter.define_private_method("draw_line", line);
@@ -61,6 +61,8 @@ namespace Rays
61
61
 
62
62
  void end ();
63
63
 
64
+ bool painting () const;
65
+
64
66
  void clear ();
65
67
 
66
68
  void polygon (const Polygon& polygon);
data/rays.gemspec CHANGED
@@ -1,10 +1,7 @@
1
1
  # -*- mode: ruby -*-
2
2
 
3
3
 
4
- File.expand_path('lib', __dir__)
5
- .tap {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
6
-
7
- require 'rays/extension'
4
+ require_relative 'lib/rays/extension'
8
5
 
9
6
 
10
7
  Gem::Specification.new do |s|
@@ -28,8 +25,8 @@ Gem::Specification.new do |s|
28
25
  s.platform = Gem::Platform::RUBY
29
26
  s.required_ruby_version = '>= 3.0.0'
30
27
 
31
- s.add_runtime_dependency 'xot', '~> 0.1.37'
32
- s.add_runtime_dependency 'rucy', '~> 0.1.37'
28
+ s.add_runtime_dependency 'xot', '~> 0.1.38'
29
+ s.add_runtime_dependency 'rucy', '~> 0.1.38'
33
30
 
34
31
  s.add_development_dependency 'rake'
35
32
  s.add_development_dependency 'test-unit'
data/src/painter.cpp CHANGED
@@ -755,6 +755,12 @@ namespace Rays
755
755
  }
756
756
  }
757
757
 
758
+ bool
759
+ Painter::painting () const
760
+ {
761
+ return self->painting;
762
+ }
763
+
758
764
  void
759
765
  Painter::clear ()
760
766
  {
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()
data/test/test_painter.rb CHANGED
@@ -41,6 +41,15 @@ class TestPainter < Test::Unit::TestCase
41
41
  Rays::Color.set_palette_color :rgb001, color(0, 0, 1)
42
42
  end
43
43
 
44
+ def test_painting?()
45
+ pa = image.painter
46
+ assert_false pa.painting?
47
+ pa.send :begin_paint
48
+ assert_true pa.painting?
49
+ pa.send :end_paint
50
+ assert_false pa.painting?
51
+ end
52
+
44
53
  def test_background_accessor()
45
54
  pa = painter
46
55
  pa.background = 1
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.38
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-27 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
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.1.37
19
+ version: 0.1.38
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.1.37
26
+ version: 0.1.38
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rucy
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.1.37
33
+ version: 0.1.38
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.1.37
40
+ version: 0.1.38
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement