ruby-processing 2.6.1 → 2.6.2
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/lib/rpextras.jar +0 -0
- data/lib/ruby-processing/app.rb +9 -2
- data/lib/ruby-processing/helper_methods.rb +7 -112
- data/lib/ruby-processing/runner.rb +12 -6
- data/lib/ruby-processing/version.rb +1 -1
- data/samples/configRP5/configRP5.pde +14 -17
- data/samples/processing_app/topics/ruby_hook/hooky.rb +26 -0
- data/samples/processing_app/topics/ruby_hook/subclass.rb +75 -0
- data/vendors/Rakefile +7 -4
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c47bf5ca5b3ccfac13e28bc08b675ca3ebed4a4
|
4
|
+
data.tar.gz: 9f852f28cebf20c5f4f040da1f18b59c46520e49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06009cf60df0dfd4d03655e8672d8dd6fcce75cc66892bc5ed7a5941b6ad81f3b36449bee4930b54ac2ef474e2834bc997436a354615a4dc71d5dfe7ab125523
|
7
|
+
data.tar.gz: e637f0ded0113ed8b710cf1b9107b7e17c4cee235b0caab5968d78eb1449710dab2639be81084790c30934ac6d4164a84f44e549667859bd39b61a8d6c0adebd
|
data/lib/rpextras.jar
CHANGED
Binary file
|
data/lib/ruby-processing/app.rb
CHANGED
@@ -103,6 +103,7 @@ module Processing
|
|
103
103
|
|
104
104
|
def initialize(options={})
|
105
105
|
super()
|
106
|
+
post_initialize(options)
|
106
107
|
$app = self
|
107
108
|
proxy_java_fields
|
108
109
|
set_sketch_path #unless Processing.online?
|
@@ -129,8 +130,10 @@ module Processing
|
|
129
130
|
args << "--present"
|
130
131
|
end
|
131
132
|
@render_mode ||= JAVA2D
|
132
|
-
|
133
|
-
|
133
|
+
xc = Processing::RP_CONFIG["X_OFF"] ||= 0
|
134
|
+
yc = Processing::RP_CONFIG["Y_OFF"] ||= 0
|
135
|
+
x = options[:x] || xc
|
136
|
+
y = options[:y] || yc
|
134
137
|
args << "--location=#{x},#{y}" # important no spaces here
|
135
138
|
title = options[:title] || File.basename(SKETCH_PATH).sub(/(\.rb)$/, '').titleize
|
136
139
|
args << title
|
@@ -152,6 +155,10 @@ module Processing
|
|
152
155
|
super(*args)
|
153
156
|
end
|
154
157
|
|
158
|
+
def post_initialize(args)
|
159
|
+
nil
|
160
|
+
end
|
161
|
+
|
155
162
|
# Make sure we set the size if we set it before we start the animation thread.
|
156
163
|
def start
|
157
164
|
self.size(@width, @height) if @width && @height
|
@@ -74,6 +74,12 @@ module Processing
|
|
74
74
|
def map(value, start1, stop1, start2, stop2)
|
75
75
|
start2 + (stop2 - start2) * ((value - start1).to_f / (stop1 - start1))
|
76
76
|
end
|
77
|
+
|
78
|
+
# ruby alternative implementation of map using range parameters
|
79
|
+
# NB: (begin .. end) and excluded end (begin ... end) versions produce the same result
|
80
|
+
def map1d(val, r_in, r_out)
|
81
|
+
r_out.begin + (r_out.end - r_out.begin) * ((val - r_in.begin).to_f / (r_in.end - r_in.begin))
|
82
|
+
end
|
77
83
|
|
78
84
|
# explicitly provide 'processing.org' norm instance method
|
79
85
|
def norm(value, start, stop)
|
@@ -98,24 +104,7 @@ module Processing
|
|
98
104
|
def max(*args)
|
99
105
|
args.max { |a, b| a <=> b }
|
100
106
|
end
|
101
|
-
|
102
|
-
# explicitly provide 'processing.org' abs instance method
|
103
|
-
def abs(val)
|
104
|
-
warn 'abs(val) is deprecated use val.abs to avoid this warning'
|
105
|
-
val.abs
|
106
|
-
end
|
107
|
-
|
108
|
-
# explicitly provide 'processing.org' ceil instance method
|
109
|
-
def ceil(val)
|
110
|
-
warn 'ceil(val) is deprecated use val.ceil to avoid this warning'
|
111
|
-
val.ceil
|
112
|
-
end
|
113
|
-
|
114
|
-
# explicitly provide 'processing.org' round instance method
|
115
|
-
def round(val)
|
116
|
-
warn 'round(val) is deprecated use val.round to avoid this warning'
|
117
|
-
val.round
|
118
|
-
end
|
107
|
+
|
119
108
|
|
120
109
|
# explicitly provide 'processing.org' dist instance method
|
121
110
|
def dist(*args)
|
@@ -133,100 +122,6 @@ module Processing
|
|
133
122
|
(amt < low) ? low : ((amt > high) ? high : amt)
|
134
123
|
end
|
135
124
|
|
136
|
-
# explicitly provide 'processing.org' pow instance method
|
137
|
-
def pow(x, exp)
|
138
|
-
warn 'pow(x, exp) is deprecated use x**exp to avoid this warning'
|
139
|
-
x**exp
|
140
|
-
end
|
141
|
-
|
142
|
-
# explicitly provide 'processing.org' radians instance method
|
143
|
-
def radians(theta)
|
144
|
-
warn 'radians(theta) is deprecated use theta.radians to avoid this warning'
|
145
|
-
theta.radians
|
146
|
-
end
|
147
|
-
|
148
|
-
# explicitly provide 'processing.org' degrees instance method
|
149
|
-
def degrees(theta)
|
150
|
-
warn 'degrees(theta) is deprecated use theta.radians to avoid this warning'
|
151
|
-
theta.degrees
|
152
|
-
end
|
153
|
-
|
154
|
-
# explicitly provide 'processing.org' hex instance method
|
155
|
-
def hex(x)
|
156
|
-
warn 'hex(x) is deprecated use x.hex to avoid this warning'
|
157
|
-
x.hex
|
158
|
-
end
|
159
|
-
|
160
|
-
# explicitly provide 'processing.org' unhex instance method
|
161
|
-
def unhex(str)
|
162
|
-
warn 'unhex(str) is deprecated use str.to_i(base=16)'
|
163
|
-
str.to_i(base=16)
|
164
|
-
end
|
165
|
-
|
166
|
-
# explicitly provide 'processing.org' binary instance method
|
167
|
-
def binary(x)
|
168
|
-
warn 'binary(x) is deprecated use x.to_s(2) to avoid this warning'
|
169
|
-
x.to_s(2)
|
170
|
-
end
|
171
|
-
|
172
|
-
# explicitly provide 'processing.org' unbinary instance method
|
173
|
-
def unbinary(str)
|
174
|
-
warn 'unbinary(str) is deprecated use str.to_i(base=2)'
|
175
|
-
str.to_i(base=2)
|
176
|
-
end
|
177
|
-
|
178
|
-
# explicitly provide 'processing.org' nf instance method
|
179
|
-
def nf(*args)
|
180
|
-
warn 'nf(num, digits) is deprecated use num.to_s.rjust(digits) '\
|
181
|
-
'to avoid this warning'
|
182
|
-
if args.length == 2
|
183
|
-
return args[0].to_s.rjust(args[1], '0')
|
184
|
-
elsif args.length == 3
|
185
|
-
return args[0].to_s.rjust(args[1], '0').ljust(args[1] + args[2], '0')
|
186
|
-
else
|
187
|
-
fail ArgumentError, 'takes 2 or 3 parameters'
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
# explicitly provide 'processing.org' mag instance method
|
192
|
-
def mag(*vec)
|
193
|
-
warn 'mag(x, y) is deprecated use hypot(x, y)'
|
194
|
-
if vec.length == 2
|
195
|
-
return hypot(vec[0], vec[1])
|
196
|
-
elsif vec.length == 3
|
197
|
-
return Math.sqrt(vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2])
|
198
|
-
else
|
199
|
-
fail ArgumentError, 'takes 2 or 3 parameters'
|
200
|
-
end
|
201
|
-
end
|
202
|
-
# explicitly provide 'processing.org' trim instance method
|
203
|
-
def trim(str)
|
204
|
-
warn 'deprecated use str.strip'
|
205
|
-
str.strip
|
206
|
-
end
|
207
|
-
|
208
|
-
# explicitly provide 'processing.org' println instance method
|
209
|
-
def println(str)
|
210
|
-
warn 'deprecated use puts(str)'
|
211
|
-
puts str
|
212
|
-
end
|
213
|
-
|
214
|
-
# explicitly provide 'processing.org' hour instance method
|
215
|
-
def hour
|
216
|
-
warn 'deprecated use t = Time.now and t.hour'
|
217
|
-
PApplet.hour
|
218
|
-
end
|
219
|
-
|
220
|
-
# explicitly provide 'processing.org' second instance method
|
221
|
-
def second
|
222
|
-
warn 'deprecated use t = Time.now and t.sec'
|
223
|
-
PApplet.second
|
224
|
-
end
|
225
|
-
|
226
|
-
# explicitly provide 'processing.org' minute instance method
|
227
|
-
def minute
|
228
|
-
PApplet.minute
|
229
|
-
end
|
230
125
|
|
231
126
|
# Uses PImage class method under hood
|
232
127
|
def blend_color(c1, c2, mode)
|
@@ -140,8 +140,13 @@ module Processing
|
|
140
140
|
show_version
|
141
141
|
root = ' PROCESSING_ROOT = Not Set!!!' unless proc_root
|
142
142
|
root ||= " PROCESSING_ROOT = #{Processing::RP_CONFIG['PROCESSING_ROOT']}"
|
143
|
+
jruby = Processing::RP_CONFIG['JRUBY']
|
144
|
+
x_off = Processing::RP_CONFIG['X_OFF']
|
145
|
+
y_off = Processing::RP_CONFIG['Y_OFF']
|
143
146
|
puts root
|
144
|
-
puts " JRUBY = #{
|
147
|
+
puts " JRUBY = #{jruby}" unless jruby.nil?
|
148
|
+
puts " X_OFF = #{x_off}" unless x_off.nil?
|
149
|
+
puts " Y_OFF = #{y_off}" unless y_off.nil?
|
145
150
|
puts " jruby-complete installed = #{installed}"
|
146
151
|
end
|
147
152
|
|
@@ -159,11 +164,12 @@ module Processing
|
|
159
164
|
|
160
165
|
private
|
161
166
|
|
162
|
-
# Trade in this Ruby instance for a JRuby instance, loading in a
|
163
|
-
#
|
164
|
-
#
|
165
|
-
#
|
166
|
-
#
|
167
|
+
# Trade in this Ruby instance for a JRuby instance, loading in a starter
|
168
|
+
# script and passing it some arguments.Unless '--nojruby' is passed, the
|
169
|
+
# installed version of jruby is used instead of our vendored jarred one
|
170
|
+
# (which is required for some sketches eg shaders and for export). To use
|
171
|
+
# jruby-complete by default set JRUBY: false in ~/.rp5rc config
|
172
|
+
# (but that will make using other gems in your sketches hard....)
|
167
173
|
def spin_up(starter_script, sketch, args)
|
168
174
|
runner = "#{RP5_ROOT}/lib/ruby-processing/runners/#{starter_script}"
|
169
175
|
warn('The --jruby flag is no longer required') if @options.jruby
|
@@ -1,10 +1,11 @@
|
|
1
|
+
import java.io.File;
|
2
|
+
|
1
3
|
Button enter, nojruby;
|
2
4
|
String processingRoot = "enter your processing root here"; // edit this line in the sketch
|
3
5
|
String done = "Done";
|
4
6
|
String OS = System.getProperty("os.name").toLowerCase();
|
5
7
|
String home, suggestion, separator, root;
|
6
8
|
PFont font;
|
7
|
-
StringBuilder header = new StringBuilder(200);
|
8
9
|
float rectX, rectX2, rectY; // Position of buttons
|
9
10
|
float rectHeight = 30; // height of rect
|
10
11
|
float rectWidth = 90; // width of rect
|
@@ -16,17 +17,16 @@ boolean acceptOver = false;
|
|
16
17
|
boolean noJruby = false;
|
17
18
|
boolean selected = false;
|
18
19
|
boolean no_jruby = false;
|
19
|
-
|
20
|
+
// The JSON object
|
21
|
+
JSONObject json;
|
20
22
|
|
21
23
|
void setup() {
|
22
24
|
size(600, 200);
|
23
25
|
home = System.getProperty("user.home");
|
24
26
|
File f = new File(home);
|
27
|
+
json = new JSONObject();
|
25
28
|
root = f.getParent();
|
26
29
|
separator = System.getProperty("file.separator");
|
27
|
-
header.append("# YAML configuration file for ruby-processing\n");
|
28
|
-
header.append("# RP5HOME: \"").append(root).append(separator).append("ruby193 ... ").append(separator);
|
29
|
-
header.append("ruby-processing\" #windows users may need to set this\n");
|
30
30
|
font = createFont("Helvetica", 18);
|
31
31
|
if (OS.contains("mac")) {
|
32
32
|
suggestion = "/Applications/Processing.app/Contents/Resources/Java";
|
@@ -40,7 +40,7 @@ void setup() {
|
|
40
40
|
selectedColor = color(0);
|
41
41
|
rectX = rectWidth + 20;
|
42
42
|
rectX2 = rectWidth + 150;
|
43
|
-
rectY = height * 0.
|
43
|
+
rectY = height * 0.8 - rectHeight / 4;
|
44
44
|
enter = new Button(rectX2, rectY, rectWidth, rectHeight, "enter");
|
45
45
|
nojruby = new Button(rectX, rectY, rectWidth, rectHeight, "nojruby");
|
46
46
|
}
|
@@ -71,19 +71,16 @@ void draw() {
|
|
71
71
|
void writeRoot() {
|
72
72
|
rectColor = selectedColor;
|
73
73
|
rectHighlight = selectedColor;
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
PrintWriter pw = createWriter(home + separator + ".rp5rc");
|
81
|
-
pw.append(header);
|
82
|
-
pw.flush();
|
83
|
-
pw.close();
|
74
|
+
json.setString("PROCESSING_ROOT", processingRoot);
|
75
|
+
json.setBoolean("JRUBY", no_jruby);
|
76
|
+
json.setInt("X_OFF", floor(displayWidth * 0.1));
|
77
|
+
json.setInt("Y_OFF", floor(displayHeight * 0.1));
|
78
|
+
|
79
|
+
saveJSONObject(json, home + separator + ".rp5rc");
|
84
80
|
processingRoot = done;
|
85
81
|
}
|
86
82
|
|
83
|
+
|
87
84
|
void keyReleased() {
|
88
85
|
if (key != CODED) {
|
89
86
|
switch (key) {
|
@@ -108,6 +105,7 @@ void update(float x, float y) {
|
|
108
105
|
noJruby = nojruby.overRect();
|
109
106
|
}
|
110
107
|
|
108
|
+
|
111
109
|
void mouseClicked() {
|
112
110
|
update(mouseX, mouseY);
|
113
111
|
if (acceptOver) {
|
@@ -147,4 +145,3 @@ class Button {
|
|
147
145
|
&& mouseY >= y && mouseY <= y + h);
|
148
146
|
}
|
149
147
|
}
|
150
|
-
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# Hooky class demonstrates how to use the post_initialize hook,
|
2
|
+
# available since ruby-processing-2.6.2, to additional attribute
|
3
|
+
# in this case :background as an array of int (splat to color)
|
4
|
+
# Not sure how clever it is to have multiple sketch instances.
|
5
|
+
|
6
|
+
class Hooky < Processing::App
|
7
|
+
attr_reader :back
|
8
|
+
|
9
|
+
def setup
|
10
|
+
size 200, 200
|
11
|
+
background(*back)
|
12
|
+
end
|
13
|
+
|
14
|
+
def post_initialize(args)
|
15
|
+
@back = (args[:background])
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
red = [200, 0, 0]
|
20
|
+
green = [0, 200, 0]
|
21
|
+
blue = [0, 0, 200]
|
22
|
+
colors = [red, green, blue]
|
23
|
+
|
24
|
+
colors.each_with_index do |col, i|
|
25
|
+
Hooky.new(x: i * 90, y: i * 90, title: "Hooky #{i}", background: col)
|
26
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# An example demonstrating the use of a hook to decouple subclasses in
|
2
|
+
# ruby-processing. The base class here is Spin, and we have included
|
3
|
+
# post_initialize as the hook (it does nothing in the base class). SpinArm
|
4
|
+
# and SpinSpots both subclass Spin, but only SpinSpots requires the hook to
|
5
|
+
# change the initialization. Note the use the hook means the subclass does
|
6
|
+
# not need to call super
|
7
|
+
|
8
|
+
def setup
|
9
|
+
size 640, 360
|
10
|
+
@arm = SpinArm.new(x: width / 2, y: height / 2, s: 0.01)
|
11
|
+
@spots = SpinSpots.new(x: width / 2, y: height / 2, s: -0.02, d: 90.0)
|
12
|
+
end
|
13
|
+
|
14
|
+
def draw
|
15
|
+
background 204
|
16
|
+
@arm.display
|
17
|
+
@spots.display
|
18
|
+
end
|
19
|
+
|
20
|
+
class Spin
|
21
|
+
|
22
|
+
attr_accessor :x, :y, :speed
|
23
|
+
attr_accessor :angle
|
24
|
+
|
25
|
+
def initialize(args = {})
|
26
|
+
@x, @y = args[:x], args[:y]
|
27
|
+
@speed = args[:s]
|
28
|
+
@angle = args[:angle] || 0.0
|
29
|
+
post_initialize(args) # this is the hook
|
30
|
+
end
|
31
|
+
|
32
|
+
def update
|
33
|
+
@angle += speed
|
34
|
+
end
|
35
|
+
|
36
|
+
def post_initialize(_args)
|
37
|
+
nil
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
class SpinArm < Spin # inherit from (or "extend") class Spin
|
43
|
+
# NB: initialize inherited from Spin class
|
44
|
+
|
45
|
+
def display
|
46
|
+
stroke_weight 1
|
47
|
+
stroke 0
|
48
|
+
push_matrix
|
49
|
+
translate x, y
|
50
|
+
update
|
51
|
+
rotate angle
|
52
|
+
line 0, 0, 165, 0
|
53
|
+
pop_matrix
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
class SpinSpots < Spin
|
59
|
+
attr_accessor :dim
|
60
|
+
|
61
|
+
def post_initialize(args)
|
62
|
+
@dim = args[:d]
|
63
|
+
end
|
64
|
+
|
65
|
+
def display
|
66
|
+
no_stroke
|
67
|
+
push_matrix
|
68
|
+
translate x, y
|
69
|
+
update
|
70
|
+
rotate angle
|
71
|
+
ellipse(-dim / 2, 0, dim, dim)
|
72
|
+
ellipse(dim / 2, 0, dim, dim)
|
73
|
+
pop_matrix
|
74
|
+
end
|
75
|
+
end
|
data/vendors/Rakefile
CHANGED
@@ -3,12 +3,12 @@ require 'rake/clean'
|
|
3
3
|
WARNING = <<-EOS
|
4
4
|
WARNING: you may not have wget installed, you could just download
|
5
5
|
the correct version of jruby-complete to the vendors folder, and
|
6
|
-
re-run
|
6
|
+
re-run rp5 setup install instead of installing wget. Some systems
|
7
7
|
may also require 'sudo' access to install, NB: this is untested....
|
8
8
|
|
9
9
|
EOS
|
10
10
|
|
11
|
-
JRUBY_VERSION = "1.7.
|
11
|
+
JRUBY_VERSION = "1.7.15"
|
12
12
|
|
13
13
|
CLOBBER.include("jruby-complete-#{JRUBY_VERSION}.jar")
|
14
14
|
|
@@ -20,11 +20,11 @@ task :download => ["jruby-complete-#{JRUBY_VERSION}.jar"]
|
|
20
20
|
|
21
21
|
file "jruby-complete-#{JRUBY_VERSION}.jar" do
|
22
22
|
begin
|
23
|
-
sh "wget http://jruby.org.s3.amazonaws.com/downloads/#{JRUBY_VERSION}/jruby-complete-#{JRUBY_VERSION}.jar"
|
24
|
-
check_sha1("jruby-complete-#{JRUBY_VERSION}.jar", "ad70c18834a143afa6686ebcda27351ebfef7385")
|
23
|
+
sh "wget http://jruby.org.s3.amazonaws.com/downloads/#{JRUBY_VERSION}/jruby-complete-#{JRUBY_VERSION}.jar"
|
25
24
|
rescue
|
26
25
|
warn(WARNING)
|
27
26
|
end
|
27
|
+
check_sha1("jruby-complete-#{JRUBY_VERSION}.jar", "4d9cb332bad3633c9c23a720542f456dc0c58a81")
|
28
28
|
end
|
29
29
|
|
30
30
|
directory "../lib/ruby"
|
@@ -46,3 +46,6 @@ def check_sha1(filename, expected_hash)
|
|
46
46
|
raise "bad sha1 checksum for #{filename} (expected #{expected_hash} got #{sha1.hexdigest})"
|
47
47
|
end
|
48
48
|
end
|
49
|
+
|
50
|
+
|
51
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-processing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.6.
|
4
|
+
version: 2.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Ashkenas
|
@@ -18,7 +18,7 @@ authors:
|
|
18
18
|
autorequire:
|
19
19
|
bindir: bin
|
20
20
|
cert_chain: []
|
21
|
-
date: 2014-
|
21
|
+
date: 2014-09-04 00:00:00.000000000 Z
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|
24
24
|
name: bundler
|
@@ -813,6 +813,8 @@ files:
|
|
813
813
|
- samples/processing_app/topics/motion/puff.rb
|
814
814
|
- samples/processing_app/topics/motion/reflection1.rb
|
815
815
|
- samples/processing_app/topics/motion/reflection2.rb
|
816
|
+
- samples/processing_app/topics/ruby_hook/hooky.rb
|
817
|
+
- samples/processing_app/topics/ruby_hook/subclass.rb
|
816
818
|
- samples/processing_app/topics/shaders/README
|
817
819
|
- samples/processing_app/topics/shaders/Rakefile
|
818
820
|
- samples/processing_app/topics/shaders/blur_filter.rb
|