processing 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/release.yml +4 -4
- data/.github/workflows/test.yml +3 -3
- data/ChangeLog.md +7 -0
- data/LICENSE +1 -1
- data/VERSION +1 -1
- data/examples/breakout.rb +2 -1
- data/examples/camera.rb +2 -1
- data/examples/clock.rb +3 -1
- data/examples/delay_camera.rb +2 -1
- data/examples/hello.rb +2 -1
- data/examples/image.rb +2 -1
- data/examples/shapes.rb +2 -1
- data/lib/processing/all.rb +20 -0
- data/lib/processing/capture.rb +119 -0
- data/lib/processing/context.rb +471 -0
- data/lib/processing/font.rb +62 -0
- data/lib/processing/graphics.rb +40 -0
- data/lib/processing/graphics_context.rb +1676 -0
- data/lib/processing/image.rb +128 -0
- data/lib/processing/shader.rb +157 -0
- data/lib/processing/touch.rb +28 -0
- data/lib/processing/vector.rb +559 -0
- data/lib/processing.rb +30 -11
- data/lib/rubysketch-processing.rb +1 -1
- data/lib/rubysketch.rb +1 -1
- data/processing.gemspec +2 -2
- data/src/RubyProcessing.mm +1 -1
- data/test/helper.rb +8 -2
- data/test/{processing/test_graphics.rb → test_graphics.rb} +3 -3
- data/test/{processing/test_shader.rb → test_shader.rb} +3 -3
- data/test/{processing/test_utility.rb → test_utility.rb} +3 -3
- data/test/{processing/test_vector.rb → test_vector.rb} +8 -4
- metadata +24 -18
- data/lib/processing/include.rb +0 -25
- data/lib/processing/processing.rb +0 -3211
- data/test/processing/helper.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 530906b18ffcfc45cd88141c8c68857f9e05e4503399d5300188cfb105d1990f
|
4
|
+
data.tar.gz: e98b0aa812bbc7a1c3d58b548fe2216631eaba2c5486cca907ec33b5500536f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e3daa052843fb58bb0842f5eaef522962c32dafdcb295c0e0bc02d0a9476d66d1106f4cc79532285060e776e7d82cebe3c8877908951dc44f8986af72d09f0a
|
7
|
+
data.tar.gz: 79b8e742b6922e46c31dcb5f2f0abb3d679fe29ef0bccbf0a188526ae20d771f5950b62351f3c7fa579690a4af26efb823bb25bfa1a39a1fd87ef0ed37c71dd9
|
@@ -12,10 +12,10 @@ jobs:
|
|
12
12
|
- name: checkout
|
13
13
|
uses: actions/checkout@v2
|
14
14
|
|
15
|
-
- name: ruby 3.
|
16
|
-
uses:
|
15
|
+
- name: ruby 3.2
|
16
|
+
uses: ruby/setup-ruby@v1
|
17
17
|
with:
|
18
|
-
ruby-version: 3.
|
18
|
+
ruby-version: 3.2
|
19
19
|
|
20
20
|
- name: install gems
|
21
21
|
run: |
|
@@ -25,7 +25,7 @@ jobs:
|
|
25
25
|
- name: version
|
26
26
|
id: version
|
27
27
|
run: |
|
28
|
-
echo
|
28
|
+
echo value=$(ruby -e 'print "${{ github.ref }}"[/\/v([\w\.\-]+)/, 1]') >> $GITHUB_OUTPUT
|
29
29
|
|
30
30
|
- name: create gem
|
31
31
|
run: rake clean gem
|
data/.github/workflows/test.yml
CHANGED
data/ChangeLog.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
# Processing for CRuby ChangeLog
|
2
2
|
|
3
3
|
|
4
|
+
## [0.5.0] - 2023-02-09
|
5
|
+
|
6
|
+
- requiring 'processing/include' is deprecated
|
7
|
+
- require 'processing' and 'using Processing' is now required
|
8
|
+
- do not show the window if a draw block is not given
|
9
|
+
|
10
|
+
|
4
11
|
## [0.4.0] - 2022-12-29
|
5
12
|
|
6
13
|
- renamed from rubysketch.gem to processing.gem
|
data/LICENSE
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
data/examples/breakout.rb
CHANGED
data/examples/camera.rb
CHANGED
data/examples/clock.rb
CHANGED
data/examples/delay_camera.rb
CHANGED
data/examples/hello.rb
CHANGED
data/examples/image.rb
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
.map {|s| File.expand_path "../../#{s}/lib", __dir__}
|
3
3
|
.each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
|
4
4
|
|
5
|
-
require 'processing
|
5
|
+
require 'processing'
|
6
|
+
using Processing
|
6
7
|
|
7
8
|
|
8
9
|
icon = loadImage 'https://xord.org/rubysketch/images/rubysketch128.png'
|
data/examples/shapes.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'set'
|
2
|
+
require 'digest/sha1'
|
3
|
+
require 'pathname'
|
4
|
+
require 'tmpdir'
|
5
|
+
require 'open-uri'
|
6
|
+
require 'reflex'
|
7
|
+
|
8
|
+
require 'processing/module'
|
9
|
+
require 'processing/app'
|
10
|
+
require 'processing/window'
|
11
|
+
|
12
|
+
require 'processing/vector'
|
13
|
+
require 'processing/image'
|
14
|
+
require 'processing/font'
|
15
|
+
require 'processing/touch'
|
16
|
+
require 'processing/shader'
|
17
|
+
require 'processing/capture'
|
18
|
+
require 'processing/graphics_context'
|
19
|
+
require 'processing/graphics'
|
20
|
+
require 'processing/context'
|
@@ -0,0 +1,119 @@
|
|
1
|
+
module Processing
|
2
|
+
|
3
|
+
|
4
|
+
# Camera object.
|
5
|
+
#
|
6
|
+
class Capture
|
7
|
+
|
8
|
+
# Returns a list of available camera device names
|
9
|
+
#
|
10
|
+
# @return [Array] device name list
|
11
|
+
#
|
12
|
+
def self.list()
|
13
|
+
Rays::Camera.device_names
|
14
|
+
end
|
15
|
+
|
16
|
+
# Initialize camera object.
|
17
|
+
#
|
18
|
+
# @overload Capture.new()
|
19
|
+
# @overload Capture.new(cameraName)
|
20
|
+
# @overload Capture.new(requestWidth, requestHeight)
|
21
|
+
# @overload Capture.new(requestWidth, requestHeight, cameraName)
|
22
|
+
#
|
23
|
+
# @param requestWidth [Integer] captured image width
|
24
|
+
# @param requestHeight [Integer] captured image height
|
25
|
+
# @param cameraName [String] camera device name
|
26
|
+
#
|
27
|
+
def initialize(*args)
|
28
|
+
width, height, name =
|
29
|
+
if args.empty?
|
30
|
+
[-1, -1, nil]
|
31
|
+
elsif args[0].kind_of?(String)
|
32
|
+
[-1, -1, args[0]]
|
33
|
+
elsif args[0].kind_of?(Numeric) && args[1].kind_of?(Numeric)
|
34
|
+
[args[0], args[1], args[2]]
|
35
|
+
else
|
36
|
+
raise ArgumentError
|
37
|
+
end
|
38
|
+
@camera = Rays::Camera.new width, height, device_name: name
|
39
|
+
end
|
40
|
+
|
41
|
+
# Start capturing.
|
42
|
+
#
|
43
|
+
# @return [nil] nil
|
44
|
+
#
|
45
|
+
def start()
|
46
|
+
raise "Failed to start capture" unless @camera.start
|
47
|
+
nil
|
48
|
+
end
|
49
|
+
|
50
|
+
# Stop capturing.
|
51
|
+
#
|
52
|
+
# @return [nil] nil
|
53
|
+
#
|
54
|
+
def stop()
|
55
|
+
@camera.stop
|
56
|
+
nil
|
57
|
+
end
|
58
|
+
|
59
|
+
# Returns is the next captured image available?
|
60
|
+
#
|
61
|
+
# @return [Boolean] true means object has next frame
|
62
|
+
#
|
63
|
+
def available()
|
64
|
+
@camera.active?
|
65
|
+
end
|
66
|
+
|
67
|
+
# Reads next frame image
|
68
|
+
#
|
69
|
+
def read()
|
70
|
+
@camera.image
|
71
|
+
end
|
72
|
+
|
73
|
+
# Returns the width of captured image
|
74
|
+
#
|
75
|
+
# @return [Numeric] the width of captured image
|
76
|
+
#
|
77
|
+
def width()
|
78
|
+
@camera.image&.width || 0
|
79
|
+
end
|
80
|
+
|
81
|
+
# Returns the height of captured image
|
82
|
+
#
|
83
|
+
# @return [Numeric] the height of captured image
|
84
|
+
#
|
85
|
+
def height()
|
86
|
+
@camera.image&.height || 0
|
87
|
+
end
|
88
|
+
|
89
|
+
# Applies an image filter.
|
90
|
+
#
|
91
|
+
# overload filter(shader)
|
92
|
+
# overload filter(type)
|
93
|
+
# overload filter(type, param)
|
94
|
+
#
|
95
|
+
# @param shader [Shader] a fragment shader to apply
|
96
|
+
# @param type [THRESHOLD, GRAY, INVERT, BLUR] filter type
|
97
|
+
# @param param [Numeric] a parameter for each filter
|
98
|
+
#
|
99
|
+
def filter(*args)
|
100
|
+
@filter = Shader.createFilter__(*args)
|
101
|
+
end
|
102
|
+
|
103
|
+
# @private
|
104
|
+
def getInternal__()
|
105
|
+
@camera.image || (@dummyImage ||= Rays::Image.new 1, 1)
|
106
|
+
end
|
107
|
+
|
108
|
+
# @private
|
109
|
+
def drawImage__(painter, *args, **states)
|
110
|
+
shader = painter.shader || @filter&.getInternal__
|
111
|
+
painter.push shader: shader, **states do |_|
|
112
|
+
painter.image getInternal__, *args
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
end# Capture
|
117
|
+
|
118
|
+
|
119
|
+
end# Processing
|