processing 0.5.27 → 0.5.28

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: 39a9026716f02cf561cb4123126620d2fe3f0b5cc14c8feaecf2817312bfaa7c
4
- data.tar.gz: 5a4eb5ac394c6451f69ca9334273c4bcaf2cdee4a80a481a6e4313139c63241b
3
+ metadata.gz: 33803d0586a118766e9bde53ba8b67f3e6d71aa8f86440e0d2e6c9c9ce5a71d4
4
+ data.tar.gz: 5eabe17a44f13fe7a4f89eb06776305f317ad28c1768364a8506483c4342c4ed
5
5
  SHA512:
6
- metadata.gz: b93cd12cd8d8fc50f43b7d2f7a18062433916526aa2d9a73563bc1a957663d85f894d7c13307ac8a76a16f858a470d0cf232c7385a2a2f449d77ff7868dea239
7
- data.tar.gz: 638accedff577b47dcb9e1414452cc0f06dd9865fb9e3daa95f2d81887f70c6fa8f45e9263f12c2360feeba2e1c846ce557c951e370e1477e38de199c0e84679
6
+ metadata.gz: 861948e620a781113a596c62ff01701bdc0e0f8952d2b6292724cee3946da2905869040df7854966174dc62ea1e1dac7fc49f555a8eae8cf5be6b95beff3eba6
7
+ data.tar.gz: d4600791e2dc54ea9ceac8a444e34e654b334e73654fe01b3ad170799b0f7fbd16c00667517e47edc832503bdceb675274def8298d2e8048411292b9e279a895
data/ChangeLog.md CHANGED
@@ -1,6 +1,13 @@
1
1
  # processing ChangeLog
2
2
 
3
3
 
4
+ ## [v0.5.28] - 2023-10-25
5
+
6
+ - Add GraphicsContext#clear
7
+ - Add Graphics#save
8
+ - save() returns nil
9
+
10
+
4
11
  ## [v0.5.27] - 2023-07-30
5
12
 
6
13
  - Update dependencies
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.27
1
+ 0.5.28
@@ -455,7 +455,7 @@ module Processing
455
455
  #
456
456
  # @return [nil] nil
457
457
  #
458
- def windowOrientation (*orientations)
458
+ def windowOrientation(*orientations)
459
459
  @window__.orientations = orientations.flatten.uniq
460
460
  end
461
461
 
@@ -38,6 +38,17 @@ module Processing
38
38
  endDraw__
39
39
  end
40
40
 
41
+ # Saves image to file.
42
+ #
43
+ # @param filename [String] file name to save image
44
+ #
45
+ # @return [nil] nil
46
+ #
47
+ def save(filename)
48
+ @image__.save filename
49
+ nil
50
+ end
51
+
41
52
  end# Graphics
42
53
 
43
54
 
@@ -802,6 +802,12 @@ module Processing
802
802
  nil
803
803
  end
804
804
 
805
+ def clear()
806
+ assertDrawing__
807
+ @painter__.background 0, 0
808
+ nil
809
+ end
810
+
805
811
  # Draws a point.
806
812
  #
807
813
  # @param x [Numeric] horizontal position
@@ -1140,8 +1146,11 @@ module Processing
1140
1146
  #
1141
1147
  # @param filename [String] file name to save image
1142
1148
  #
1149
+ # @return [nil] nil
1150
+ #
1143
1151
  def save(filename)
1144
1152
  @window__.canvas_image.save filename
1153
+ nil
1145
1154
  end
1146
1155
 
1147
1156
  # Applies translation matrix to current transformation matrix.
@@ -142,8 +142,11 @@ module Processing
142
142
  #
143
143
  # @param filename [String] file name to save image
144
144
  #
145
+ # @return [nil] nil
146
+ #
145
147
  def save(filename)
146
148
  @image.save filename
149
+ nil
147
150
  end
148
151
 
149
152
  # @private
data/processing.gemspec CHANGED
@@ -26,9 +26,9 @@ Gem::Specification.new do |s|
26
26
  s.required_ruby_version = '>= 3.0.0'
27
27
 
28
28
  s.add_runtime_dependency 'xot', '~> 0.1.39'
29
- s.add_runtime_dependency 'rucy', '~> 0.1.39'
30
- s.add_runtime_dependency 'rays', '~> 0.1.43'
31
- s.add_runtime_dependency 'reflexion', '~> 0.1.51'
29
+ s.add_runtime_dependency 'rucy', '~> 0.1.40'
30
+ s.add_runtime_dependency 'rays', '~> 0.1.44'
31
+ s.add_runtime_dependency 'reflexion', '~> 0.1.52'
32
32
 
33
33
  s.add_development_dependency 'rake'
34
34
  s.add_development_dependency 'test-unit'
data/test/helper.rb CHANGED
@@ -5,15 +5,28 @@
5
5
  require 'xot/test'
6
6
  require 'processing/all'
7
7
 
8
+ require 'tempfile'
8
9
  require 'test/unit'
9
10
 
10
11
  include Xot::Test
11
12
 
12
13
 
13
- def assert_equal_vector(v1, v2, delta = 0.000001)
14
- assert_in_delta v1.x, v2.x, delta
15
- assert_in_delta v1.y, v2.y, delta
16
- assert_in_delta v1.z, v2.z, delta
14
+ def temppath(ext: nil, &block)
15
+ f = Tempfile.new
16
+ path = f.path
17
+ path += ".#{ext}" if ext
18
+ f.close!
19
+ block.call path
20
+ File.delete path
21
+ end
22
+
23
+ def get_pixels(image)
24
+ %i[@image @image__]
25
+ .map {image.instance_variable_get _1}
26
+ .compact
27
+ .first
28
+ .bitmap
29
+ .to_a
17
30
  end
18
31
 
19
32
  def graphics(width = 10, height = 10, &block)
@@ -21,3 +34,9 @@ def graphics(width = 10, height = 10, &block)
21
34
  g.beginDraw {block.call g, g.getInternal__} if block
22
35
  end
23
36
  end
37
+
38
+ def assert_equal_vector(v1, v2, delta = 0.000001)
39
+ assert_in_delta v1.x, v2.x, delta
40
+ assert_in_delta v1.y, v2.y, delta
41
+ assert_in_delta v1.z, v2.z, delta
42
+ end
@@ -15,6 +15,21 @@ class TestGraphics < Test::Unit::TestCase
15
15
  assert_raise {g.beginDraw}
16
16
  end
17
17
 
18
+ def test_save()
19
+ g = graphics 100, 100
20
+ g.beginDraw do
21
+ g.background 200
22
+ g.fill 255
23
+ g.stroke 0
24
+ g.ellipseMode :corner
25
+ g.ellipse 0, 0, g.width, g.height
26
+ end
27
+ temppath(ext: 'png') do |path|
28
+ assert_nothing_raised {g.save path}
29
+ assert_equal get_pixels(g), get_pixels(g.loadImage path)
30
+ end
31
+ end
32
+
18
33
  def test_inspect()
19
34
  assert_match %r|#<Processing::Graphics:0x\w{16}>|, graphics.inspect
20
35
  end
@@ -10,6 +10,23 @@ class TestGraphicsContext < Test::Unit::TestCase
10
10
  G.new w, h
11
11
  end
12
12
 
13
+ def test_color()
14
+ g = graphics
15
+
16
+ g.colorMode G::RGB, 255
17
+ c = g.color 10, 20, 30, 40
18
+ assert_equal 0x280a141e, c
19
+ assert_equal [10, 20, 30, 40], [g.red(c), g.green(c), g.blue(c), g.alpha(c)]
20
+
21
+ g.colorMode G::RGB, 1.0
22
+ c = g.color 0.1, 0.2, 0.3, 0.4
23
+ assert_equal 0x6619334c, c
24
+ assert_in_delta 0.1, g.red(c), 1 / 256.0
25
+ assert_in_delta 0.2, g.green(c), 1 / 256.0
26
+ assert_in_delta 0.3, g.blue(c), 1 / 256.0
27
+ assert_in_delta 0.4, g.alpha(c), 1 / 256.0
28
+ end
29
+
13
30
  def test_colorMode()
14
31
  g = graphics
15
32
  assert_equal G::RGB, g.colorMode
@@ -40,21 +57,17 @@ class TestGraphicsContext < Test::Unit::TestCase
40
57
  assert_raise {g.blendMode LEFT}
41
58
  end
42
59
 
43
- def test_color()
60
+ def test_clear()
61
+ colors = -> g {get_pixels(g).map(&:to_a).flatten.uniq}
62
+
44
63
  g = graphics
64
+ assert_equal [0], colors[g]
45
65
 
46
- g.colorMode G::RGB, 255
47
- c = g.color 10, 20, 30, 40
48
- assert_equal 0x280a141e, c
49
- assert_equal [10, 20, 30, 40], [g.red(c), g.green(c), g.blue(c), g.alpha(c)]
66
+ g.beginDraw {g.ellipse 0, 0, g.width, g.height}
67
+ assert_not_equal [0], colors[g]
50
68
 
51
- g.colorMode G::RGB, 1.0
52
- c = g.color 0.1, 0.2, 0.3, 0.4
53
- assert_equal 0x6619334c, c
54
- assert_in_delta 0.1, g.red(c), 1 / 256.0
55
- assert_in_delta 0.2, g.green(c), 1 / 256.0
56
- assert_in_delta 0.3, g.blue(c), 1 / 256.0
57
- assert_in_delta 0.4, g.alpha(c), 1 / 256.0
69
+ g.beginDraw {g.clear}
70
+ assert_equal [0], colors[g]
58
71
  end
59
72
 
60
73
  def test_lerp()
data/test/test_image.rb CHANGED
@@ -7,7 +7,7 @@ class TestImage < Test::Unit::TestCase
7
7
 
8
8
  def image(w = 10, h = 10, &block)
9
9
  img = Rays::Image.new w, h
10
- img.paint &block if block
10
+ img.paint(&block) if block
11
11
  P::Image.new img
12
12
  end
13
13
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: processing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.27
4
+ version: 0.5.28
5
5
  platform: ruby
6
6
  authors:
7
7
  - xordog
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-30 00:00:00.000000000 Z
11
+ date: 2023-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xot
@@ -30,42 +30,42 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.1.39
33
+ version: 0.1.40
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.39
40
+ version: 0.1.40
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rays
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.1.43
47
+ version: 0.1.44
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.1.43
54
+ version: 0.1.44
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: reflexion
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.1.51
61
+ version: 0.1.52
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.1.51
68
+ version: 0.1.52
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement