processing 0.4.0

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.
@@ -0,0 +1,33 @@
1
+ %w[xot rays reflex processing]
2
+ .map {|s| File.expand_path "../../#{s}/lib", __dir__}
3
+ .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
4
+
5
+ require 'processing/include'
6
+
7
+
8
+ w, h = width, height
9
+
10
+ cam = Capture.new w, h, Capture.list.last
11
+ cam.start
12
+
13
+ images = 60.times.map {
14
+ Graphics.new w, h
15
+ }
16
+
17
+ draw do
18
+ if frameCount % 2 == 0
19
+ images.unshift images.pop
20
+ images.first.tap do |image|
21
+ image.beginDraw {
22
+ image.image cam, 0, 0
23
+ }
24
+ end
25
+ end
26
+
27
+ background 0
28
+ segment_h= h / images.size
29
+ images.each.with_index do |image, i|
30
+ y = i * segment_h
31
+ copy image, 0, y, w, segment_h, 0, y, w, segment_h
32
+ end
33
+ end
data/examples/hello.rb ADDED
@@ -0,0 +1,12 @@
1
+ %w[xot rays reflex processing]
2
+ .map {|s| File.expand_path "../../#{s}/lib", __dir__}
3
+ .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
4
+
5
+ require 'processing/include'
6
+
7
+
8
+ draw do
9
+ background 0, 10
10
+ textSize 50
11
+ text 'hello, world!', mouseX, mouseY
12
+ end
data/examples/image.rb ADDED
@@ -0,0 +1,13 @@
1
+ %w[xot rays reflex processing]
2
+ .map {|s| File.expand_path "../../#{s}/lib", __dir__}
3
+ .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
4
+
5
+ require 'processing/include'
6
+
7
+
8
+ icon = loadImage 'https://xord.org/rubysketch/images/rubysketch128.png'
9
+
10
+ draw do
11
+ background 0, 10
12
+ image icon, mouseX, mouseY, icon.width / 10, icon.height / 10
13
+ end
@@ -0,0 +1,121 @@
1
+ %w[xot rays reflex processing]
2
+ .map {|s| File.expand_path "../../#{s}/lib", __dir__}
3
+ .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
4
+
5
+ require 'processing/include'
6
+
7
+
8
+ setup do
9
+ colorMode RGB, 1
10
+ angleMode DEGREES
11
+ end
12
+
13
+ draw do
14
+ background 0
15
+
16
+ fill 1
17
+ stroke 1, 0.5, 0.2
18
+
19
+ translate 10, 10
20
+
21
+ push
22
+
23
+ text 'point', 0, 0
24
+ point 0, 30
25
+
26
+ translate 0, 100
27
+
28
+ text 'point with strokeWeight', 0, 0
29
+ strokeWeight 10
30
+ point 0, 30
31
+ strokeWeight 0
32
+
33
+ translate 0, 100
34
+
35
+ text 'line', 0, 0
36
+ line 0, 30, 100, 50
37
+
38
+ translate 0, 100
39
+
40
+ text 'line with strokeWeight (very slow)', 0, 0
41
+ strokeWeight 10
42
+ line 0, 30, 100, 50
43
+ strokeWeight 1
44
+
45
+ translate 0, 100
46
+
47
+ text 'rect with rectMode(CORNER)', 0, 0
48
+ rectMode CORNER
49
+ rect 20, 30, 100, 50
50
+
51
+ translate 0, 100
52
+
53
+ text 'rect with rectMode(CORNERS)', 0, 0
54
+ rectMode CORNERS
55
+ rect 20, 30, 120, 80
56
+
57
+ translate 0, 100
58
+
59
+ text 'rect with rectMode(CENTER)', 0, 0
60
+ rectMode CENTER
61
+ rect 70, 55, 100, 50
62
+
63
+ translate 0, 100
64
+
65
+ text 'rect with rectMode(RADIUS)', 0, 0
66
+ rectMode RADIUS
67
+ rect 70, 55, 50, 25
68
+
69
+ pop
70
+ translate 200, 0
71
+ push
72
+
73
+ text 'circle', 0, 0
74
+ circle 70, 55, 25
75
+
76
+ translate 0, 100
77
+
78
+ text 'arc', 0, 0
79
+ arc 70, 55, 100, 50, 45, 270
80
+
81
+ translate 0, 100
82
+
83
+ text 'square', 0, 0
84
+ square 20, 30, 50
85
+
86
+ translate 0, 100
87
+
88
+ text 'triangle', 0, 0
89
+ triangle 70, 30, 120, 80, 20, 80
90
+
91
+ translate 0, 100
92
+
93
+ text 'quad', 0, 0
94
+ quad 20, 30, 120, 30, 150, 80, 50, 80
95
+
96
+ translate 0, 100
97
+
98
+ text 'ellipse with ellipseMode(CORNER)', 0, 0
99
+ ellipseMode CORNER
100
+ ellipse 20, 30, 100, 50
101
+
102
+ translate 0, 100
103
+
104
+ text 'ellipse with ellipseMode(CORNERS)', 0, 0
105
+ ellipseMode CORNERS
106
+ ellipse 20, 30, 120, 80
107
+
108
+ translate 0, 100
109
+
110
+ text 'ellipse with ellipseMode(CENTER)', 0, 0
111
+ ellipseMode CENTER
112
+ ellipse 70, 55, 100, 50
113
+
114
+ translate 0, 100
115
+
116
+ text 'ellipse with ellipseMode(RADIUS)', 0, 0
117
+ ellipseMode RADIUS
118
+ ellipse 70, 55, 50, 25
119
+
120
+ pop
121
+ end
@@ -0,0 +1,13 @@
1
+ module Processing
2
+
3
+
4
+ class App < Reflex::Application
5
+
6
+ def on_motion(e)
7
+ Processing.instance_variable_get(:@window)&.on_motion e
8
+ end
9
+
10
+ end# App
11
+
12
+
13
+ end# Processing
@@ -0,0 +1,25 @@
1
+ require 'processing'
2
+
3
+
4
+ begin
5
+ window = Processing::Window.new {start}
6
+ context = Processing::Processing::Context.new window
7
+
8
+ (context.methods - Object.instance_methods).each do |method|
9
+ define_method method do |*args, **kwargs, &block|
10
+ context.__send__ method, *args, **kwargs, &block
11
+ end
12
+ end
13
+
14
+ context.class.constants.each do |const|
15
+ self.class.const_set const, context.class.const_get(const)
16
+ end
17
+
18
+ window.__send__ :begin_draw
19
+ at_exit do
20
+ window.__send__ :end_draw
21
+ Processing::App.new {window.show}.start unless $!
22
+ end
23
+
24
+ PROCESSING_WINDOW = window
25
+ end
@@ -0,0 +1,23 @@
1
+ module Processing
2
+
3
+
4
+ module Module
5
+
6
+ module_function
7
+
8
+ def name()
9
+ super.split('::')[-2]
10
+ end
11
+
12
+ def version()
13
+ open(root_dir 'VERSION') {|f| f.readline.chomp}
14
+ end
15
+
16
+ def root_dir(path = '')
17
+ File.expand_path "../../#{path}", __dir__
18
+ end
19
+
20
+ end# Module
21
+
22
+
23
+ end# Processing