ruby-processing 2.6.0 → 2.6.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b0e7df4d8034c02dcfe15463749d38214bbe608f
4
- data.tar.gz: e4a17499eeb39eadc078e071eb05b277afd2c03f
3
+ metadata.gz: c0aaf568197ed0c33de6d5ee76ee799e488dbf7c
4
+ data.tar.gz: 141086257f20b9b623a7092ba17b857e22e0e694
5
5
  SHA512:
6
- metadata.gz: 8bfc1d032a6c94051c9a727f4daa0523dc4429cb02744a34c0f6f20c84a220a653d3ba1b6716a9745622a1fd1465d9ce5506b1fe1f238980dfb64181c2f03686
7
- data.tar.gz: d555e878a9d35ea17fc64ae4f713413364c943e92be126e2b9683b503ab4db7d03b3ac8c1b68a775770a7c9a636e059614f4a4109b8e9757ec1a10865e5f93ab
6
+ metadata.gz: 4dcfc3f5a0ae54e209ffd00ce00844287a3c5811ba352b657a42d9e47d526466a6ab97ed535b4a50d4fe6f615fc81f686008b54fe3ecb80cf2a6e95e149fe4e0
7
+ data.tar.gz: 05c8de38b6678bcbb3ee193306deed6c8f4d9d45a3b9762bd62465ef27b6b1ef0581fdf2e5e035d083b049086b899ea9d4897b2507be605ae41d6f0c9beca0de
data/lib/rpextras.jar CHANGED
Binary file
@@ -7,10 +7,10 @@ require_relative '../ruby-processing/helper_methods'
7
7
  require_relative '../ruby-processing/library_loader'
8
8
  require_relative '../ruby-processing/config'
9
9
 
10
- Dir["#{Processing::RB_CONFIG["PROCESSING_ROOT"]}/core/library/\*.jar"].each { |jar| require jar }
10
+ Dir["#{Processing::RP_CONFIG["PROCESSING_ROOT"]}/core/library/\*.jar"].each { |jar| require jar }
11
11
 
12
12
  # Include some core processing classes that we'd like to use:
13
- %w(PApplet PConstants PFont PImage PShape PShapeOBJ PShapeSVG PStyle
13
+ %w(PApplet PConstants PFont PImage PShape PShapeOBJ PShapeSVG PStyle
14
14
  PGraphicsJava2D PGraphics PFont PVector PMatrix2D PMatrix3D).each do |klass|
15
15
  java_import "processing.core.#{klass}"
16
16
  end
@@ -54,8 +54,8 @@ module Processing
54
54
  if methods_to_alias.key?(method_name)
55
55
  alias_method methods_to_alias[method_name], method_name
56
56
  end
57
- end
58
-
57
+ end
58
+
59
59
  # Handy getters and setters on the class go here:
60
60
  def self.sketch_class; @sketch_class; end
61
61
  @@full_screen = false
@@ -92,15 +92,15 @@ module Processing
92
92
 
93
93
  def library_loaded?(library_name)
94
94
  self.class.library_loaded?(library_name)
95
- end
95
+ end
96
96
 
97
- # It is 'NOT' usually necessary to directly pass options to a sketch, it
97
+ # It is 'NOT' usually necessary to directly pass options to a sketch, it
98
98
  # gets done automatically for you. Since processing-2.0 you should prefer
99
99
  # setting the sketch width and height and renderer using the size method,
100
- # in the sketch (as with vanilla processing), which should be the first
100
+ # in the sketch (as with vanilla processing), which should be the first
101
101
  # argument in setup. Sensible options to pass are x and y to locate sketch
102
102
  # on the screen, or full_screen: true (prefer new hash syntax)
103
-
103
+
104
104
  def initialize(options={})
105
105
  super()
106
106
  $app = self
@@ -161,6 +161,7 @@ module Processing
161
161
  # Provide a loggable string to represent this sketch.
162
162
  def inspect
163
163
  "#<Processing::App:#{self.class}:#{@title}>"
164
+ #"#<Processing::App:#{self.class}>"
164
165
  end
165
166
 
166
167
  # Cleanly close and shutter a running sketch.
@@ -202,8 +203,8 @@ module Processing
202
203
 
203
204
  # Proxy methods through to the sketch.
204
205
  def self.proxy_methods(inner_class)
205
- code = desired_method_names(inner_class).inject('') do |code, method|
206
- code << <<-EOS
206
+ code = desired_method_names(inner_class).inject('') do |rcode, method|
207
+ rcode << <<-EOS
207
208
  def #{method}(*args, &block) # def rect(*args, &block)
208
209
  if block_given? # if block_given?
209
210
  $app.send :'#{method}', *args, &block # $app.send(:rect, *args, &block)
@@ -3,13 +3,13 @@ require 'psych'
3
3
  module Processing
4
4
 
5
5
  if Processing.exported?
6
- RB_CONFIG = { 'PROCESSING_ROOT' => RP5_ROOT, 'JRUBY' => 'false' }
6
+ RP_CONFIG = { 'PROCESSING_ROOT' => RP5_ROOT, 'JRUBY' => 'false' }
7
7
  end
8
8
 
9
- unless defined? RB_CONFIG
9
+ unless defined? RP_CONFIG
10
10
  begin
11
- CONFIG_FILE_PATH=File.expand_path('~/.rp5rc')
12
- RB_CONFIG = (Psych.load_file(CONFIG_FILE_PATH))
11
+ CONFIG_FILE_PATH = File.expand_path('~/.rp5rc')
12
+ RP_CONFIG = (Psych.load_file(CONFIG_FILE_PATH))
13
13
  rescue
14
14
  warn('WARNING: you need to set PROCESSING_ROOT in ~/.rp5rc')
15
15
  end
@@ -1,7 +1,8 @@
1
1
  require 'rbconfig'
2
+ require_relative 'base_exporter'
2
3
 
3
4
  module Processing
4
- require_relative '../../ruby-processing/exporters/base_exporter'
5
+
5
6
  # A utility class to export Ruby-Processing sketches as
6
7
  # Mac/Win/Nix Applications.
7
8
  class ApplicationExporter < BaseExporter
@@ -43,7 +44,7 @@ module Processing
43
44
  @prefix = 'lib'
44
45
  cp_r(Dir["#{RP5_ROOT}/lib/templates/application/{*,**}"], @dest)
45
46
  @necessary_files = [@main_file_path]
46
- @necessary_files += Dir["#{RB_CONFIG['PROCESSING_ROOT']}/core/library/{*,**}"]
47
+ @necessary_files += Dir["#{RP_CONFIG['PROCESSING_ROOT']}/core/library/{*,**}"]
47
48
  @necessary_files += Dir["#{RP5_ROOT}/lib/{*,**}"]
48
49
  @necessary_files += @real_requires
49
50
  NECESSARY_FOLDERS.each do |folder|
@@ -55,19 +56,19 @@ module Processing
55
56
  cp_r(@libraries, File.join(@dest, @prefix, 'library')) unless @libraries.empty?
56
57
  # Then move the icon
57
58
  potential_icon = Dir.glob(File.join(@dest, @prefix, 'data/*.icns'))[0]
58
- move(potential_icon, File.join(@dest, 'Contents/Resources/sketch.icns'), force: true) if potential_icon
59
+ move(potential_icon, File.join(@dest, 'Contents/Resources/sketch.icns'), force: true) if potential_icon
59
60
  end
60
61
 
61
62
  def calculate_substitutions
62
63
  file_list = ['lib/ruby/jruby-complete.jar']
63
- @class_path = file_list.map { |f| '$JAVAROOT/' + f.sub(@prefix+'/', '') }.join(':')
64
+ @class_path = file_list.map { |f| '$JAVAROOT/' + f.sub(@prefix + "/", '') }.join(":")
64
65
  @linux_class_path = '.:../lib/ruby/*:../lib/*:../lib/library/*'
65
66
  @windows_class_path = '.;../lib/ruby/*;../lib/*;../lib/library/*'
66
67
  end
67
68
 
68
69
  def create_executables
69
70
  render_erb_in_path_with_binding(@dest, binding, delete: true)
70
- rm Dir.glob(@dest + '/**/*.java')
71
+ rm Dir.glob(@dest + "/**/*.java")
71
72
  runnable = @dest + '/' + File.basename(@main_file, '.rb')
72
73
  move @dest + '/run', runnable
73
74
  move @dest + '/run.exe', "#{runnable}.exe"
@@ -1,6 +1,6 @@
1
1
  require 'fileutils'
2
2
  require 'erb'
3
- require_relative '../../ruby-processing/library_loader'
3
+ require_relative '../library_loader'
4
4
 
5
5
  module Processing
6
6
  # This base exporter implements some of the common
@@ -42,8 +42,7 @@ module Processing
42
42
 
43
43
  # Searches the source for a title.
44
44
  def extract_title(source)
45
- filter = /#{@info[:class_name]}\.new.*?:title\s=>\s["'](.+?)["']/m
46
- match = source.match(filter)
45
+ match = source.match(/#{@info[:class_name]}\.new.*?:title\s=>\s["'](.+?)["']/m)
47
46
  match ? match[1] : File.basename(@file, '.rb').titleize
48
47
  end
49
48
 
@@ -103,7 +102,6 @@ module Processing
103
102
  requirements
104
103
  end
105
104
 
106
-
107
105
  protected
108
106
 
109
107
  def read_source_code
@@ -115,7 +113,7 @@ module Processing
115
113
  end
116
114
 
117
115
  def hash_to_ivars(hash)
118
- hash.each { |k, v| instance_variable_set('@' + k.to_s, v) }
116
+ hash.each { |k, v| instance_variable_set("@#{k}", v) }
119
117
  end
120
118
 
121
119
  def wipe_and_recreate_destination
@@ -124,7 +122,7 @@ module Processing
124
122
  end
125
123
 
126
124
  def render_erb_in_path_with_binding(path, some_binding, opts = {})
127
- erbs = Dir.glob(path + '/**/*.erb')
125
+ erbs = Dir.glob(path + "/**/*.erb") # double quotes required
128
126
  erbs.each do |erb|
129
127
  string = File.open(erb) { |f| f.read }
130
128
  rendered = render_erb_from_string_with_binding(string, some_binding)
@@ -138,4 +136,3 @@ module Processing
138
136
  end
139
137
  end
140
138
  end
141
-
@@ -1,8 +1,33 @@
1
1
  module Processing
2
- require_relative '../../ruby-processing/exporters/base_exporter'
3
- Param = Struct.new(:name, :file_name, :title, :width, :height, :mode)
2
+ require 'erb'
3
+
4
+ class SketchWriter
5
+ include ERB::Util
6
+
7
+ def initialize(template, param = {})
8
+ @name = param[:name]
9
+ @file_name = param[:file_name]
10
+ @title = param[:title]
11
+ @width = param[:width]
12
+ @height = param[:height]
13
+ @mode = param[:mode].upcase unless param[:mode].nil?
14
+ @template = template
15
+ save(@file_name)
16
+ end
17
+
18
+ def render
19
+ ERB.new(@template).result(binding)
20
+ end
21
+
22
+ def save(file)
23
+ File.open(file, 'w+') do |f|
24
+ f.write(render)
25
+ end
26
+ end
27
+ end
28
+
4
29
  # An abstract class providing common methods for real creators
5
- class Creator < BaseExporter
30
+ class Creator
6
31
 
7
32
  ALL_DIGITS = /\A\d+\Z/
8
33
 
@@ -24,90 +49,139 @@ module Processing
24
49
  mode can be P2D / P3D.
25
50
  Use --wrap for a sketch wrapped as a class
26
51
  Use --inner to generated a ruby version of 'java' Inner class
27
- Examples: rp5 create fancy_drawing/app 800 600
28
- rp5 create fancy_drawing/app 800 600 P3D --wrap
52
+ Examples: rp5 create app 800 600
53
+ rp5 create app 800 600 p3d --wrap
29
54
  rp5 create inner_class --inner
30
55
 
31
56
  USAGE
32
57
  end
33
58
 
34
- def create_file(path, param, rendered, type)
35
- # Make the file
36
- dir = File.dirname path
37
- mkdir_p dir
38
- ful_path = File.join(dir, "#{param.file_name}.rb")
39
- File.open(ful_path, 'w') { |f| f.print(rendered) }
40
- puts "Created #{type} \"#{param.title}\" in #{ful_path.sub(/\A\.\//, '')}"
41
- end
42
59
  end
43
60
 
44
61
  # This class creates bare sketches, with an optional render mode
45
62
  class BasicSketch < Creator
46
63
  # Create a blank sketch, given a path.
64
+ def basic_template
65
+ %{
66
+ def setup
67
+ size <%=@width%>, <%=@height%>
68
+ end
69
+
70
+ def draw
71
+
72
+ end
73
+ }
74
+ end
75
+
76
+ def basic_template_mode
77
+ %{
78
+ def setup
79
+ size <%=@width%>, <%=@height%>, <%=@mode%>
80
+ end
81
+
82
+ def draw
83
+
84
+ end
85
+ }
86
+ end
87
+
47
88
  def create!(path, args)
48
89
  return usage if /\?/ =~ path || /--help/ =~ path
49
90
  main_file = File.basename(path, '.rb')
50
91
  # Check to make sure that the main file doesn't exist already
51
92
  already_exist(path)
52
- @param = Param.new(
53
- main_file.camelize,
54
- main_file.underscore,
55
- main_file.titleize,
56
- args[0],
57
- args[1],
58
- args[2]
59
- )
60
- @with_size = @param.width && @param.width.match(ALL_DIGITS) &&
61
- @param.height && @param.height.match(ALL_DIGITS)
62
- template_name = @param.mode.nil? ? 'basic.rb.erb' : 'basic_mode.rb.erb'
63
- template = File.new("#{RP5_ROOT}/lib/templates/create/#{template_name}")
64
- rendered = render_erb_from_string_with_binding(template.read, binding)
65
- create_file(path, @param, rendered, 'Sketch')
93
+ @param = {
94
+ name: main_file.camelize,
95
+ file_name: "#{File.dirname(path)}/#{path.underscore}.rb",
96
+ title: main_file.titleize,
97
+ width: args[0],
98
+ height: args[1],
99
+ mode: args[2]
100
+ }
101
+ @with_size = @param[:width] && @param[:width].match(ALL_DIGITS) &&
102
+ @param[:height] && @param[:height].match(ALL_DIGITS)
103
+ template = @param[:mode].nil? ? basic_template : basic_template_mode
104
+ SketchWriter.new(template, @param)
66
105
  end
67
106
  end
68
107
 
69
108
  # This class creates class wrapped sketches, with an optional render mode
70
109
  class ClassSketch < Creator
110
+
111
+ def class_template
112
+ %{
113
+ class <%=@name%> < Processing::App
114
+ def setup
115
+ size <%=@width%>, <%=@height%>
116
+ end
117
+
118
+ def draw
119
+
120
+ end
121
+ end
122
+
123
+ # <%=@name%>.new(x: 20, y: 20)
124
+ }
125
+ end
126
+
127
+ def class_template_mode
128
+ %{
129
+ class <%=@name%> < Processing::App
130
+ def setup
131
+ size <%=@width%>, <%=@height%>, <%=@mode%>
132
+ end
133
+
134
+ def draw
135
+
136
+ end
137
+ end
138
+
139
+ # <%=@name%>.new(x: 20, y: 20)
140
+ }
141
+ end
71
142
  # Create a bare blank sketch, given a path.
72
143
  def create!(path, args)
73
144
  return usage if /\?/ =~ path || /--help/ =~ path
74
145
  main_file = File.basename(path, '.rb')
75
146
  # Check to make sure that the main file doesn't exist already
76
147
  already_exist(path)
77
- @param = Param.new(
78
- main_file.camelize,
79
- main_file.underscore,
80
- main_file.titleize,
81
- args[0],
82
- args[1],
83
- args[2]
84
- )
85
- @with_size = @param.width && @param.width.match(ALL_DIGITS) &&
86
- @param.height && @param.height.match(ALL_DIGITS)
87
- t_name = @param.mode.nil? ? 'basic_wrap.rb.erb' : 'mode_wrap.rb.erb'
88
- template = File.new("#{RP5_ROOT}/lib/templates/create/#{t_name}")
89
- rendered = render_erb_from_string_with_binding(template.read, binding)
90
- create_file(path, @param, rendered, 'Sketch')
148
+ @param = {
149
+ name: main_file.camelize,
150
+ file_name: "#{File.dirname(path)}/#{path.underscore}.rb",
151
+ title: main_file.titleize,
152
+ width: args[0],
153
+ height: args[1],
154
+ mode: args[2]
155
+ }
156
+ @with_size = @param[:width] && @param[:width].match(ALL_DIGITS) &&
157
+ @param[:height] && @param[:height].match(ALL_DIGITS)
158
+ template = @param[:mode].nil? ? class_template : class_template_mode
159
+ SketchWriter.new(template, @param)
91
160
  end
92
161
  end
93
162
 
94
163
  # This class creates a ruby-processing class that mimics java inner class
95
164
  class Inner < Creator
165
+ def inner_class_template
166
+ %{
167
+ class <%=@name%>
168
+ include_module Processing::Proxy
169
+
170
+ end
171
+ }
172
+ end
96
173
  # Create a blank sketch, given a path.
97
174
  def create!(path, _args_)
98
175
  return usage if /\?/ =~ path || /--help/ =~ path
99
176
  main_file = File.basename(path, '.rb')
100
177
  # Check to make sure that the main file doesn't exist already
101
178
  already_exist(path)
102
- @param = Param.new(
103
- main_file.camelize,
104
- main_file.underscore,
105
- main_file.titleize
106
- )
107
- template_name = 'inner_class.rb.erb'
108
- template = File.new("#{RP5_ROOT}/lib/templates/create/#{template_name}")
109
- rendered = render_erb_from_string_with_binding(template.read, binding)
110
- create_file(path, @param, rendered, "\"Inner Class\"")
179
+ @param = {
180
+ name: main_file.camelize,
181
+ file_name: "#{File.dirname(path)}/#{path.underscore}.rb",
182
+ title: main_file.titleize
183
+ }
184
+ SketchWriter.new(inner_class_template, @param)
111
185
  end
112
186
  end
113
187
  end
@@ -56,14 +56,14 @@ module Processing
56
56
 
57
57
  # Overrides Processing convenience function thread, which takes a String
58
58
  # arg (for a function) to more rubylike version, takes a block...
59
- def thread(*args, &block)
59
+ def thread(&block)
60
60
  if block_given?
61
- Thread.new *args, &block
61
+ Thread.new(&block)
62
62
  else
63
63
  fail ArgumentError, 'thread must be called with a block' , caller
64
64
  end
65
65
  end
66
-
66
+
67
67
  # Explicitly provides 'processing.org' map instance method, in which
68
68
  # value is mapped from range 1, to range 2 (NB: values are not clamped to
69
69
  # range 1). It may be better to explicitly write your own interpolate function
@@ -98,7 +98,7 @@ module Processing
98
98
  def max(*args)
99
99
  args.max { |a, b| a <=> b }
100
100
  end
101
-
101
+
102
102
  # explicitly provide 'processing.org' abs instance method
103
103
  def abs(val)
104
104
  warn 'abs(val) is deprecated use val.abs to avoid this warning'
@@ -110,7 +110,7 @@ module Processing
110
110
  warn 'ceil(val) is deprecated use val.ceil to avoid this warning'
111
111
  val.ceil
112
112
  end
113
-
113
+
114
114
  # explicitly provide 'processing.org' round instance method
115
115
  def round(val)
116
116
  warn 'round(val) is deprecated use val.round to avoid this warning'
@@ -144,37 +144,37 @@ module Processing
144
144
  warn 'radians(theta) is deprecated use theta.radians to avoid this warning'
145
145
  theta.radians
146
146
  end
147
-
147
+
148
148
  # explicitly provide 'processing.org' degrees instance method
149
149
  def degrees(theta)
150
150
  warn 'degrees(theta) is deprecated use theta.radians to avoid this warning'
151
151
  theta.degrees
152
152
  end
153
-
153
+
154
154
  # explicitly provide 'processing.org' hex instance method
155
155
  def hex(x)
156
156
  warn 'hex(x) is deprecated use x.hex to avoid this warning'
157
157
  x.hex
158
158
  end
159
-
159
+
160
160
  # explicitly provide 'processing.org' unhex instance method
161
161
  def unhex(str)
162
162
  warn 'unhex(str) is deprecated use str.to_i(base=16)'
163
163
  str.to_i(base=16)
164
164
  end
165
-
165
+
166
166
  # explicitly provide 'processing.org' binary instance method
167
167
  def binary(x)
168
168
  warn 'binary(x) is deprecated use x.to_s(2) to avoid this warning'
169
169
  x.to_s(2)
170
170
  end
171
-
171
+
172
172
  # explicitly provide 'processing.org' unbinary instance method
173
- def unhex(str)
173
+ def unbinary(str)
174
174
  warn 'unbinary(str) is deprecated use str.to_i(base=2)'
175
175
  str.to_i(base=2)
176
176
  end
177
-
177
+
178
178
  # explicitly provide 'processing.org' nf instance method
179
179
  def nf(*args)
180
180
  warn 'nf(num, digits) is deprecated use num.to_s.rjust(digits) '\
@@ -199,37 +199,35 @@ module Processing
199
199
  fail ArgumentError, 'takes 2 or 3 parameters'
200
200
  end
201
201
  end
202
-
203
202
  # explicitly provide 'processing.org' trim instance method
204
203
  def trim(str)
205
204
  warn 'deprecated use str.strip'
206
205
  str.strip
207
206
  end
208
-
207
+
209
208
  # explicitly provide 'processing.org' println instance method
210
209
  def println(str)
211
210
  warn 'deprecated use puts(str)'
212
211
  puts str
213
212
  end
214
-
213
+
215
214
  # explicitly provide 'processing.org' hour instance method
216
215
  def hour
217
216
  warn 'deprecated use t = Time.now and t.hour'
218
217
  PApplet.hour
219
218
  end
220
-
219
+
221
220
  # explicitly provide 'processing.org' second instance method
222
221
  def second
223
222
  warn 'deprecated use t = Time.now and t.sec'
224
223
  PApplet.second
225
224
  end
226
-
225
+
227
226
  # explicitly provide 'processing.org' minute instance method
228
227
  def minute
229
- 'deprecated use t = Time.now and t.min'
230
228
  PApplet.minute
231
229
  end
232
-
230
+
233
231
  # Uses PImage class method under hood
234
232
  def blend_color(c1, c2, mode)
235
233
  PImage.blendColor(c1, c2, mode)
@@ -252,9 +250,9 @@ module Processing
252
250
 
253
251
  # By default, your sketch path is the folder that your sketch is in.
254
252
  # If you'd like to do something fancy, feel free.
255
- def set_sketch_path(path = nil)
253
+ def set_sketch_path(spath = nil)
256
254
  field = @declared_fields['sketchPath']
257
- field.set_value(java_self, path || SKETCH_ROOT)
255
+ field.set_value(java_self, spath || SKETCH_ROOT)
258
256
  end
259
257
 
260
258
  # Fix java conversion problems getting the last key
@@ -53,14 +53,14 @@ module Processing
53
53
  def load_java_library(library_name)
54
54
  library_name = library_name.to_sym
55
55
  return true if @loaded_libraries[library_name]
56
- path = get_library_directory_path(library_name, 'jar')
56
+ jpath = get_library_directory_path(library_name, 'jar')
57
57
  jars = get_library_paths(library_name, 'jar')
58
58
  return false if jars.empty?
59
59
  jars.each {|jar| require jar }
60
60
 
61
- platform_specific_library_paths = get_platform_specific_library_paths(path)
62
- platform_specific_library_paths = platform_specific_library_paths.select do |path|
63
- test(?d, path) && !Dir.glob(File.join(path, '*.{so,dll,jnilib}')).empty?
61
+ platform_specific_library_paths = get_platform_specific_library_paths(jpath)
62
+ platform_specific_library_paths = platform_specific_library_paths.select do |ppath|
63
+ test(?d, ppath) && !Dir.glob(File.join(ppath, '*.{so,dll,jnilib}')).empty?
64
64
  end
65
65
 
66
66
  if !platform_specific_library_paths.empty?
@@ -106,14 +106,14 @@ module Processing
106
106
  extensions = extension ? [extension] : %w{jar rb}
107
107
  extensions.each do |ext|
108
108
  [ "#{SKETCH_ROOT}/library/#{library_name}",
109
- "#{Processing::RB_CONFIG['PROCESSING_ROOT']}/modes/java/libraries/#{library_name}/library",
109
+ "#{Processing::RP_CONFIG['PROCESSING_ROOT']}/modes/java/libraries/#{library_name}/library",
110
110
  "#{RP5_ROOT}/library/#{library_name}/library",
111
111
  "#{RP5_ROOT}/library/#{library_name}",
112
112
  "#{@sketchbook_library_path}/#{library_name}/library",
113
113
  "#{@sketchbook_library_path}/#{library_name}"
114
- ].each do |path|
115
- if File.exist?(path) && !Dir.glob(path + "/*.#{ext}").empty?
116
- return path
114
+ ].each do |jpath|
115
+ if File.exist?(jpath) && !Dir.glob(jpath + "/*.#{ext}").empty?
116
+ return jpath
117
117
  end
118
118
  end
119
119
  end
@@ -123,19 +123,19 @@ module Processing
123
123
  def find_sketchbook_path
124
124
  preferences_paths = []
125
125
  sketchbook_paths = []
126
- if sketchbook_path = Processing::RB_CONFIG['sketchbook_path']
126
+ if sketchbook_path = Processing::RP_CONFIG['sketchbook_path']
127
127
  return File.expand_path(sketchbook_path)
128
128
  else
129
129
  ["'Application Data/Processing'", 'AppData/Roaming/Processing',
130
130
  'Library/Processing', 'Documents/Processing',
131
131
  '.processing', 'sketchbook'].each do |prefix|
132
- path = "#{ENV['HOME']}/#{prefix}"
133
- pref_path = path+'/preferences.txt'
132
+ spath = "#{ENV['HOME']}/#{prefix}"
133
+ pref_path = spath + '/preferences.txt'
134
134
  if test(?f, pref_path)
135
135
  preferences_paths << pref_path
136
136
  end
137
- if test(?d, path)
138
- sketchbook_paths << path
137
+ if test(?d, spath)
138
+ sketchbook_paths << spath
139
139
  end
140
140
  end
141
141
  if !preferences_paths.empty?
@@ -34,7 +34,7 @@ module Processing
34
34
  Examples:
35
35
  rp5 setup unpack_samples
36
36
  rp5 run samples/contributed/jwishy.rb
37
- rp5 create some_new_sketch 640 480 p3d (P3D mode example)
37
+ rp5 create some_new_sketch 640 480 p3d (P3D mode example)
38
38
  rp5 create some_new_sketch 640 480 --wrap (a class wrapped default sketch)
39
39
  rp5 watch some_new_sketch.rb
40
40
 
@@ -69,13 +69,13 @@ module Processing
69
69
  # Parse the command-line options. Keep it simple.
70
70
  def parse_options(args)
71
71
  @options = OpenStruct.new
72
- @options.wrap = !args.delete('--wrap').nil?
73
- @options.inner = !args.delete('--inner').nil?
74
- @options.jruby = !args.delete('--jruby').nil?
75
- @options.nojruby = !args.delete('--nojruby').nil?
76
- @options.action = args[0] || nil
77
- @options.path = args[1] || File.basename(Dir.pwd + '.rb')
78
- @options.args = args[2..-1] || []
72
+ @options.wrap = !args.delete('--wrap').nil?
73
+ @options.inner = !args.delete('--inner').nil?
74
+ @options.jruby = !args.delete('--jruby').nil?
75
+ @options.nojruby = !args.delete('--nojruby').nil?
76
+ @options.action = args[0] || nil
77
+ @options.path = args[1] || File.basename(Dir.pwd + '.rb')
78
+ @options.args = args[2..-1] || []
79
79
  end
80
80
 
81
81
  # Create a fresh Ruby-Processing sketch, with the necessary
@@ -139,9 +139,9 @@ module Processing
139
139
  def check(proc_root, installed)
140
140
  show_version
141
141
  root = ' PROCESSING_ROOT = Not Set!!!' unless proc_root
142
- root ||= " PROCESSING_ROOT = #{Processing::RB_CONFIG['PROCESSING_ROOT']}"
142
+ root ||= " PROCESSING_ROOT = #{Processing::RP_CONFIG['PROCESSING_ROOT']}"
143
143
  puts root
144
- puts " JRUBY = #{Processing::RB_CONFIG['JRUBY']}"
144
+ puts " JRUBY = #{Processing::RP_CONFIG['JRUBY']}"
145
145
  puts " jruby-complete installed = #{installed}"
146
146
  end
147
147
 
@@ -167,7 +167,7 @@ module Processing
167
167
  def spin_up(starter_script, sketch, args)
168
168
  runner = "#{RP5_ROOT}/lib/ruby-processing/runners/#{starter_script}"
169
169
  warn('The --jruby flag is no longer required') if @options.jruby
170
- @options.nojruby = true if Processing::RB_CONFIG['JRUBY'] == 'false'
170
+ @options.nojruby = true if Processing::RP_CONFIG['JRUBY'] == 'false'
171
171
  java_args = discover_java_args(sketch)
172
172
  command = @options.nojruby ?
173
173
  ['java', java_args, '-cp', jruby_complete, 'org.jruby.Main', runner, sketch, args].flatten :
@@ -185,8 +185,8 @@ module Processing
185
185
  args += dock_icon
186
186
  if File.exist?(arg_file)
187
187
  args += File.read(arg_file).split(/\s+/)
188
- elsif Processing::RB_CONFIG['java_args']
189
- args += Processing::RB_CONFIG['java_args'].split(/\s+/)
188
+ elsif Processing::RP_CONFIG['java_args']
189
+ args += Processing::RP_CONFIG['java_args'].split(/\s+/)
190
190
  end
191
191
  args.map! { |arg| "-J#{arg}" } unless @options.nojruby
192
192
  args
@@ -231,7 +231,7 @@ module Processing
231
231
  data = {}
232
232
  path = File.expand_path("#{ENV['HOME']}/.rp5rc")
233
233
  if @os == :macosx
234
- data['PROCESSING_ROOT'] = %q(/Applications/Processing.app/Contents/Java')
234
+ data['PROCESSING_ROOT'] = %q(/Applications/Processing.app/Contents/Java)
235
235
  else
236
236
  root = "#{ENV['HOME']}/processing-2.2.1"
237
237
  data['PROCESSING_ROOT'] = root
@@ -1,3 +1,3 @@
1
1
  module RubyProcessing
2
- VERSION = '2.6.0'
2
+ VERSION = '2.6.1'
3
3
  end
@@ -0,0 +1,7 @@
1
+ def setup
2
+ <%= "size #{@width}, #{@height}" if @with_size %>
3
+ end
4
+
5
+ def draw
6
+
7
+ end
@@ -0,0 +1,7 @@
1
+ def setup
2
+ <%= "size #{@width}, #{@height}, P3D" if @with_size %>
3
+ end
4
+
5
+ def draw
6
+
7
+ end
@@ -34,7 +34,7 @@ end
34
34
  def draw
35
35
  if add_points
36
36
  @nbr_points += 1
37
- @nbr_points = min(nbr_points, KMAX_POINTS)
37
+ @nbr_points = [nbr_points, KMAX_POINTS].min
38
38
  init_sphere(nbr_points)
39
39
  end
40
40
 
@@ -52,7 +52,7 @@ end
52
52
 
53
53
  def render_globe
54
54
  push_matrix
55
- (0 .. min(nbr_points, pts.length)).each do |i|
55
+ (0 .. [nbr_points, pts.length].min).each do |i|
56
56
  lat = pts[i].lat
57
57
  lon = pts[i].lon
58
58
  push_matrix
@@ -13,7 +13,7 @@ def setup
13
13
  smooth(4)
14
14
  no_stroke
15
15
 
16
- diameter = min(width, height) * 0.75
16
+ diameter = [width, height].min * 0.75
17
17
  angles = [30, 10, 45, 35 ,60, 38, 75, 67]
18
18
  last_angle = 0.0
19
19
 
@@ -13,7 +13,7 @@ def setup
13
13
  size 640, 360
14
14
  @x = width/2
15
15
  @y = height/2
16
- @outer_radius = min(width, height) * 0.4
16
+ @outer_radius = [width, height].min * 0.4
17
17
  @inner_radius = outer_radius * 0.6
18
18
  end
19
19
 
@@ -45,8 +45,8 @@ class Hilbert
45
45
  @grammar = Grammar.new(axiom, rule)
46
46
  @production = grammar.generate gen
47
47
  @distance = size / (gen**2 - 1)
48
- @theta = radians 90
49
- @phi = radians 90
48
+ @theta = 90.radians
49
+ @phi = 90.radians
50
50
  @adj_array = [0, 0.5, 1.5, 3.5, 7.5, 15].map { |x| Vec3D.new(x * -1, x, x * -1) }
51
51
  end
52
52
 
@@ -102,7 +102,7 @@ class Handle
102
102
  (mouse_x >= x && mouse_x <= x + width && mouse_y >= y && mouse_y <= y + height)
103
103
  end
104
104
 
105
- def lock(val, minv, maxv)
106
- min(max(val, minv), maxv)
107
- end
105
+ def lock(val, first, last)
106
+ constrain(val, first, last)
107
+ end
108
108
  end
@@ -42,12 +42,11 @@ def draw
42
42
  end
43
43
 
44
44
 
45
- class HScrollbar
46
-
45
+ class HScrollbar
46
+ include Processing::Proxy
47
47
  attr_reader :swidth, :sheight, :xpos, :ypos, :spos, :newspos
48
48
  attr_reader :spos_max, :spos_min, :loose, :over, :locked, :ratio
49
49
  def initialize(xp, yp, sw, sh, l)
50
- super
51
50
  @swidth = sw
52
51
  @sheight = sh
53
52
  widthtoheight = sw - sh
@@ -68,10 +67,6 @@ class HScrollbar
68
67
  @spos = spos + (newspos - spos) / loose if (newspos - spos).abs > 1
69
68
  end
70
69
 
71
- def constrain(val, minv, maxv)
72
- min(max(val, minv), maxv)
73
- end
74
-
75
70
  def over_event?
76
71
  (mouse_x > xpos && mouse_x < xpos + swidth && mouse_y > ypos && mouse_y < ypos + sheight)
77
72
  end
@@ -14,30 +14,30 @@ def setup
14
14
 
15
15
  # Load an image from the data directory
16
16
  # Load a different image by modifying the comments
17
- img = loadImage('frontier.jpg')
17
+ img = load_image('frontier.jpg')
18
18
  image(img, 0, 0)
19
+ img.load_pixels
19
20
  @hist = Array.new(256, 0)
20
21
 
21
22
  # Calculate the histogram
22
23
  (0 ... img.width).each do |i|
23
24
  (0 ... img.height).each do |j|
24
- bright = (brightness(get(i, j))).to_i
25
+ bright = (brightness(img.pixels[j * img.width + i]))
25
26
  hist[bright] += 1
26
27
  end
27
28
  end
28
29
 
29
- # Find the largest value in the histogram using processings max function
30
- # that's why we use to java cinversion
31
- histMax = max(hist.to_java Java::int)
30
+ # Find the largest value in the histogram using ruby array max function
31
+ hist_max = hist.max
32
32
 
33
33
  stroke(255)
34
34
  # Draw half of the histogram (skip every second value)
35
35
  (0 ... img.width).step(2) do |i|
36
36
  # Map i (from 0..img.width) to a location in the histogram (0..255)
37
- which = (map(i, 0, img.width, 0, 255)).to_i
37
+ which = map(i, 0, img.width, 0, 255)
38
38
  # Convert the histogram value to a location between
39
39
  # the bottom and the top of the picture
40
- y = (map(hist[which], 0, histMax, img.height, 0)).to_i
40
+ y = map(hist[which], 0, hist_max, img.height, 0)
41
41
  line(i, img.height, i, y)
42
42
  end
43
43
  end
@@ -66,8 +66,7 @@ def update_spring
66
66
  # Set and constrain the position of top bar
67
67
  if (@move)
68
68
  @ps = mouseY - @s_height/2
69
- @ps = @min if (@ps < @min)
70
- @ps = @max if (@ps > @max)
69
+ @ps = constrain(@ps, @min, @max)
71
70
  end
72
71
  end
73
72
 
data/vendors/Rakefile CHANGED
@@ -8,7 +8,7 @@ WARNING = <<-EOS
8
8
 
9
9
  EOS
10
10
 
11
- JRUBY_VERSION = "1.7.13"
11
+ JRUBY_VERSION = "1.7.14"
12
12
 
13
13
  CLOBBER.include("jruby-complete-#{JRUBY_VERSION}.jar")
14
14
 
@@ -21,7 +21,7 @@ task :download => ["jruby-complete-#{JRUBY_VERSION}.jar"]
21
21
  file "jruby-complete-#{JRUBY_VERSION}.jar" do
22
22
  begin
23
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", "0dfca68810a5eed7f12ae2007dc2cc47554b4cc6")
24
+ check_sha1("jruby-complete-#{JRUBY_VERSION}.jar", "ad70c18834a143afa6686ebcda27351ebfef7385")
25
25
  rescue
26
26
  warn(WARNING)
27
27
  end
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.0
4
+ version: 2.6.1
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-08-14 00:00:00.000000000 Z
21
+ date: 2014-08-30 00:00:00.000000000 Z
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
24
24
  name: bundler
@@ -130,11 +130,8 @@ files:
130
130
  - lib/templates/application/lib/library/library.txt
131
131
  - lib/templates/application/run.erb
132
132
  - lib/templates/application/run.exe
133
- - lib/templates/create/basic.rb.erb
134
- - lib/templates/create/basic_mode.rb.erb
135
- - lib/templates/create/basic_wrap.rb.erb
136
- - lib/templates/create/inner_class.rb.erb
137
- - lib/templates/create/mode_wrap.rb.erb
133
+ - lib/templates/create/blank_sketch.rb.erb
134
+ - lib/templates/create/p3d_sketch.rb.erb
138
135
  - library/boids/boids.rb
139
136
  - library/control_panel/control_panel.rb
140
137
  - library/fastmath/fastmath.rb
@@ -1,10 +0,0 @@
1
- # <%= @param.file_name %>.rb
2
-
3
- def setup
4
- <%= "size #{@param.width}, #{@param.height}" if @with_size %>
5
-
6
- end
7
-
8
- def draw
9
-
10
- end
@@ -1,10 +0,0 @@
1
- # <%= @param.file_name %>.rb
2
-
3
- def setup
4
- <%= "size #{@param.width}, #{@param.height}, #{@param.mode.upcase}" if @with_size %>
5
-
6
- end
7
-
8
- def draw
9
-
10
- end
@@ -1,15 +0,0 @@
1
- # <%= @param.file_name %>.rb
2
-
3
- class <%= @param.name %> < Processing::App
4
-
5
- def setup
6
- <%= "size #{@param.width}, #{@param.height}" if @with_size %>
7
-
8
- end
9
-
10
- def draw
11
-
12
- end
13
- end
14
-
15
- <%= @param.name %>.new(x: 20, y: 30)
@@ -1,9 +0,0 @@
1
- # <%= @param.file_name %>.rb
2
-
3
- class <%= @param.name %>
4
- include Processing::Proxy
5
-
6
- def initialize
7
-
8
- end
9
- end
@@ -1,15 +0,0 @@
1
- # <%= @param.file_name %>.rb
2
-
3
- class <%= @param.name %> < Processing::App
4
-
5
- def setup
6
- <%= "size #{@param.width}, #{@param.height}, #{@param.mode.upcase}" if @with_size %>
7
-
8
- end
9
-
10
- def draw
11
-
12
- end
13
- end
14
-
15
- <%= @param.name %>.new(x: 20, y: 30)