processing 1.1.4 → 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 +4 -4
- data/ChangeLog.md +16 -0
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/lib/processing/all.rb +11 -4
- data/lib/processing/context.rb +27 -11
- data/lib/processing/graphics_context.rb +10 -5
- data/lib/processing/vector.rb +8 -0
- data/lib/processing.rb +28 -14
- data/processing.gemspec +4 -4
- data/test/browser.rb +4 -3
- data/test/test_vector.rb +5 -0
- metadata +18 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70c89abc66d556510a19230893f507b29cca377f8c7050d174b36824138e82b2
|
4
|
+
data.tar.gz: 56d4368c848ff70af9c0466b2d931c38cac7370938615f3179c0f4931fe935ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fdfd84c468aaf6df0fec4f592b5f8e8f23a2dcff860884385de49a344851d877b4e5ef9c72f5e7e3b7a602f54a6366ee8e8a01574d987d2ef97e27e7c517545f
|
7
|
+
data.tar.gz: 3e0408708222f8cfed7a605c64c1cf2dda2f9f140110328325dcb2c67f9edc69108ed58ecc49c29a3e83ad9dca424d156a7dee6afef905d0aca6f52330352543
|
data/ChangeLog.md
CHANGED
@@ -1,6 +1,22 @@
|
|
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
|
+
|
15
|
+
## [v1.1.5] - 2025-01-30
|
16
|
+
|
17
|
+
- Do not define snake_case methods by default
|
18
|
+
|
19
|
+
|
4
20
|
## [v1.1.4] - 2025-01-27
|
5
21
|
|
6
22
|
- Event blocks can be defined as methods with 'def'
|
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.6
|
data/lib/processing/all.rb
CHANGED
@@ -29,12 +29,19 @@ module Processing
|
|
29
29
|
|
30
30
|
window = Processing::Window.new(w, h) {start}
|
31
31
|
context = namespace::Context.new window
|
32
|
-
|
32
|
+
|
33
|
+
return window, context
|
34
|
+
end
|
35
|
+
|
36
|
+
# @private
|
37
|
+
def self.funcs__(context)
|
38
|
+
(context.methods - Object.instance_methods)
|
33
39
|
.reject {_1 =~ /__$/} # methods for internal use
|
34
|
-
|
35
|
-
.each.with_object({}) {|event, hash| hash[event] = -> {__send__ event}}
|
40
|
+
end
|
36
41
|
|
37
|
-
|
42
|
+
# @private
|
43
|
+
def self.events__(context)
|
44
|
+
to_snake_case__(EVENT_NAMES__).flatten.uniq.select {context.respond_to? _1}
|
38
45
|
end
|
39
46
|
|
40
47
|
# @private
|
data/lib/processing/context.rb
CHANGED
@@ -26,16 +26,24 @@ module Processing
|
|
26
26
|
LANDSCAPE = :landscape
|
27
27
|
|
28
28
|
# @private
|
29
|
-
@@
|
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
|
-
@@
|
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
|
-
|
91
|
-
@
|
92
|
-
|
93
|
-
|
94
|
-
|
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
|
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
|
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 "
|
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
|
-
|
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
|
data/lib/processing/vector.rb
CHANGED
data/lib/processing.rb
CHANGED
@@ -2,37 +2,51 @@ require 'processing/all'
|
|
2
2
|
|
3
3
|
|
4
4
|
module Processing
|
5
|
-
Processing.
|
6
|
-
|
7
|
-
WINDOW__, CONTEXT__, funcs, events = Processing.setup__ Processing
|
5
|
+
WINDOW__, CONTEXT__ = Processing.setup__ Processing
|
8
6
|
|
9
7
|
refine Object do
|
10
|
-
|
8
|
+
context = CONTEXT__
|
9
|
+
Processing.funcs__(context).each do |func|
|
11
10
|
define_method func do |*args, **kwargs, &block|
|
12
|
-
|
11
|
+
context.__send__ func, *args, **kwargs, &block
|
13
12
|
end
|
14
13
|
end
|
14
|
+
end
|
15
|
+
end# Processing
|
16
|
+
|
17
|
+
|
18
|
+
def Processing(snake_case: false)
|
19
|
+
return Processing unless snake_case
|
20
|
+
|
21
|
+
$processing_refinements_with_snake_case ||= Module.new do
|
22
|
+
Processing.alias_snake_case_methods__ Processing
|
15
23
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
24
|
+
refine Object do
|
25
|
+
context = Processing::CONTEXT__
|
26
|
+
Processing.funcs__(context).each do |func|
|
27
|
+
define_method func do |*args, **kwargs, &block|
|
28
|
+
context.__send__ func, *args, **kwargs, &block
|
29
|
+
end
|
21
30
|
end
|
22
31
|
end
|
23
32
|
end
|
24
|
-
end
|
33
|
+
end
|
25
34
|
|
26
35
|
|
27
36
|
begin
|
28
37
|
w, c = Processing::WINDOW__, Processing::CONTEXT__
|
29
38
|
|
30
|
-
c.class.constants
|
31
|
-
|
32
|
-
|
39
|
+
c.class.constants
|
40
|
+
.reject {_1 =~ /__$/}
|
41
|
+
.each {self.class.const_set _1, c.class.const_get(_1)}
|
33
42
|
|
34
43
|
w.__send__ :begin_draw
|
35
44
|
at_exit do
|
45
|
+
Processing.events__(c).each do |event|
|
46
|
+
m = begin method event; rescue NameError; nil end
|
47
|
+
c.__send__(event) {__send__ event} if m
|
48
|
+
end
|
49
|
+
|
36
50
|
w.__send__ :end_draw
|
37
51
|
Processing::App.new {w.show}.start if c.hasUserBlocks__ && !$!
|
38
52
|
end
|
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.
|
30
|
-
s.add_dependency 'rucy', '~> 0.3.
|
31
|
-
s.add_dependency 'rays', '~> 0.3.
|
32
|
-
s.add_dependency 'reflexion', '~> 0.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/
|
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.
|
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-
|
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.
|
33
|
+
version: 0.3.4
|
34
34
|
- - ">="
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: 0.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.
|
43
|
+
version: 0.3.4
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 0.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.
|
53
|
+
version: 0.3.4
|
54
54
|
- - ">="
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: 0.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.
|
63
|
+
version: 0.3.4
|
64
64
|
- - ">="
|
65
65
|
- !ruby/object:Gem::Version
|
66
|
-
version: 0.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.
|
73
|
+
version: 0.3.4
|
74
74
|
- - ">="
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: 0.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.
|
83
|
+
version: 0.3.4
|
84
84
|
- - ">="
|
85
85
|
- !ruby/object:Gem::Version
|
86
|
-
version: 0.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.
|
93
|
+
version: 0.3.4
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.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.
|
103
|
+
version: 0.3.4
|
104
104
|
- - ">="
|
105
105
|
- !ruby/object:Gem::Version
|
106
|
-
version: 0.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: []
|