processing 0.5.29 → 0.5.30

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: 43c304fcb0736f53301de6d1dcdea69d62c0f2cce027c6f5557102c8e92372b7
4
- data.tar.gz: a75abc1fec6ddbb3ee785ae444304dcd0a36ef1f67d5957779eb1926cc096fdd
3
+ metadata.gz: ca6d65b8e9bd003c16fabbf550a70f20f0adf70ea623d1abe01ec1b967b88fa0
4
+ data.tar.gz: e4f689b826f7854a4da0bf9b52c6368c27ef02179ae98e15e0995b452eafc096
5
5
  SHA512:
6
- metadata.gz: 35a3a70db26dd8ff031675de548fb5593af891ca2699c6bf57a9fb2beccddada68e8ff2bd59ec8556edd625654d626fbe1c1aa82177253bcce884c3cec878ca7
7
- data.tar.gz: 74ee44f9aad045d7c7646afbe51f0952a40929aac202a92080e469f1693d21f56e9381aa5c57a81d5a6ae5aa7607313297ee48ad550695eafd9633275494a4c7
6
+ metadata.gz: f74584e4c313f4c95ce326ccadd8fa20e59dba80a2b4598f083c7dd5f2041950b8f3d69f0ca34c7fc3021d5b704f26170879587d19d375bb499e244577d529e3
7
+ data.tar.gz: a38786a6783135f58ffd9a81edf929f5ba8d020dbd12fc06faa85cc6d36dc95c682249cccea600a823faee81e03b86eb3ffff2ca766704a520f867294cf51ae8
@@ -17,19 +17,19 @@ jobs:
17
17
  - name: checkout
18
18
  uses: actions/checkout@v2
19
19
 
20
+ - name: setup gems
21
+ run: bundle install
22
+
20
23
  - name: setup dependencies
21
24
  run: "ruby -I.github/workflows -rutils -e 'setup_dependencies'"
22
25
 
23
- - name: install gems
24
- run: gem install yard
25
-
26
26
  - name: test
27
- run: rake quiet test
27
+ run: bundle exec rake quiet test
28
28
 
29
29
  - name: create gem
30
30
  id: gem
31
31
  run: |
32
- rake gem
32
+ bundle exec rake gem
33
33
  echo path=$(ruby -e 'print Dir.glob("*.gem").first') >> $GITHUB_OUTPUT
34
34
 
35
35
  - name: create github release
@@ -59,4 +59,4 @@ jobs:
59
59
  touch $HOME/.gem/credentials
60
60
  chmod 0600 $HOME/.gem/credentials
61
61
  printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
62
- rake upload
62
+ bundle exec rake upload
@@ -0,0 +1,34 @@
1
+ name: Test Draw
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ pull_request:
7
+ branches: [master]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: macos-latest
12
+
13
+ steps:
14
+ - name: ruby 3.2
15
+ uses: ruby/setup-ruby@v1
16
+ with:
17
+ ruby-version: 3.2
18
+
19
+ - name: checkout
20
+ uses: actions/checkout@v2
21
+
22
+ - name: setup gems
23
+ run: bundle install
24
+
25
+ - name: setup dependencies
26
+ run: "ruby -I.github/workflows -rutils -e 'setup_dependencies'"
27
+
28
+ - name: setup chrome
29
+ uses: browser-actions/setup-chrome@latest
30
+ with:
31
+ chrome-version: stable
32
+
33
+ - name: test
34
+ run: rake test:draw
@@ -19,8 +19,11 @@ jobs:
19
19
  - name: checkout
20
20
  uses: actions/checkout@v2
21
21
 
22
+ - name: setup gems
23
+ run: bundle install
24
+
22
25
  - name: setup dependencies
23
26
  run: "ruby -I.github/workflows -rutils -e 'setup_dependencies'"
24
27
 
25
28
  - name: test
26
- run: rake test
29
+ run: bundle exec rake test
data/ChangeLog.md CHANGED
@@ -1,6 +1,13 @@
1
1
  # processing ChangeLog
2
2
 
3
3
 
4
+ ## [v0.5.30] - 2023-11-09
5
+
6
+ - Test drawing methods with p5.rb
7
+ - Add .github/workflows/test-draw.yml
8
+ - Use Gemfile to install gems for development instead of add_development_dependency in gemspec
9
+
10
+
4
11
  ## [v0.5.29] - 2023-10-29
5
12
 
6
13
  - Update dependencies
data/Gemfile CHANGED
@@ -1,3 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gemspec
3
+ gem 'rake'
4
+ gem 'test-unit'
5
+ gem 'yard'
6
+ gem 'ferrum'
data/Gemfile.lock ADDED
@@ -0,0 +1,35 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ addressable (2.8.5)
5
+ public_suffix (>= 2.0.2, < 6.0)
6
+ concurrent-ruby (1.2.2)
7
+ ferrum (0.14)
8
+ addressable (~> 2.5)
9
+ concurrent-ruby (~> 1.1)
10
+ webrick (~> 1.7)
11
+ websocket-driver (>= 0.6, < 0.8)
12
+ power_assert (2.0.3)
13
+ public_suffix (5.0.3)
14
+ rake (13.1.0)
15
+ test-unit (3.6.1)
16
+ power_assert
17
+ webrick (1.7.0)
18
+ websocket-driver (0.7.6)
19
+ websocket-extensions (>= 0.1.0)
20
+ websocket-extensions (0.1.5)
21
+ yard (0.9.34)
22
+
23
+ PLATFORMS
24
+ arm64-darwin-20
25
+ arm64-darwin-21
26
+ x86_64-darwin-20
27
+
28
+ DEPENDENCIES
29
+ ferrum
30
+ rake
31
+ test-unit
32
+ yard
33
+
34
+ BUNDLED WITH
35
+ 2.3.3
data/Rakefile CHANGED
@@ -14,11 +14,26 @@ require 'reflex/extension'
14
14
  require 'processing/extension'
15
15
 
16
16
 
17
- EXTENSIONS = [Xot, Rucy, Rays, Reflex, Processing]
17
+ EXTENSIONS = [Xot, Rucy, Rays, Reflex, Processing]
18
+ DRAW_TESTS = Dir.glob('test/draw/test_*.rb')
19
+ TESTS_EXCLUDE = DRAW_TESTS
18
20
 
19
21
  ENV['RDOC'] = 'yardoc --no-private'
20
22
 
21
23
  default_tasks
24
+ use_bundler
22
25
  test_ruby_extension
23
26
  generate_documents
24
27
  build_ruby_gem
28
+
29
+ task :clean => 'test:clean'
30
+
31
+ namespace :test do
32
+ task :clean do
33
+ sh %( rm -rf test/draw/p5rb )
34
+ end
35
+
36
+ task :draw do
37
+ sh %( ruby #{DRAW_TESTS.join ' '} )
38
+ end
39
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.29
1
+ 0.5.30
data/processing.gemspec CHANGED
@@ -25,14 +25,10 @@ Gem::Specification.new do |s|
25
25
  s.platform = Gem::Platform::RUBY
26
26
  s.required_ruby_version = '>= 3.0.0'
27
27
 
28
- s.add_runtime_dependency 'xot', '~> 0.1.39'
29
- s.add_runtime_dependency 'rucy', '~> 0.1.40'
30
- s.add_runtime_dependency 'rays', '~> 0.1.45'
31
- s.add_runtime_dependency 'reflexion', '~> 0.1.53'
32
-
33
- s.add_development_dependency 'rake'
34
- s.add_development_dependency 'test-unit'
35
- s.add_development_dependency 'yard'
28
+ s.add_runtime_dependency 'xot', '~> 0.1.40'
29
+ s.add_runtime_dependency 'rucy', '~> 0.1.41'
30
+ s.add_runtime_dependency 'rays', '~> 0.1.46'
31
+ s.add_runtime_dependency 'reflexion', '~> 0.1.54'
36
32
 
37
33
  s.files = `git ls-files`.split $/
38
34
  s.test_files = s.files.grep %r{^(test|spec|features)/}
@@ -0,0 +1,31 @@
1
+ require 'digest/md5'
2
+ require 'fileutils'
3
+
4
+ require_relative '../helper'
5
+ require_relative 'p5'
6
+
7
+
8
+ def md5(s)
9
+ Digest::MD5.hexdigest s
10
+ end
11
+
12
+ def mkdir(dir: nil, filename: nil)
13
+ path = dir || File.dirname(filename)
14
+ FileUtils.mkdir_p path unless File.exist? path
15
+ end
16
+
17
+ def assert_draw(width = 100, height = 100, draw_src, threshold: 1.0)
18
+ path = File.join __dir__, "p5rb", "#{md5(draw_src)}.png"
19
+ mkdir filename: path
20
+ density = draw_p5rb width, height, draw_src, path, headless: false
21
+ gfx = graphics(width, height, density).tap do |g|
22
+ g.beginDraw do
23
+ g.background 0
24
+ g.fill 255, 0, 0
25
+ g.noStroke
26
+ g.instance_eval draw_src
27
+ end
28
+ end
29
+ gfx.save path.sub(/\.png$/, '.actual.png')
30
+ assert_equal_pixels gfx.loadImage(path), gfx, threshold: threshold
31
+ end
data/test/draw/p5.rb ADDED
@@ -0,0 +1,63 @@
1
+ require 'open-uri'
2
+ require 'ferrum'
3
+
4
+ RUBY_URL = 'https://cdn.jsdelivr.net/npm/ruby-3_2-wasm-wasi@next/dist/browser.script.iife.js'
5
+ P5JS_URL = 'https://cdn.jsdelivr.net/npm/p5@1.5.0/lib/p5.js'
6
+ P5RB_URL = 'https://raw.githubusercontent.com/ongaeshi/p5rb/master/docs/lib/p5.rb'
7
+
8
+ P5RB_SRC = URI.open(P5RB_URL) {|f| f.read}
9
+
10
+ def browser(width, height, headless: true)
11
+ hash = ($browsers ||= {})
12
+ key = [width, height, headless]
13
+ hash[key] ||= Ferrum::Browser.new headless: headless, window_size: [width, height]
14
+ end
15
+
16
+ def get_p5rb_html(width, height, draw_src)
17
+ <<~END
18
+ <html>
19
+ <head>
20
+ <script src="#{RUBY_URL}"></script>
21
+ <script src="#{P5JS_URL}"></script>
22
+ <script type="text/ruby">#{P5RB_SRC}</script>
23
+ <style type="text/css">
24
+ body {margin: 0;}
25
+ </style>
26
+ <script type="text/javascript">
27
+ function completed() {
28
+ id = 'completed'
29
+ if (document.querySelector("#" + id)) return;
30
+ let e = document.createElement("span");
31
+ e.id = id;
32
+ document.body.appendChild(e);
33
+ }
34
+ </script>
35
+ <script type="text/ruby">
36
+ def setup()
37
+ createCanvas #{width}, #{height}
38
+ end
39
+ def draw()
40
+ background 0
41
+ fill 255, 0, 0
42
+ noStroke
43
+ #{draw_src}
44
+ JS.global.completed
45
+ end
46
+ P5::init
47
+ </script>
48
+ </head>
49
+ <body><main></main></body>
50
+ </html>
51
+ END
52
+ end
53
+
54
+ def draw_p5rb(width, height, draw_src, path, headless: true)
55
+ b = browser width, height, headless: headless
56
+ unless File.exist? path
57
+ b.reset
58
+ b.main_frame.content = get_p5rb_html width, height, draw_src
59
+ sleep 0.1 until b.evaluate 'document.querySelector("#completed") != null'
60
+ b.screenshot path: path
61
+ end
62
+ b.device_pixel_ratio
63
+ end
@@ -0,0 +1,22 @@
1
+ require_relative 'helper'
2
+
3
+
4
+ class TestDraw < Test::Unit::TestCase
5
+
6
+ def test_rect()
7
+ assert_draw 'rect 10, 20, 30, 40'
8
+ assert_draw 'rectMode CORNER; rect 10, 20, 30, 40'
9
+ assert_draw 'rectMode CORNERS; rect 10, 20, 30, 50'
10
+ assert_draw 'rectMode CENTER; rect 40, 50, 30, 40'
11
+ assert_draw 'rectMode RADIUS; rect 40, 50, 30, 40'
12
+ end
13
+
14
+ def test_ellipse()
15
+ assert_draw 'ellipse 40, 50, 30, 40', threshold: 0.98
16
+ assert_draw 'ellipseMode CORNER; ellipse 10, 20, 30, 40', threshold: 0.98
17
+ assert_draw 'ellipseMode CORNERS; ellipse 10, 20, 30, 50', threshold: 0.98
18
+ assert_draw 'ellipseMode CENTER; ellipse 40, 50, 30, 40', threshold: 0.98
19
+ assert_draw 'ellipseMode RADIUS; ellipse 40, 50, 30, 40', threshold: 0.98
20
+ end
21
+
22
+ end# TestDraw
data/test/helper.rb CHANGED
@@ -29,8 +29,8 @@ def get_pixels(image)
29
29
  .to_a
30
30
  end
31
31
 
32
- def graphics(width = 10, height = 10, &block)
33
- Processing::Graphics.new(width, height).tap do |g|
32
+ def graphics(width = 10, height = 10, *args, &block)
33
+ Processing::Graphics.new(width, height, *args).tap do |g|
34
34
  g.beginDraw {block.call g, g.getInternal__} if block
35
35
  end
36
36
  end
@@ -40,3 +40,15 @@ def assert_equal_vector(v1, v2, delta = 0.000001)
40
40
  assert_in_delta v1.y, v2.y, delta
41
41
  assert_in_delta v1.z, v2.z, delta
42
42
  end
43
+
44
+ def assert_equal_pixels(expected, actual, threshold: 1.0)
45
+ exp_pixels = get_pixels expected
46
+ act_pixels = get_pixels actual
47
+ raise "Number of pixels does not match" if act_pixels.size != exp_pixels.size
48
+
49
+ equal_count = exp_pixels.zip(act_pixels).count {|a, b| a == b}
50
+ equal_rate = equal_count.to_f / act_pixels.size.to_f
51
+ assert equal_rate >= threshold, <<~EOS
52
+ The rate of the same pixel #{equal_rate} is below the threshold #{threshold}
53
+ EOS
54
+ end
@@ -26,7 +26,7 @@ class TestGraphics < Test::Unit::TestCase
26
26
  end
27
27
  temppath(ext: 'png') do |path|
28
28
  assert_nothing_raised {g.save path}
29
- assert_equal get_pixels(g), get_pixels(g.loadImage path)
29
+ assert_equal_pixels g, g.loadImage(path)
30
30
  end
31
31
  end
32
32
 
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.29
4
+ version: 0.5.30
5
5
  platform: ruby
6
6
  authors:
7
7
  - xordog
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-28 00:00:00.000000000 Z
11
+ date: 2023-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xot
@@ -16,98 +16,56 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.1.39
19
+ version: 0.1.40
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.39
26
+ version: 0.1.40
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.40
33
+ version: 0.1.41
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.40
40
+ version: 0.1.41
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.45
47
+ version: 0.1.46
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.45
54
+ version: 0.1.46
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.53
61
+ version: 0.1.54
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.53
69
- - !ruby/object:Gem::Dependency
70
- name: rake
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: test-unit
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: yard
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
68
+ version: 0.1.54
111
69
  description: Creative Coding Framework has API compatible to Processing or p5.js.
112
70
  email: xordog@gmail.com
113
71
  executables: []
@@ -116,12 +74,14 @@ extra_rdoc_files: []
116
74
  files:
117
75
  - ".github/workflows/release-gem.yml"
118
76
  - ".github/workflows/tag.yml"
77
+ - ".github/workflows/test-draw.yml"
119
78
  - ".github/workflows/test.yml"
120
79
  - ".github/workflows/utils.rb"
121
80
  - ".gitignore"
122
81
  - ".yardopts"
123
82
  - ChangeLog.md
124
83
  - Gemfile
84
+ - Gemfile.lock
125
85
  - LICENSE
126
86
  - README.md
127
87
  - Rakefile
@@ -150,6 +110,9 @@ files:
150
110
  - lib/processing/vector.rb
151
111
  - lib/processing/window.rb
152
112
  - processing.gemspec
113
+ - test/draw/helper.rb
114
+ - test/draw/p5.rb
115
+ - test/draw/test_draw.rb
153
116
  - test/helper.rb
154
117
  - test/test_capture.rb
155
118
  - test/test_font.rb
@@ -185,6 +148,9 @@ signing_key:
185
148
  specification_version: 4
186
149
  summary: Processing compatible Creative Coding Framework.
187
150
  test_files:
151
+ - test/draw/helper.rb
152
+ - test/draw/p5.rb
153
+ - test/draw/test_draw.rb
188
154
  - test/helper.rb
189
155
  - test/test_capture.rb
190
156
  - test/test_font.rb