processing 1.1.5 → 1.1.6

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: c8f47bfbe64ef981036e63d3764e68d0136d9279f155eda380484c5e82b09c0b
4
- data.tar.gz: 8d73f1f9a94c04ebe2050007ab2a07c9ca5febae8611373af831b9b1ab30973b
3
+ metadata.gz: 70c89abc66d556510a19230893f507b29cca377f8c7050d174b36824138e82b2
4
+ data.tar.gz: 56d4368c848ff70af9c0466b2d931c38cac7370938615f3179c0f4931fe935ff
5
5
  SHA512:
6
- metadata.gz: f38a551e8d521bd34f3c6fd41c554f3fc95cf33fee013e40b4142580cf679078d248d2fe00c5ee84d19a2f24b8108a9bfe6541678e103a59cd5bb845d8fd8006
7
- data.tar.gz: 9b7fe7c09c8daee0e9d7e0fb44a1e9fe66a95145f20003614492480c2325a650ec860f263062e9b9f4b7defa92a89cd98a59eca446a034f912e48a5d2a95e960
6
+ metadata.gz: fdfd84c468aaf6df0fec4f592b5f8e8f23a2dcff860884385de49a344851d877b4e5ef9c72f5e7e3b7a602f54a6366ee8e8a01574d987d2ef97e27e7c517545f
7
+ data.tar.gz: 3e0408708222f8cfed7a605c64c1cf2dda2f9f140110328325dcb2c67f9edc69108ed58ecc49c29a3e83ad9dca424d156a7dee6afef905d0aca6f52330352543
data/ChangeLog.md CHANGED
@@ -1,6 +1,17 @@
1
1
  # processing ChangeLog
2
2
 
3
3
 
4
+ ## [v1.1.6] - 2025-03-07
5
+
6
+ - Add keyIsRepeat
7
+ - Add Vector#-@
8
+
9
+ - Painter#background: Clearing background with transparency uses blend_mode with :replace to replace alpha value
10
+ - Fix p5.rb version
11
+
12
+ - Fix smaller-than-expected height of screenshots rendered in headless chrome
13
+
14
+
4
15
  ## [v1.1.5] - 2025-01-30
5
16
 
6
17
  - Do not define snake_case methods by default
data/Gemfile.lock CHANGED
@@ -12,7 +12,7 @@ GEM
12
12
  power_assert (2.0.3)
13
13
  public_suffix (5.0.3)
14
14
  rake (13.1.0)
15
- rexml (3.4.0)
15
+ rexml (3.4.1)
16
16
  test-unit (3.6.1)
17
17
  power_assert
18
18
  webrick (1.7.0)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.5
1
+ 1.1.6
@@ -26,16 +26,24 @@ module Processing
26
26
  LANDSCAPE = :landscape
27
27
 
28
28
  # @private
29
- @@context__ = nil
29
+ @@rootContext__ = nil
30
+
31
+ # @private
32
+ @@context__ = nil
30
33
 
31
34
  # @private
32
35
  def self.context__()
33
- @@context__
36
+ @@context__ || @@rootContext__
37
+ end
38
+
39
+ # @private
40
+ def self.setContext__(context)
41
+ @@context__ = context
34
42
  end
35
43
 
36
44
  # @private
37
45
  def initialize(window)
38
- @@context__ = self
46
+ @@rootContext__ = self
39
47
 
40
48
  tmpdir__.tap {|dir| FileUtils.rm_r dir.to_s if dir.directory?}
41
49
 
@@ -50,6 +58,7 @@ module Processing
50
58
  @frameCount__ = 0
51
59
  @key__ = nil
52
60
  @keyCode__ = nil
61
+ @keyRepeat__ = false
53
62
  @keysPressed__ = Set.new
54
63
  @pointer__ = nil
55
64
  @pointerPrev__ = nil
@@ -87,12 +96,11 @@ module Processing
87
96
  end
88
97
 
89
98
  updateKeyStates = -> event, pressed {
90
- @key__ = event.chars
91
- @keyCode__ = event.key
92
- if pressed != nil
93
- set = @keysPressed__
94
- pressed ? set.add(@keyCode__) : set.delete(@keyCode__)
95
- end
99
+ set = @keysPressed__
100
+ @key__ = event.chars
101
+ @keyCode__ = event.key
102
+ @keyRepeat__ = pressed && set.include?(@keyCode__)
103
+ pressed ? set.add(@keyCode__) : set.delete(@keyCode__)
96
104
  }
97
105
 
98
106
  mouseButtonMap = {
@@ -633,7 +641,7 @@ module Processing
633
641
  @window__.height
634
642
  end
635
643
 
636
- # Returns weather the window is active or not.
644
+ # Returns whether the window is active or not.
637
645
  #
638
646
  # @return [Boolean] active or not
639
647
  #
@@ -708,7 +716,7 @@ module Processing
708
716
  not @keysPressed__.empty?
709
717
  end
710
718
 
711
- # Returns weather or not the key is currently pressed.
719
+ # Returns whether or not the key is currently pressed.
712
720
  #
713
721
  # @param keyCode [Numeric] code for the key
714
722
  #
@@ -720,6 +728,14 @@ module Processing
720
728
  @keysPressed__.include? keyCode
721
729
  end
722
730
 
731
+ # Returns whether the current key is repeated or not.
732
+ #
733
+ # @return [Boolean] is the key repeated or not
734
+ #
735
+ def keyIsRepeated()
736
+ @keyRepeat__
737
+ end
738
+
723
739
  # Returns mouse x position
724
740
  #
725
741
  # @return [Numeric] horizontal position of mouse
@@ -461,7 +461,7 @@ module Processing
461
461
  FONT_SIZE_MAX__ = 256
462
462
 
463
463
  # @private
464
- def init__(image, painter)
464
+ def init__(image, painter = image.painter)
465
465
  @drawing__ = false
466
466
  @renderMode__ = nil
467
467
  @p5jsMode__ = false
@@ -525,15 +525,20 @@ module Processing
525
525
  end
526
526
 
527
527
  # @private
528
- def updateCanvas__(image, painter)
528
+ def updateCanvas__(image, painter = image.painter)
529
+ drawing = @drawing__
530
+ endDraw__ if drawing
531
+
529
532
  @image__, @painter__ = image, painter
530
533
  @painter__.miter_limit = 10
531
534
  @painter__.stroke_outset = 0.5
535
+
536
+ beginDraw__ if drawing
532
537
  end
533
538
 
534
539
  # @private
535
540
  def beginDraw__()
536
- raise "call beginDraw() before drawing" if @drawing__
541
+ raise "beginDraw() is already called" if @drawing__
537
542
  @matrixStack__.clear
538
543
  @styleStack__.clear
539
544
  @drawing__ = true
@@ -561,7 +566,7 @@ module Processing
561
566
 
562
567
  # @private
563
568
  def endDraw__()
564
- raise unless @drawing__
569
+ assertDrawing__
565
570
  @drawing__ = false
566
571
  end
567
572
 
@@ -1448,7 +1453,7 @@ module Processing
1448
1453
  if rgba[3] == 1
1449
1454
  @painter__.background(*rgba)
1450
1455
  else
1451
- @painter__.push fill: rgba, stroke: :none do |_|
1456
+ @painter__.push fill: rgba, stroke: :none, blend_mode: :replace do |_|
1452
1457
  @painter__.rect 0, 0, width, height
1453
1458
  end
1454
1459
  end
@@ -320,6 +320,14 @@ module Processing
320
320
  dup.div num
321
321
  end
322
322
 
323
+ # Negate a vector.
324
+ #
325
+ # @return [Vector] negated vector
326
+ #
327
+ def -@()
328
+ dup.mult -1
329
+ end
330
+
323
331
  # Adds 2 vectors.
324
332
  #
325
333
  # @overload add(v1, v2)
data/lib/processing.rb CHANGED
@@ -36,9 +36,9 @@ end
36
36
  begin
37
37
  w, c = Processing::WINDOW__, Processing::CONTEXT__
38
38
 
39
- c.class.constants.reject {_1 =~ /__$/}.each do |const|
40
- self.class.const_set const, c.class.const_get(const)
41
- end
39
+ c.class.constants
40
+ .reject {_1 =~ /__$/}
41
+ .each {self.class.const_set _1, c.class.const_get(_1)}
42
42
 
43
43
  w.__send__ :begin_draw
44
44
  at_exit do
data/processing.gemspec CHANGED
@@ -26,10 +26,10 @@ Gem::Specification.new do |s|
26
26
  s.required_ruby_version = '>= 3.0.0'
27
27
 
28
28
  s.add_dependency 'rexml'
29
- s.add_dependency 'xot', '~> 0.3.3', '>= 0.3.3'
30
- s.add_dependency 'rucy', '~> 0.3.3', '>= 0.3.3'
31
- s.add_dependency 'rays', '~> 0.3.3', '>= 0.3.3'
32
- s.add_dependency 'reflexion', '~> 0.3.3', '>= 0.3.3'
29
+ s.add_dependency 'xot', '~> 0.3.4', '>= 0.3.4'
30
+ s.add_dependency 'rucy', '~> 0.3.4', '>= 0.3.4'
31
+ s.add_dependency 'rays', '~> 0.3.4', '>= 0.3.4'
32
+ s.add_dependency 'reflexion', '~> 0.3.4', '>= 0.3.4'
33
33
 
34
34
  s.files = `git ls-files`.split $/
35
35
  s.test_files = s.files.grep %r{^(test|spec|features)/}
data/test/browser.rb CHANGED
@@ -3,14 +3,14 @@ require 'ferrum'
3
3
 
4
4
  RUBY_URL = 'https://cdn.jsdelivr.net/npm/ruby-3_2-wasm-wasi@next/dist/browser.script.iife.js'
5
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'
6
+ P5RB_URL = 'https://raw.githubusercontent.com/ongaeshi/p5rb/421ce24c4a29c5787d143f8132eb610b73f60b92/docs/lib/p5.rb'
7
7
 
8
8
  P5RB_SRC = URI.open(P5RB_URL) {|f| f.read}
9
9
 
10
10
  def browser(width, height, headless: true)
11
11
  hash = ($browsers ||= {})
12
12
  key = [width, height, headless]
13
- hash[key] ||= Ferrum::Browser.new headless: headless, window_size: [width, height]
13
+ hash[key] ||= Ferrum::Browser.new headless: headless, window_size: [width, height + 200]
14
14
  end
15
15
 
16
16
  def get_svg_html(width, height, svg_xml)
@@ -95,8 +95,9 @@ def draw_on_browser(width, height, path, html, headless: true)
95
95
  sleep_until do
96
96
  b.evaluate 'document.querySelector("#completed") != null'
97
97
  end
98
- b.screenshot path: path
98
+ b.screenshot path: path, area: {x: 0, y: 0, width: width, height: height}
99
99
  end
100
+ sleep 1
100
101
  b.device_pixel_ratio
101
102
  end
102
103
 
data/test/test_vector.rb CHANGED
@@ -191,6 +191,11 @@ class TestVector < Test::Unit::TestCase
191
191
  assert_equal_vector vec(2, 4, 6), v
192
192
  end
193
193
 
194
+ def test_op_negate()
195
+ assert_equal_vector vec(-1, -2, -3), -vec( 1, 2, 3)
196
+ assert_equal_vector vec( 1, 2, 3), -vec(-1, -2, -3)
197
+ end
198
+
194
199
  def test_fun_add()
195
200
  v1 = vec 1, 2, 3
196
201
  v2 = vec 4, 5, 6
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: 1.1.5
4
+ version: 1.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - xordog
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-01-29 00:00:00.000000000 Z
11
+ date: 2025-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rexml
@@ -30,80 +30,80 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.3.3
33
+ version: 0.3.4
34
34
  - - ">="
35
35
  - !ruby/object:Gem::Version
36
- version: 0.3.3
36
+ version: 0.3.4
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - "~>"
42
42
  - !ruby/object:Gem::Version
43
- version: 0.3.3
43
+ version: 0.3.4
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: 0.3.3
46
+ version: 0.3.4
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rucy
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: 0.3.3
53
+ version: 0.3.4
54
54
  - - ">="
55
55
  - !ruby/object:Gem::Version
56
- version: 0.3.3
56
+ version: 0.3.4
57
57
  type: :runtime
58
58
  prerelease: false
59
59
  version_requirements: !ruby/object:Gem::Requirement
60
60
  requirements:
61
61
  - - "~>"
62
62
  - !ruby/object:Gem::Version
63
- version: 0.3.3
63
+ version: 0.3.4
64
64
  - - ">="
65
65
  - !ruby/object:Gem::Version
66
- version: 0.3.3
66
+ version: 0.3.4
67
67
  - !ruby/object:Gem::Dependency
68
68
  name: rays
69
69
  requirement: !ruby/object:Gem::Requirement
70
70
  requirements:
71
71
  - - "~>"
72
72
  - !ruby/object:Gem::Version
73
- version: 0.3.3
73
+ version: 0.3.4
74
74
  - - ">="
75
75
  - !ruby/object:Gem::Version
76
- version: 0.3.3
76
+ version: 0.3.4
77
77
  type: :runtime
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - "~>"
82
82
  - !ruby/object:Gem::Version
83
- version: 0.3.3
83
+ version: 0.3.4
84
84
  - - ">="
85
85
  - !ruby/object:Gem::Version
86
- version: 0.3.3
86
+ version: 0.3.4
87
87
  - !ruby/object:Gem::Dependency
88
88
  name: reflexion
89
89
  requirement: !ruby/object:Gem::Requirement
90
90
  requirements:
91
91
  - - "~>"
92
92
  - !ruby/object:Gem::Version
93
- version: 0.3.3
93
+ version: 0.3.4
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: 0.3.3
96
+ version: 0.3.4
97
97
  type: :runtime
98
98
  prerelease: false
99
99
  version_requirements: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.3.3
103
+ version: 0.3.4
104
104
  - - ">="
105
105
  - !ruby/object:Gem::Version
106
- version: 0.3.3
106
+ version: 0.3.4
107
107
  description: Creative Coding Framework has API compatible to Processing or p5.js.
108
108
  email: xordog@gmail.com
109
109
  executables: []