ruby-processing 2.6.14 → 2.6.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rpextras.jar +0 -0
- data/lib/ruby-processing/app.rb +3 -0
- data/lib/ruby-processing/exporters/base_exporter.rb +1 -1
- data/lib/ruby-processing/helper_methods.rb +63 -81
- data/lib/ruby-processing/runners/watch.rb +15 -1
- data/lib/ruby-processing/version.rb +1 -1
- data/vendors/Rakefile +2 -2
- metadata +24 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 384f354fac78ee142f0d968856d620c4834d5a55
|
4
|
+
data.tar.gz: f1ea31f4103503196219832efd8a07334fe20033
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 853c17b72cd1fdcbef31abd6f88d59d389c1b41eca0867f5e02d4c1c19269e841294551d5a440666b3b84aab36be1db6496608b10a458830083036a4e9e24c39
|
7
|
+
data.tar.gz: b15074265d45eb34e6e9b98c269b6632bc83a9f4f364196dd6948db117a84d13364cc9424bbc5759676967fcd38fe907acc6f5c213283f28ff998ff7b1fced57
|
data/lib/rpextras.jar
CHANGED
Binary file
|
data/lib/ruby-processing/app.rb
CHANGED
@@ -21,6 +21,7 @@ module Processing
|
|
21
21
|
Dir["#{RP_CONFIG["PROCESSING_ROOT"]}/core/library/\*.jar"].each do |jar|
|
22
22
|
require jar unless jar =~ /native/
|
23
23
|
end
|
24
|
+
Java::Monkstone::MathToolLibrary.new.load(JRuby.runtime, false)
|
24
25
|
# Include some core processing classes that we'd like to use:
|
25
26
|
include_package 'processing.core'
|
26
27
|
|
@@ -40,6 +41,7 @@ module Processing
|
|
40
41
|
class App < PApplet
|
41
42
|
include Math
|
42
43
|
include HelperMethods
|
44
|
+
include MathTool
|
43
45
|
# Alias some methods for familiarity for Shoes coders.
|
44
46
|
# attr_accessor :frame, :title
|
45
47
|
alias_method :oval, :ellipse
|
@@ -194,6 +196,7 @@ module Processing
|
|
194
196
|
# unfettered access to the methods defined in the surrounding class.
|
195
197
|
module Proxy
|
196
198
|
include Math
|
199
|
+
include MathTool
|
197
200
|
# Generate a list of method names to proxy for inner classes.
|
198
201
|
# Nothing camelCased, nothing __internal__, just the Processing API.
|
199
202
|
def self.desired_method_names(inner_class)
|
@@ -70,7 +70,7 @@ module Processing
|
|
70
70
|
def extract_libraries(source)
|
71
71
|
lines = source.split("\n")
|
72
72
|
libs = lines.grep(/^[^#]*load_(?:java_|ruby_)?librar(?:y|ies)\s+(.+)/) do
|
73
|
-
|
73
|
+
Regexp.last_match(1).split(/\s*,\s*/).map do |raw_library_name|
|
74
74
|
raw_library_name.tr("\"':\r\n", '')
|
75
75
|
end
|
76
76
|
end.flatten
|
@@ -1,5 +1,10 @@
|
|
1
|
+
# processing module wrapper
|
2
|
+
require_relative '../rpextras'
|
3
|
+
|
4
|
+
|
1
5
|
module Processing
|
2
6
|
# Provides some convenience methods available in vanilla processing
|
7
|
+
Java::Monkstone::MathToolLibrary.new.load(JRuby.runtime, false)
|
3
8
|
module HelperMethods
|
4
9
|
# processings epsilon may not be defined yet
|
5
10
|
EPSILON ||= 1.0e-04
|
@@ -13,7 +18,7 @@ module Processing
|
|
13
18
|
buf.end_draw
|
14
19
|
buf
|
15
20
|
end
|
16
|
-
|
21
|
+
|
17
22
|
# A nice method to run a given block for a grid.
|
18
23
|
# Lifted from action_coding/Nodebox.
|
19
24
|
def grid(cols, rows, col_size = 1, row_size = 1)
|
@@ -23,27 +28,18 @@ module Processing
|
|
23
28
|
yield x, y
|
24
29
|
end
|
25
30
|
end
|
26
|
-
|
31
|
+
|
27
32
|
# lerp_color takes three or four arguments, in Java that's two
|
28
33
|
# different methods, one regular and one static, so:
|
29
34
|
def lerp_color(*args)
|
30
35
|
args.length > 3 ? self.class.lerp_color(*args) : super(*args)
|
31
36
|
end
|
32
|
-
|
37
|
+
|
33
38
|
def color(*args)
|
34
|
-
|
35
|
-
|
36
|
-
if args.length == 1
|
37
|
-
if a.is_a?(Fixnum) && a >= 2**31
|
38
|
-
args = [a - 2**32]
|
39
|
-
elsif a.is_a?(String) && a[0].eql?('#')
|
40
|
-
h = a[1..-1].rjust(6, '0').prepend('ff')
|
41
|
-
return color(h.hex)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
super(*args)
|
39
|
+
return super(*args) unless args.length == 1
|
40
|
+
super(hex_color(args[0]))
|
45
41
|
end
|
46
|
-
|
42
|
+
|
47
43
|
# Overrides Processing convenience function thread, which takes a String
|
48
44
|
# arg (for a function) to more rubylike version, takes a block...
|
49
45
|
def thread(&block)
|
@@ -53,7 +49,7 @@ module Processing
|
|
53
49
|
fail ArgumentError, 'thread must be called with a block', caller
|
54
50
|
end
|
55
51
|
end
|
56
|
-
|
52
|
+
|
57
53
|
# Explicitly provides 'processing.org' map instance method, in which
|
58
54
|
# value is mapped from range 1, to range 2 (NB: values are not clamped to
|
59
55
|
# range 1). It may be better to explicitly write your own interpolate
|
@@ -64,56 +60,24 @@ module Processing
|
|
64
60
|
# @return [float] mapped value
|
65
61
|
def map(value, start1, stop1, start2, stop2)
|
66
62
|
start2 + (stop2 - start2) * ((value - start1).to_f / (stop1 - start1))
|
63
|
+
warn('map is deprecated use p5map or map1d instead')
|
67
64
|
end
|
68
|
-
|
69
|
-
|
70
|
-
# (begin..end) and excluded end (begin...end) produce the same result
|
71
|
-
def map1d(val, r_in, r_out)
|
72
|
-
r_out.begin + (r_out.end - r_out.begin) *
|
73
|
-
((val - r_in.begin).to_f / (r_in.end - r_in.begin))
|
74
|
-
end
|
75
|
-
|
76
|
-
# Explicitly provides 'processing.org' map instance method, where
|
77
|
-
# value is mapped from range 1 to range 2 where values are clamped to
|
78
|
-
# range 2.
|
79
|
-
# @param val input
|
80
|
-
# @param [r_in] start1, stop1
|
81
|
-
# @param [r_out] start2, stop2
|
82
|
-
# @return mapped value
|
83
|
-
def constrained_map(val, r_in, r_out)
|
84
|
-
unless r_in.include? val
|
85
|
-
return r_out.begin if (val < r_in.begin && r_in.begin < r_in.end) ||
|
86
|
-
(val > r_in.begin && r_in.begin > r_in.end)
|
87
|
-
return r_out.end
|
88
|
-
end
|
89
|
-
r_out.begin + (r_out.end - r_out.begin) *
|
90
|
-
((val - r_in.begin).to_f / (r_in.end - r_in.begin))
|
91
|
-
end
|
92
|
-
|
93
|
-
# explicitly provide 'processing.org' norm instance method
|
94
|
-
def norm(value, start, stop)
|
95
|
-
(value - start).to_f / (stop - start)
|
96
|
-
end
|
97
|
-
|
98
|
-
# explicitly provide 'processing.org' lerp instance method
|
99
|
-
def lerp(start, stop, amt)
|
100
|
-
start + (stop - start) * amt
|
101
|
-
end
|
102
|
-
|
65
|
+
# deprecate :map, :p5map, 2015, 12
|
66
|
+
|
103
67
|
# explicitly provide 'processing.org' min instance method
|
104
68
|
# to return a float:- a, b and c need to be floats
|
105
|
-
|
69
|
+
|
106
70
|
def min(*args)
|
107
71
|
args.min # { |a,b| a <=> b } optional block not reqd
|
108
72
|
end
|
109
|
-
|
73
|
+
|
110
74
|
# explicitly provide 'processing.org' max instance method
|
111
75
|
# to return a float:- a, b and c need to be floats
|
112
|
-
|
76
|
+
|
113
77
|
def max(*args)
|
114
78
|
args.max # { |a, b| a <=> b } optional block not reqd
|
115
79
|
end
|
116
|
-
|
80
|
+
|
117
81
|
# explicitly provide 'processing.org' dist instance method
|
118
82
|
def dist(*args)
|
119
83
|
len = args.length
|
@@ -124,25 +88,25 @@ module Processing
|
|
124
88
|
end
|
125
89
|
fail ArgumentError, 'takes 4 or 6 parameters'
|
126
90
|
end
|
127
|
-
|
91
|
+
|
128
92
|
# explicitly provide 'processing.org' constrain instance method
|
129
93
|
# to return a float:- amt, low and high need to be floats
|
130
94
|
def constrain(amt, low, high)
|
131
95
|
(low..high).clip(amt)
|
132
96
|
end
|
133
|
-
|
97
|
+
|
134
98
|
# Uses PImage class method under hood
|
135
99
|
def blend_color(c1, c2, mode)
|
136
|
-
Java::ProcessingCore::PImage
|
100
|
+
Java::ProcessingCore::PImage.blendColor(c1, c2, mode)
|
137
101
|
end
|
138
|
-
|
102
|
+
|
139
103
|
# There's just so many functions in Processing,
|
140
104
|
# Here's a convenient way to look for them.
|
141
105
|
def find_method(method_name)
|
142
106
|
reg = Regexp.new("#{method_name}", true)
|
143
107
|
methods.sort.select { |meth| reg.match(meth) }
|
144
108
|
end
|
145
|
-
|
109
|
+
|
146
110
|
# Proxy over a list of Java declared fields that have the same name as
|
147
111
|
# some methods. Add to this list as needed.
|
148
112
|
def proxy_java_fields
|
@@ -151,87 +115,105 @@ module Processing
|
|
151
115
|
@declared_fields = Hash[fields.zip(methods)]
|
152
116
|
end
|
153
117
|
|
118
|
+
class VersionError < StandardError
|
119
|
+
end
|
120
|
+
|
154
121
|
# By default, your sketch path is the folder that your sketch is in.
|
155
122
|
# If you'd like to do something fancy, feel free.
|
156
123
|
def set_sketch_path(spath = nil)
|
157
124
|
field = @declared_fields['sketchPath']
|
158
|
-
|
125
|
+
begin
|
126
|
+
field.set_value(java_self, spath || SKETCH_ROOT)
|
127
|
+
rescue TypeError
|
128
|
+
fail VersionError, 'Use JRubyArt for processing-3.0'
|
129
|
+
end
|
159
130
|
end
|
160
|
-
|
131
|
+
|
161
132
|
# Fix java conversion problems getting the last key
|
162
133
|
# If it's ASCII, return the character, otherwise the integer
|
163
134
|
def key
|
164
135
|
int = @declared_fields['key'].value(java_self)
|
165
136
|
int < 256 ? int.chr : int
|
166
137
|
end
|
167
|
-
|
138
|
+
|
168
139
|
# Provide a convenient handle for the Java-space version of self.
|
169
140
|
def java_self
|
170
141
|
@java_self ||= to_java(Java::ProcessingCore::PApplet)
|
171
142
|
end
|
172
|
-
|
143
|
+
|
173
144
|
# Get the sketch path
|
174
145
|
def sketch_path
|
175
146
|
@declared_fields['sketchPath'].value(java_self)
|
176
147
|
end
|
177
|
-
|
148
|
+
|
178
149
|
# Fields that should be made accessible as under_scored.
|
179
150
|
define_method(:mouse_x) { mouseX }
|
180
|
-
|
151
|
+
|
181
152
|
define_method(:mouse_y) { mouseY }
|
182
|
-
|
153
|
+
|
183
154
|
define_method(:pmouse_x) { pmouseX }
|
184
|
-
|
155
|
+
|
185
156
|
define_method(:pmouse_y) { pmouseY }
|
186
|
-
|
157
|
+
|
187
158
|
define_method(:frame_count) { frameCount }
|
188
|
-
|
159
|
+
|
189
160
|
define_method(:mouse_button) { mouseButton }
|
190
|
-
|
161
|
+
|
191
162
|
define_method(:key_code) { keyCode }
|
192
|
-
|
163
|
+
|
193
164
|
# Ensure that load_strings returns a real Ruby array
|
194
165
|
def load_strings(file_or_url)
|
195
166
|
loadStrings(file_or_url).to_a
|
196
167
|
end
|
197
|
-
|
168
|
+
|
198
169
|
# Writes an array of strings to a file, one line per string.
|
199
170
|
# This file is saved to the sketch's data folder
|
200
171
|
def save_strings(filename, strings)
|
201
172
|
saveStrings(filename, [strings].flatten.to_java(:String))
|
202
173
|
end
|
203
|
-
|
174
|
+
|
204
175
|
# frame_rate needs to support reading and writing
|
205
176
|
def frame_rate(fps = nil)
|
206
177
|
return @declared_fields['frameRate'].value(java_self) unless fps
|
207
178
|
super(fps)
|
208
179
|
end
|
209
|
-
|
180
|
+
|
210
181
|
# Is the mouse pressed for this frame?
|
211
182
|
def mouse_pressed?
|
212
183
|
@declared_fields['mousePressed'].value(java_self)
|
213
184
|
end
|
214
|
-
|
185
|
+
|
215
186
|
# Is a key pressed for this frame?
|
216
187
|
def key_pressed?
|
217
188
|
@declared_fields['keyPressed'].value(java_self)
|
218
|
-
end
|
219
|
-
|
189
|
+
end
|
190
|
+
|
220
191
|
private
|
221
|
-
|
192
|
+
|
193
|
+
# parse single argument color int/double/String
|
194
|
+
def hex_color(a)
|
195
|
+
if a.is_a?(Fixnum)
|
196
|
+
return Java::Monkstone::ColorUtil.colorLong(a)
|
197
|
+
elsif a.is_a?(String)
|
198
|
+
return Java::Monkstone::ColorUtil.colorString(a) if a =~ /#\h+/
|
199
|
+
fail StandardError, 'Dodgy Hexstring'
|
200
|
+
end
|
201
|
+
Java::Monkstone::ColorUtil.colorDouble(a)
|
202
|
+
end
|
203
|
+
|
222
204
|
def dist2d(*args)
|
223
205
|
dx = args[0] - args[2]
|
224
206
|
dy = args[1] - args[3]
|
225
207
|
return 0 if dx.abs < EPSILON && dy.abs < EPSILON
|
226
208
|
Math.hypot(dx, dy)
|
227
209
|
end
|
228
|
-
|
210
|
+
|
229
211
|
def dist3d(*args)
|
230
212
|
dx = args[0] - args[3]
|
231
213
|
dy = args[1] - args[4]
|
232
214
|
dz = args[2] - args[5]
|
233
215
|
return 0 if dx.abs < EPSILON && dy.abs < EPSILON && dz.abs < EPSILON
|
234
216
|
Math.sqrt(dx * dx + dy * dy + dz * dz)
|
235
|
-
end
|
217
|
+
end
|
236
218
|
end
|
237
219
|
end
|
@@ -5,6 +5,15 @@ module Processing
|
|
5
5
|
# the feedback between code and effect.
|
6
6
|
class Watcher
|
7
7
|
# Sic a new Processing::Watcher on the sketch
|
8
|
+
WATCH_MESSAGE ||= <<-EOS
|
9
|
+
Warning:
|
10
|
+
To protect you from running watch mode in a top level
|
11
|
+
directory with lots of nested ruby or GLSL files we
|
12
|
+
limit the number of files to watch to %d.
|
13
|
+
If you really want to watch %d files you should
|
14
|
+
increase MAX_WATCH in ~/.rp5rc
|
15
|
+
|
16
|
+
EOS
|
8
17
|
SLEEP_TIME = 0.2
|
9
18
|
def initialize
|
10
19
|
reload_files_to_watch
|
@@ -50,7 +59,12 @@ module Processing
|
|
50
59
|
end
|
51
60
|
|
52
61
|
def reload_files_to_watch
|
53
|
-
@files = Dir.glob(File.join(SKETCH_ROOT,
|
62
|
+
@files = Dir.glob(File.join(SKETCH_ROOT, '**/*.{rb,glsl}'))
|
63
|
+
count = @files.length
|
64
|
+
max_watch = RP_CONFIG.fetch('MAX_WATCH', 20)
|
65
|
+
return unless count > max_watch
|
66
|
+
warn format(WATCH_MESSAGE, max_watch, count)
|
67
|
+
abort
|
54
68
|
end
|
55
69
|
end
|
56
70
|
end
|
data/vendors/Rakefile
CHANGED
@@ -8,7 +8,7 @@ WARNING = <<-EOS
|
|
8
8
|
|
9
9
|
EOS
|
10
10
|
|
11
|
-
JRUBYC_VERSION = '1.7.
|
11
|
+
JRUBYC_VERSION = '1.7.22'
|
12
12
|
EXAMPLES = '1.7'
|
13
13
|
HOME_DIR = ENV['HOME']
|
14
14
|
MAC_OR_LINUX = /linux|mac|darwin/ =~ RbConfig::CONFIG['host_os']
|
@@ -27,7 +27,7 @@ file "jruby-complete-#{JRUBYC_VERSION}.jar" do
|
|
27
27
|
rescue
|
28
28
|
warn(WARNING)
|
29
29
|
end
|
30
|
-
check_sha1("jruby-complete-#{JRUBYC_VERSION}.jar", "
|
30
|
+
check_sha1("jruby-complete-#{JRUBYC_VERSION}.jar", "42dc9be2f706774c24ef61ec2981d05e2c79a9e2")
|
31
31
|
end
|
32
32
|
|
33
33
|
directory "../lib/ruby"
|
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.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Ashkenas
|
@@ -16,14 +16,14 @@ authors:
|
|
16
16
|
autorequire:
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
|
-
date: 2015-
|
19
|
+
date: 2015-08-21 00:00:00.000000000 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
requirement: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.10'
|
27
27
|
name: bundler
|
28
28
|
prerelease: false
|
29
29
|
type: :development
|
@@ -31,13 +31,13 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '1.
|
34
|
+
version: '1.10'
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
requirement: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '10.
|
40
|
+
version: '10.4'
|
41
41
|
name: rake
|
42
42
|
prerelease: false
|
43
43
|
type: :development
|
@@ -45,7 +45,7 @@ dependencies:
|
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '10.
|
48
|
+
version: '10.4'
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
50
|
requirement: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '5.
|
68
|
+
version: '5.8'
|
69
69
|
name: minitest
|
70
70
|
prerelease: false
|
71
71
|
type: :development
|
@@ -73,8 +73,22 @@ dependencies:
|
|
73
73
|
requirements:
|
74
74
|
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: '5.
|
77
|
-
|
76
|
+
version: '5.8'
|
77
|
+
- !ruby/object:Gem::Dependency
|
78
|
+
requirement: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.3'
|
83
|
+
name: rspec
|
84
|
+
prerelease: false
|
85
|
+
type: :development
|
86
|
+
version_requirements: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '3.3'
|
91
|
+
description: " Ruby-Processing is a ruby wrapper for the processing-2.0 art framework.\n\
|
78
92
|
\ This version supports processing-2.2.1, and uses jruby-complete-1.7.22 or an\
|
79
93
|
\ \n installed jruby as the glue between ruby and java. Use both processing \n\
|
80
94
|
\ libraries and ruby gems in your sketches. The \"watch\" mode, provides a \n \
|
@@ -146,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
160
|
requirements:
|
147
161
|
- A decent graphics card
|
148
162
|
- java runtime >= 1.7+
|
149
|
-
- processing = 2.2.1
|
163
|
+
- processing = 2.2.1
|
150
164
|
rubyforge_project:
|
151
165
|
rubygems_version: 2.4.8
|
152
166
|
signing_key:
|