ruby-processing 2.4.4 → 2.5.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.
Files changed (227) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rpextras.jar +0 -0
  3. data/lib/ruby-processing.rb +8 -6
  4. data/lib/ruby-processing/app.rb +54 -67
  5. data/lib/ruby-processing/config.rb +7 -7
  6. data/lib/ruby-processing/exporters/application_exporter.rb +37 -38
  7. data/lib/ruby-processing/exporters/base_exporter.rb +34 -37
  8. data/lib/ruby-processing/exporters/creator.rb +27 -25
  9. data/lib/ruby-processing/helper_methods.rb +18 -22
  10. data/lib/ruby-processing/helpers/numeric.rb +5 -6
  11. data/lib/ruby-processing/helpers/string.rb +11 -20
  12. data/lib/ruby-processing/library_loader.rb +33 -35
  13. data/lib/ruby-processing/runner.rb +118 -65
  14. data/lib/ruby-processing/runners/base.rb +21 -26
  15. data/lib/ruby-processing/runners/live.rb +3 -4
  16. data/lib/ruby-processing/runners/run.rb +1 -3
  17. data/lib/ruby-processing/runners/watch.rb +8 -8
  18. data/lib/ruby-processing/version.rb +1 -1
  19. data/lib/templates/application/lib/args.txt.erb +1 -1
  20. data/lib/templates/application/run.erb +3 -3
  21. data/library/control_panel/control_panel.rb +29 -29
  22. data/library/fastmath/fastmath.rb +3 -0
  23. data/library/file_chooser/file_chooser.rb +11 -13
  24. data/library/vecmath/vecmath.rb +6 -35
  25. data/samples/Rakefile +3 -1
  26. data/samples/configRP5/configRP5.pde +150 -0
  27. data/samples/contributed/Rakefile +6 -6
  28. data/samples/contributed/animator.rb +6 -6
  29. data/samples/contributed/bezier_playground.rb +29 -68
  30. data/samples/contributed/circle_collision.rb +6 -13
  31. data/samples/contributed/elegant_ball.rb +14 -17
  32. data/samples/contributed/empathy.rb +8 -5
  33. data/samples/contributed/fibonacci_sphere.rb +10 -49
  34. data/samples/contributed/full_screen.rb +1 -1
  35. data/samples/contributed/grapher.rb +10 -9
  36. data/samples/contributed/gravity.rb +11 -16
  37. data/samples/contributed/jwishy.rb +18 -20
  38. data/samples/contributed/quadraticvertex.rb +26 -26
  39. data/samples/external_library/java_processing/custom/landscape.rb +6 -4
  40. data/samples/external_library/java_processing/hemesh/twin_iso.rb +69 -71
  41. data/samples/external_library/java_processing/pbox2d/bumpy_surface_noise.rb +57 -0
  42. data/samples/external_library/java_processing/pbox2d/contact_test.rb +23 -0
  43. data/samples/external_library/java_processing/pbox2d/data/java_args.txt +2 -0
  44. data/samples/external_library/java_processing/pbox2d/library/custom_shape/custom_shape.rb +158 -0
  45. data/samples/external_library/java_processing/pbox2d/library/particle_system/particle_system.rb +212 -0
  46. data/samples/external_library/java_processing/pbox2d/library/surface/surface.rb +154 -0
  47. data/samples/external_library/java_processing/pbox2d/liquidy.rb +58 -0
  48. data/samples/external_library/java_processing/pbox2d/polygons.rb +58 -0
  49. data/samples/external_library/java_processing/toxiclibs/library/vbo/vbo.rb +52 -0
  50. data/samples/external_library/java_processing/toxiclibs/model_align.rb +9 -16
  51. data/samples/processing_app/basics/color/color_wheel.rb +1 -1
  52. data/samples/processing_app/basics/form/regular_polygon.rb +2 -2
  53. data/samples/processing_app/basics/form/rgb_cube.rb +2 -2
  54. data/samples/processing_app/basics/form/shape_primitives.rb +1 -1
  55. data/samples/processing_app/basics/form/star.rb +2 -2
  56. data/samples/processing_app/basics/input/clock.rb +21 -16
  57. data/samples/processing_app/basics/input/storing_input.rb +6 -6
  58. data/samples/processing_app/basics/math/additive_wave.rb +1 -1
  59. data/samples/processing_app/basics/math/sine.rb +2 -2
  60. data/samples/processing_app/basics/math/sine_cosine.rb +1 -1
  61. data/samples/processing_app/basics/math/sine_wave.rb +1 -1
  62. data/samples/processing_app/basics/objects/inheritance.rb +2 -0
  63. data/samples/processing_app/basics/objects/inheritance_two.rb +88 -0
  64. data/samples/processing_app/basics/objects/module.rb +89 -0
  65. data/samples/processing_app/{library/vecmath/drawolver.rb → basics/objects/module_two.rb} +1 -1
  66. data/samples/processing_app/basics/objects/multiple_constructors.rb +5 -0
  67. data/samples/processing_app/basics/objects/struct.rb +38 -0
  68. data/samples/processing_app/basics/structure/recursion2.rb +1 -1
  69. data/samples/processing_app/basics/transform/birds.rb +7 -10
  70. data/samples/processing_app/basics/transform/library/bird/bird.rb +3 -3
  71. data/samples/processing_app/basics/transform/rotate.rb +1 -1
  72. data/samples/processing_app/basics/transform/rotate1.rb +1 -1
  73. data/samples/processing_app/basics/transform/rotate_x_y.rb +1 -1
  74. data/samples/processing_app/demos/graphics/bezier_patch.rb +1 -38
  75. data/samples/processing_app/demos/graphics/trefoil.rb +50 -40
  76. data/samples/processing_app/demos/graphics/wiggling.rb +36 -38
  77. data/samples/processing_app/demos/performance/cubic_grid_retained.rb +14 -14
  78. data/samples/processing_app/demos/performance/esfera.rb +27 -39
  79. data/samples/processing_app/demos/performance/text_rendering.rb +1 -1
  80. data/samples/processing_app/library/fastmath/clock.rb +44 -0
  81. data/samples/processing_app/library/pdf/complex_3D.rb +26 -24
  82. data/samples/processing_app/library/vecmath/{Rakefile → arcball/Rakefile} +6 -6
  83. data/samples/processing_app/library/vecmath/arcball/arcball_box.rb +23 -0
  84. data/samples/processing_app/library/vecmath/arcball/arcball_radius.rb +23 -0
  85. data/samples/processing_app/library/vecmath/arcball/arcball_shape.rb +29 -0
  86. data/samples/processing_app/library/vecmath/{README.txt → vec2d/README.txt} +0 -0
  87. data/samples/processing_app/library/vecmath/vec2d/Rakefile +30 -0
  88. data/samples/processing_app/library/vecmath/{acceleration_with_vectors.rb → vec2d/acceleration_with_vectors.rb} +4 -5
  89. data/samples/processing_app/library/vecmath/{bouncing_ball.rb → vec2d/bouncing_ball.rb} +9 -15
  90. data/samples/processing_app/library/vecmath/{circle_collision.rb → vec2d/circle_collision.rb} +46 -51
  91. data/samples/processing_app/library/vecmath/{data → vec2d/data}/java_args.txt +0 -0
  92. data/samples/processing_app/library/vecmath/{data → vec2d/data}/sprite.png +0 -0
  93. data/samples/processing_app/library/vecmath/{data → vec2d/data}/texture.png +0 -0
  94. data/samples/processing_app/library/vecmath/{flocking.rb → vec2d/flocking.rb} +3 -6
  95. data/samples/processing_app/library/vecmath/{library → vec2d/library}/flock/flock.rb +47 -67
  96. data/samples/processing_app/library/vecmath/{library → vec2d/library}/particle/particle_system.rb +5 -5
  97. data/samples/processing_app/library/vecmath/vec2d/library/tile/tile.rb +85 -0
  98. data/samples/processing_app/library/vecmath/{morph.rb → vec2d/morph.rb} +17 -16
  99. data/samples/processing_app/library/vecmath/{multiple_particle_systems.rb → vec2d/multiple_particle_systems.rb} +11 -28
  100. data/samples/processing_app/library/vecmath/{particle_system_pshape.rb → vec2d/particle_system_pshape.rb} +4 -6
  101. data/samples/processing_app/library/vecmath/vec2d/penrose.rb +71 -0
  102. data/samples/processing_app/library/vecmath/{reflection1.rb → vec2d/reflection1.rb} +6 -6
  103. data/samples/processing_app/library/vecmath/{seeking_neural.rb → vec2d/seeking_neural.rb} +12 -16
  104. data/samples/processing_app/library/vecmath/{simple_particle_system.rb → vec2d/simple_particle_system.rb} +8 -12
  105. data/samples/processing_app/library/vecmath/{smoke_particle_system.rb → vec2d/smoke_particle_system.rb} +8 -13
  106. data/samples/processing_app/library/vecmath/{vector_math.rb → vec2d/vector_math.rb} +0 -0
  107. data/samples/processing_app/library/vecmath/{library/wiggler/wiggler.rb → vec2d/wiggle_pshape.rb} +28 -4
  108. data/samples/processing_app/library/vecmath/vec3d/Rakefile +30 -0
  109. data/samples/processing_app/library/vecmath/vec3d/drawolver.rb +86 -0
  110. data/samples/processing_app/library/vecmath/vec3d/frame_of_reference.rb +103 -0
  111. data/samples/processing_app/library/vecmath/{hilbert_fractal.rb → vec3d/hilbert_fractal.rb} +5 -33
  112. data/samples/processing_app/library/vecmath/vec3d/library/geometry/geometry.rb +3 -0
  113. data/samples/processing_app/library/vecmath/vec3d/library/geometry/lib/cylinder.rb +44 -0
  114. data/samples/processing_app/library/vecmath/vec3d/library/geometry/lib/mat4.rb +28 -0
  115. data/samples/processing_app/library/vecmath/vec3d/library/geometry/lib/plane.rb +60 -0
  116. data/samples/processing_app/library/vecmath/{library → vec3d/library}/hilbert/hilbert.rb +14 -17
  117. data/samples/processing_app/library/vecmath/{retained_menger.rb → vec3d/retained_menger.rb} +20 -55
  118. data/samples/processing_app/topics/advanced_data/Rakefile +6 -6
  119. data/samples/processing_app/topics/advanced_data/counting_words.rb +7 -7
  120. data/samples/processing_app/topics/advanced_data/data/data.xml +0 -15
  121. data/samples/processing_app/topics/advanced_data/data/struct_data.yml +5 -0
  122. data/samples/processing_app/topics/advanced_data/library/bubble/bubble.rb +8 -8
  123. data/samples/processing_app/topics/advanced_data/load_save_XML.rb +41 -42
  124. data/samples/processing_app/topics/advanced_data/load_save_json.rb +11 -11
  125. data/samples/processing_app/topics/advanced_data/load_save_struct_yaml.rb +22 -23
  126. data/samples/processing_app/topics/advanced_data/load_save_table.rb +12 -12
  127. data/samples/processing_app/topics/advanced_data/load_save_yaml.rb +10 -12
  128. data/samples/processing_app/topics/advanced_data/regex.rb +5 -6
  129. data/samples/processing_app/topics/advanced_data/threads.rb +27 -27
  130. data/samples/processing_app/topics/advanced_data/threads_two.rb +3 -2
  131. data/samples/processing_app/topics/advanced_data/word_frequency.rb +18 -16
  132. data/samples/processing_app/topics/advanced_data/yahoo_weather.rb +6 -5
  133. data/samples/processing_app/topics/animation/animated_sprite.rb +9 -7
  134. data/samples/processing_app/topics/animation/sequential.rb +19 -19
  135. data/samples/processing_app/topics/cellular_automata/library/ca/ca.rb +1 -1
  136. data/samples/processing_app/topics/cellular_automata/wolfram.rb +1 -1
  137. data/samples/processing_app/topics/create_shapes/begin_end_contour.rb +1 -1
  138. data/samples/processing_app/topics/create_shapes/library/wiggler/wiggler.rb +4 -4
  139. data/samples/processing_app/topics/create_shapes/particle_system_pshape.rb +2 -2
  140. data/samples/processing_app/topics/create_shapes/path_pshape.rb +1 -1
  141. data/samples/processing_app/topics/create_shapes/polygon_pshape_oo3.rb +1 -1
  142. data/samples/processing_app/topics/create_shapes/polygon_shape.rb +3 -3
  143. data/samples/processing_app/topics/file_io/load_file1.rb +1 -1
  144. data/samples/processing_app/topics/file_io/save_frames.rb +5 -5
  145. data/samples/processing_app/topics/file_io/save_one_image.rb +2 -2
  146. data/samples/processing_app/topics/file_io/tile_images.rb +1 -1
  147. data/samples/processing_app/topics/gui/scrollbar.rb +3 -3
  148. data/samples/processing_app/topics/image_processing/blending.rb +13 -13
  149. data/samples/processing_app/topics/image_processing/blur.rb +1 -1
  150. data/samples/processing_app/topics/image_processing/brightness.rb +1 -1
  151. data/samples/processing_app/topics/image_processing/convolution.rb +1 -1
  152. data/samples/processing_app/topics/image_processing/edge_detection.rb +4 -4
  153. data/samples/processing_app/topics/image_processing/explode.rb +1 -1
  154. data/samples/processing_app/topics/image_processing/extrusion.rb +1 -1
  155. data/samples/processing_app/topics/image_processing/histogram.rb +1 -1
  156. data/samples/processing_app/topics/image_processing/linear_image.rb +1 -1
  157. data/samples/processing_app/topics/image_processing/pixel_array.rb +1 -1
  158. data/samples/processing_app/topics/image_processing/zoom.rb +2 -2
  159. data/samples/processing_app/topics/lsystems/Rakefile +6 -6
  160. data/samples/processing_app/topics/lsystems/chequer.rb +4 -10
  161. data/samples/processing_app/topics/lsystems/csplant.rb +25 -25
  162. data/samples/processing_app/topics/lsystems/cstest.rb +9 -4
  163. data/samples/processing_app/topics/lsystems/david_tour.rb +14 -16
  164. data/samples/processing_app/topics/lsystems/koch.rb +8 -18
  165. data/samples/processing_app/topics/lsystems/library/cs_grammar/cs_grammar.rb +18 -24
  166. data/samples/processing_app/topics/lsystems/library/grammar/grammar.rb +7 -9
  167. data/samples/processing_app/topics/lsystems/library/koch/koch_fractal.rb +75 -94
  168. data/samples/processing_app/topics/lsystems/library/stochastic_grammar/stochastic_grammar.rb +11 -13
  169. data/samples/processing_app/topics/lsystems/mpeano.rb +29 -32
  170. data/samples/processing_app/topics/lsystems/peano.rb +19 -21
  171. data/samples/processing_app/topics/lsystems/penrose.rb +31 -37
  172. data/samples/processing_app/topics/lsystems/penrose_snowflake.rb +10 -15
  173. data/samples/processing_app/topics/lsystems/pentagonal.rb +20 -23
  174. data/samples/processing_app/topics/lsystems/snake_kolam.rb +13 -13
  175. data/samples/processing_app/topics/lsystems/stochastic_test.rb +25 -28
  176. data/samples/processing_app/topics/lsystems/three_d_tree.rb +25 -24
  177. data/samples/processing_app/topics/motion/bouncy_bubbles.rb +17 -17
  178. data/samples/processing_app/topics/motion/cubes_in_cube.rb +1 -3
  179. data/samples/processing_app/topics/motion/library/cube/cube.rb +2 -2
  180. data/samples/processing_app/topics/motion/reflection2.rb +1 -1
  181. data/samples/processing_app/topics/shaders/blur_filter.rb +3 -3
  182. data/samples/processing_app/topics/shaders/bw_shader.rb +3 -3
  183. data/samples/processing_app/topics/shaders/conway.rb +5 -5
  184. data/samples/processing_app/topics/shaders/deform.rb +5 -5
  185. data/samples/processing_app/topics/shaders/edge_detect.rb +3 -5
  186. data/samples/processing_app/topics/shaders/glossy_fish_eye.rb +15 -21
  187. data/samples/processing_app/topics/shaders/glsl_heightmap_noise.rb +21 -19
  188. data/samples/processing_app/topics/shaders/image_mask.rb +6 -6
  189. data/samples/processing_app/topics/shaders/landscape.rb +4 -4
  190. data/samples/processing_app/topics/shaders/monjori.rb +15 -15
  191. data/samples/processing_app/topics/shaders/nebula.rb +3 -3
  192. data/samples/processing_app/topics/shaders/sep_blur.rb +15 -15
  193. data/samples/processing_app/topics/shaders/toon_shading.rb +2 -2
  194. data/samples/processing_app/topics/simulate/chain.rb +16 -14
  195. data/samples/processing_app/topics/simulate/smoke_particle_system.rb +3 -3
  196. data/samples/processing_app/topics/vectors/acceleration_with_vectors.rb +3 -2
  197. data/samples/processing_app/topics/vectors/bouncing_ball.rb +1 -0
  198. data/samples/processing_app/topics/vectors/vector_math.rb +2 -1
  199. data/vendors/Rakefile +15 -3
  200. metadata +99 -86
  201. data/.gitignore +0 -13
  202. data/.travis.yml +0 -6
  203. data/.yardopts +0 -5
  204. data/CHANGELOG +0 -316
  205. data/CONTRIBUTING.md +0 -35
  206. data/Gemfile +0 -6
  207. data/LICENSE.md +0 -39
  208. data/README.md +0 -119
  209. data/Rakefile +0 -37
  210. data/bin/install_jruby_complete +0 -13
  211. data/lib/ruby-processing/exporters/exporters.rb +0 -7
  212. data/library/vecmath/lib/arcball.rb +0 -64
  213. data/library/vecmath/lib/quaternion.rb +0 -62
  214. data/library/vecmath/lib/vec.rb +0 -232
  215. data/ruby-processing.gemspec +0 -54
  216. data/samples/processing_app/library/pdf/.gitignore +0 -1
  217. data/samples/processing_app/library/vecmath/retained_test.rb +0 -65
  218. data/samples/processing_app/library/vecmath/retained_test2.rb +0 -65
  219. data/samples/processing_app/library/vecmath/wiggle_pshape.rb +0 -22
  220. data/test/README.md +0 -6
  221. data/test/basic.rb +0 -14
  222. data/test/draw_ex.rb +0 -12
  223. data/test/graphics.rb +0 -7
  224. data/test/p2d.rb +0 -14
  225. data/test/p3d.rb +0 -14
  226. data/test/rp5_test.rb +0 -86
  227. data/test/setup_ex.rb +0 -12
@@ -1,8 +1,8 @@
1
1
  require 'ostruct'
2
2
  require 'fileutils'
3
3
  require 'rbconfig'
4
- require_relative 'config'
5
- require_relative 'version'
4
+ require_relative '../ruby-processing/config'
5
+ require_relative '../ruby-processing/version'
6
6
 
7
7
 
8
8
  module Processing
@@ -11,47 +11,37 @@ module Processing
11
11
  # offers. Able to run, watch, live, create, app, and unpack
12
12
  class Runner
13
13
  HELP_MESSAGE = <<-EOS
14
- Version: #{RubyProcessing::VERSION}
15
-
16
- Ruby-Processing is a little shim between Processing and JRuby that helps
17
- you create sketches of code art.
18
-
19
- Usage:
20
- rp5 [run | watch | live | create [width height] | app | unpack] path/to/sketch
21
-
22
- run: run sketch once
23
- watch: watch for changes on the file and relaunch it on the fly
24
- live: launch sketch and give an interactive IRB shell
25
- create: create new sketch. Use --bare to generate simpler sketches without a class
26
- app: create an application version of the sketch
27
- unpack: unpack samples or library
28
-
29
- Common options:
30
- --nojruby: do not use the installed version of jruby, instead use our vendored
31
- jarred one (required for shader sketches, and some others).
32
-
33
- Configuration file:
34
- A YAML configuration file is located at {Processing::CONFIG_FILE_PATH}
35
-
36
- Possible options are:
37
-
38
- java_args: pass additionnals arguments to Java VM upon launching.
39
- Useful for increasing available memory (for example:
40
- -Xms256m -Xmx256m) or force 32 bits mode (-d32).
41
- sketchbook_path: specify Processing sketchbook path to load additionnal
42
- libraries
43
-
44
- Examples:
45
- rp5 unpack samples
14
+ Version: #{RubyProcessing::VERSION}
15
+
16
+ Ruby-Processing is a little shim between Processing and JRuby that helps
17
+ you create sketches of code art.
18
+
19
+ Usage:
20
+ rp5 [choice] path/to/sketch
21
+
22
+ choice:-
23
+ run: run sketch once
24
+ watch: watch for changes on the file and relaunch it on the fly
25
+ live: launch sketch and give an interactive IRB shell
26
+ create [width height]: create a new sketch.
27
+ app: create an application version of the sketch
28
+ setup: check setup, install jruby-complete, unpack samples
29
+
30
+ Common options:
31
+ --nojruby: use jruby-complete in place of an installed version of jruby
32
+ (Set [JRUBY: 'false'] in .rp5rc to make using jruby-complete default)
33
+
34
+ Examples:
35
+ rp5 setup unpack_samples
46
36
  rp5 run samples/contributed/jwishy.rb
47
37
  rp5 create some_new_sketch 640 480
48
38
  rp5 create some_new_sketch --p3d 640 480
49
39
  rp5 watch some_new_sketch.rb
50
40
 
51
- Everything Else:
41
+ Everything Else:
52
42
  http://wiki.github.com/jashkenas/ruby-processing
53
43
 
54
- EOS
44
+ EOS
55
45
 
56
46
  # Start running a ruby-processing sketch from the passed-in arguments
57
47
  def self.execute
@@ -68,7 +58,7 @@ module Processing
68
58
  when 'live' then live(@options.path, @options.args)
69
59
  when 'create' then create(@options.path, @options.args, @options.p3d)
70
60
  when 'app' then app(@options.path)
71
- when 'unpack' then unpack(@options.path)
61
+ when 'setup' then setup(@options.path)
72
62
  when /-v/ then show_version
73
63
  when /-h/ then show_help
74
64
  else
@@ -79,9 +69,9 @@ module Processing
79
69
  # Parse the command-line options. Keep it simple.
80
70
  def parse_options(args)
81
71
  @options = OpenStruct.new
82
- @options.p3d = !!args.delete('--p3d')
83
- @options.jruby = !!args.delete('--jruby')
84
- @options.nojruby = !!args.delete('--nojruby')
72
+ @options.p3d = !args.delete('--p3d').nil?
73
+ @options.jruby = !args.delete('--jruby').nil?
74
+ @options.nojruby = !args.delete('--nojruby').nil?
85
75
  @options.action = args[0] || nil
86
76
  @options.path = args[1] || File.basename(Dir.pwd + '.rb')
87
77
  @options.args = args[2..-1] || []
@@ -90,42 +80,66 @@ module Processing
90
80
  # Create a fresh Ruby-Processing sketch, with the necessary
91
81
  # boilerplate filled out.
92
82
  def create(sketch, args, p3d)
83
+ require_relative '../ruby-processing/exporters/creator'
93
84
  Processing::Creator.new.create!(sketch, args, p3d)
94
85
  end
95
86
 
96
87
  # Just simply run a ruby-processing sketch.
97
88
  def run(sketch, args)
98
- ensure_exists(sketch)
89
+ ensure_exists(sketch)
99
90
  spin_up('run.rb', sketch, args)
100
91
  end
101
92
 
102
93
  # Run a sketch, keeping an eye on it's file, and reloading
103
94
  # whenever it changes.
104
95
  def watch(sketch, args)
105
- ensure_exists(sketch)
96
+ ensure_exists(sketch)
106
97
  spin_up('watch.rb', sketch, args)
107
98
  end
108
99
 
109
100
  # Run a sketch, opening its guts to IRB, letting you play with it.
110
101
  def live(sketch, args)
111
- ensure_exists(sketch)
102
+ ensure_exists(sketch)
112
103
  spin_up('live.rb', sketch, args)
113
104
  end
114
105
 
115
106
  # Generate a cross-platform application of a given Ruby-Processing sketch.
116
107
  def app(sketch)
108
+ require_relative '../ruby-processing/exporters/application_exporter'
117
109
  Processing::ApplicationExporter.new.export!(sketch)
118
110
  end
119
111
 
120
- # Install the included samples to a given path, where you can run and
121
- # alter them to your heart's content.
122
- def unpack(dir)
123
- require 'fileutils'
124
- usage = "Usage: rp5 unpack [samples | library]"
125
- puts usage and return unless dir.match(/\A(samples|library)\Z/)
126
- FileUtils.cp_r("#{RP5_ROOT}/#{dir}", "#{Dir.pwd}/#{dir}")
112
+ def setup(choice)
113
+ usage = 'Usage: rp5 setup [check | install | unpack_samples]'
114
+ installed = File.exist?("#{RP5_ROOT}/lib/ruby/jruby-complete.jar")
115
+ proc_root = File.exist?("#{ENV['HOME']}/.rp5rc")
116
+ case choice
117
+ when /check/
118
+ check(proc_root, installed)
119
+ when /install/
120
+ system "cd #{RP5_ROOT}/vendors && rake"
121
+ if !proc_root
122
+ set_processing_root
123
+ warn 'PROCESSING_ROOT set optimistically, run check to confirm'
124
+ end
125
+ when /unpack_samples/
126
+ require 'fileutils'
127
+ FileUtils.cp_r("#{RP5_ROOT}/samples", "#{Dir.pwd}/rp_samples")
128
+ else
129
+ puts usage
130
+ end
127
131
  end
128
132
 
133
+ def check(proc_root, installed)
134
+ show_version
135
+ root = ' PROCESSING_ROOT = Not Set!!!' unless proc_root
136
+ root ||= " PROCESSING_ROOT = #{Processing::RB_CONFIG['PROCESSING_ROOT']}"
137
+ puts root
138
+ puts " JRUBY = #{Processing::RB_CONFIG['JRUBY']}"
139
+ puts " jruby-complete installed = #{installed}"
140
+ end
141
+
142
+
129
143
  # Display the current version of Ruby-Processing.
130
144
  def show_version
131
145
  puts "Ruby-Processing version #{RubyProcessing::VERSION}"
@@ -143,14 +157,16 @@ module Processing
143
157
  # starter script and passing it some arguments.
144
158
  # Unless --nojruby is passed, use the installed version of jruby, instead of
145
159
  # our vendored jarred one (vendored version is required for some sketches eg shaders).
160
+ # For people with system jruby they can use ~.rp5rc config to use option without flag
146
161
  def spin_up(starter_script, sketch, args)
147
162
  runner = "#{RP5_ROOT}/lib/ruby-processing/runners/#{starter_script}"
163
+ warn('The --jruby flag is no longer required') if @options.jruby
164
+ @options.nojruby = true if Processing::RB_CONFIG['JRUBY'] == 'false'
148
165
  java_args = discover_java_args(sketch)
149
- warn("The --jruby flag is no longer required") if @options.jruby
150
166
  command = @options.nojruby ?
151
- ['java', java_args, '-cp', jruby_complete, 'org.jruby.Main', runner, sketch, args].flatten :
152
- ['jruby', java_args, runner, sketch, args].flatten
153
- exec *command
167
+ ['java', java_args, '-cp', jruby_complete, 'org.jruby.Main', runner, sketch, args].flatten :
168
+ ['jruby', java_args, runner, sketch, args].flatten
169
+ exec(*command)
154
170
  # exec replaces the Ruby process with the JRuby one.
155
171
  end
156
172
 
@@ -163,10 +179,10 @@ module Processing
163
179
  args += dock_icon
164
180
  if File.exist?(arg_file)
165
181
  args += File.read(arg_file).split(/\s+/)
166
- elsif Processing::CONFIG["java_args"]
167
- args += Processing::CONFIG["java_args"].split(/\s+/)
182
+ elsif Processing::RB_CONFIG['java_args']
183
+ args += Processing::RB_CONFIG['java_args'].split(/\s+/)
168
184
  end
169
- args.map! {|arg| "-J#{arg}" } unless @options.nojruby
185
+ args.map! { |arg| "-J#{arg}" } unless @options.nojruby
170
186
  args
171
187
  end
172
188
 
@@ -179,18 +195,55 @@ module Processing
179
195
  if File.exist?(rcomplete)
180
196
  return rcomplete
181
197
  else
182
- warn "#{rcomplete} does not exist\nTry running `install_jruby_complete`"
183
- exit
184
- end
198
+ warn "#{rcomplete} does not exist\nTry running `rp5 setup install`"
199
+ exit
200
+ end
201
+ end
202
+
203
+ def os
204
+ @os ||=
205
+ host_os = RbConfig::CONFIG['host_os']
206
+ case host_os
207
+ when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
208
+ :windows
209
+ when /darwin|mac os/
210
+ :macosx
211
+ when /linux/
212
+ :linux
213
+ when /solaris|bsd/
214
+ :unix
215
+ else
216
+ raise "unknown os: #{host_os.inspect}"
217
+ end
218
+ end
219
+
220
+
221
+ # Optimistically set processing root
222
+ def set_processing_root
223
+ require 'psych'
224
+ os
225
+ data = {}
226
+ path = File.expand_path("#{ENV['HOME']}/.rp5rc")
227
+ if @os == :macosx
228
+ data['PROCESSING_ROOT'] = %q(/Applications/Processing.app/Contents/Java')
229
+ else
230
+ root = "#{ENV['HOME']}/processing-2.2.1"
231
+ data['PROCESSING_ROOT'] = root
232
+ end
233
+ data['JRUBY'] = %q(true)
234
+ open(path, 'w:UTF-8') {|f| f.write(data.to_yaml) }
185
235
  end
186
236
 
187
237
  # On the Mac, we can display a fat, shiny ruby in the Dock.
188
238
  def dock_icon
189
- mac ||= RbConfig::CONFIG['host_os'].match(/darwin/i)
190
- mac ||= RbConfig::CONFIG['host_os'].match(/mac/i)
191
- mac ? ["-Xdock:name=Ruby-Processing", "-Xdock:icon=#{RP5_ROOT}/lib/templates/application/Contents/Resources/sketch.icns"] : []
239
+ os
240
+ icon = []
241
+ if @os == :mac
242
+ icon << '-Xdock:name=Ruby-Processing'
243
+ icon << "-Xdock:icon=#{RP5_ROOT}/lib/templates/application/Contents/Resources/sketch.icns"
244
+ end
245
+ icon
192
246
  end
193
-
194
247
  end # class Runner
195
-
196
248
  end # module Processing
249
+
@@ -1,38 +1,36 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- $LOAD_PATH << File.expand_path(File.dirname(__FILE__) + "/../../")
4
- SKETCH_PATH = ARGV.shift unless defined? SKETCH_PATH
5
- SKETCH_ROOT = File.dirname(SKETCH_PATH) unless defined? SKETCH_ROOT
3
+ SKETCH_PATH ||= ARGV.shift
4
+ SKETCH_ROOT ||= File.dirname(SKETCH_PATH)
6
5
 
7
- require 'ruby-processing'
8
- require 'ruby-processing/app'
6
+ require_relative '../../ruby-processing'
7
+ require_relative '../../ruby-processing/app'
9
8
 
10
9
  module Processing
11
-
12
10
  # For use with "bare" sketches that don't want to define a class or methods
13
11
  SKETCH_TEMPLATE = <<-EOS
14
- class Sketch < Processing::App
15
- <% if has_methods %>
16
- <%= source %>
17
- <% else %>
18
- def setup
19
- size(DEFAULT_WIDTH, DEFAULT_HEIGHT, JAVA2D)
20
- <%= source %>
21
- no_loop
22
- end
23
- <% end %>
24
- end
12
+ class Sketch < Processing::App
13
+ <% if has_methods %>
14
+ <%= source %>
15
+ <% else %>
16
+ def setup
17
+ size(DEFAULT_WIDTH, DEFAULT_HEIGHT, JAVA2D)
18
+ <%= source %>
19
+ no_loop
20
+ end
21
+ <% end %>
22
+ end
25
23
  EOS
26
24
 
27
25
  # This method is the common entry point to run a sketch, bare or complete.
28
26
  def self.load_and_run_sketch
29
- source = self.read_sketch_source
30
- has_sketch = !!source.match(/^[^#]*< Processing::App/)
31
- has_methods = !!source.match(/^[^#]*(def\s+setup|def\s+draw)/)
27
+ source = read_sketch_source
28
+ has_sketch = !source.match(/^[^#]*< Processing::App/).nil?
29
+ has_methods = !source.match(/^[^#]*(def\s+setup|def\s+draw)/).nil?
32
30
 
33
31
  if has_sketch
34
- load File.join(SKETCH_ROOT, SKETCH_PATH)
35
- Processing::App.sketch_class.new if !$app
32
+ load File.join(SKETCH_ROOT, SKETCH_PATH)
33
+ Processing::App.sketch_class.new unless $app
36
34
  else
37
35
  require 'erb'
38
36
  code = ERB.new(SKETCH_TEMPLATE).result(binding)
@@ -41,11 +39,8 @@ module Processing
41
39
  end
42
40
  end
43
41
 
44
-
45
42
  # Read in the sketch source code. Needs to work both online and offline.
46
43
  def self.read_sketch_source
47
- source = File.read(SKETCH_PATH)
48
- source
44
+ File.read(SKETCH_PATH)
49
45
  end
50
-
51
46
  end
@@ -1,9 +1,8 @@
1
- # An IRB shell for live coding.
2
- # This flavor will either load up empty Ruby-Processing,
1
+ # An IRB shell for live coding.
2
+ # This flavor will either load up empty Ruby-Processing,
3
3
  # or will start with your sketch.
4
4
 
5
- root = File.dirname(__FILE__)
6
- require "#{root}/base.rb"
5
+ require_relative '../../ruby-processing/runners/base'
7
6
  Processing.load_and_run_sketch
8
7
 
9
8
  ARGV.clear # So that IRB doesn't try to load them as files.
@@ -1,8 +1,6 @@
1
1
  # TODO: this is crud. Windows applets are having serious
2
2
  # trouble with absolute paths.
3
3
 
4
- # root = defined?(JRUBY_APPLET) ? 'ruby-processing/runners' : File.dirname(__FILE__)
5
- root = File.dirname(__FILE__)
6
- require "#{root}/base.rb"
4
+ require_relative '../runners/base'
7
5
 
8
6
  Processing.load_and_run_sketch
@@ -1,4 +1,4 @@
1
- require "#{File.dirname(__FILE__)}/base.rb"
1
+ require_relative '../runners/base'
2
2
 
3
3
  module Processing
4
4
 
@@ -19,10 +19,10 @@ module Processing
19
19
  def start_watching
20
20
  start_runner
21
21
  loop do
22
- if @files.detect { |file| File.exist?(file) && File.stat(file).mtime > @time }
23
- puts "reloading sketch..."
22
+ if @files.find { |file| File.exist?(file) && File.stat(file).mtime > @time }
23
+ puts 'reloading sketch...'
24
24
  $app && $app.close
25
- @time = Time.now
25
+ @time = Time.now
26
26
  java.lang.System.gc
27
27
  start_runner
28
28
  reload_files_to_watch
@@ -40,17 +40,17 @@ module Processing
40
40
  puts "Backtrace:\n\t#{e.backtrace.join("\n\t")}"
41
41
  end
42
42
 
43
- def start_runner
43
+ def start_runner
44
44
  @runner.kill if @runner && @runner.alive?
45
- @runner = Thread.start do
46
- report_errors do
45
+ @runner = Thread.start do
46
+ report_errors do
47
47
  Processing.load_and_run_sketch
48
48
  end
49
49
  end
50
50
  end
51
51
 
52
52
  def reload_files_to_watch
53
- @files = ([SKETCH_PATH] + Dir.glob(File.dirname(SKETCH_PATH) + "/*.rb")).uniq
53
+ @files = ([SKETCH_PATH] + Dir.glob(File.dirname(SKETCH_PATH) + '/*.rb')).uniq
54
54
  end
55
55
  end
56
56
  end
@@ -1,3 +1,3 @@
1
1
  module RubyProcessing
2
- VERSION="2.4.4"
2
+ VERSION = '2.5.0'
3
3
  end
@@ -1,3 +1,3 @@
1
- set EXPORTED="true"
1
+ set EXPORTED='true'
2
2
  org.jruby.Main lib/ruby-processing/runners/run.rb lib/<%= @main_file %>
3
3
  <%= @windows_class_path %>
@@ -1,5 +1,5 @@
1
1
  #!/bin/sh
2
- APPDIR=$(dirname "$0")
3
- export EXPORTED="true"
4
- cd "$APPDIR/lib"
2
+ APPDIR=$(dirname '$0')
3
+ export EXPORTED='true'
4
+ cd '$APPDIR/lib'
5
5
  java -cp "<%= @linux_class_path %>" org.jruby.Main ../lib/ruby-processing/runners/run.rb <%= @main_file %>
@@ -6,7 +6,7 @@
6
6
  # (optionally) pass the range and default value.
7
7
 
8
8
  module ControlPanel
9
-
9
+
10
10
  class Slider < javax.swing.JSlider
11
11
  def initialize(control_panel, name, range, initial_value, proc=nil)
12
12
  min = range.begin * 100
@@ -25,21 +25,21 @@ module ControlPanel
25
25
  set_value(initial_value ? initial_value*100 : min)
26
26
  fire_state_changed
27
27
  end
28
-
28
+
29
29
  def value
30
30
  get_value / 100.0
31
31
  end
32
-
32
+
33
33
  def update_label(label, name, value)
34
34
  value = value.to_s
35
- value << "0" if value.length < 4
35
+ value << '0' if value.length < 4
36
36
  label.set_text "<html><br><b>#{name.to_s}: #{value}</b></html>"
37
37
  end
38
38
  end
39
-
40
-
39
+
40
+
41
41
  class Menu < javax.swing.JComboBox
42
- def initialize(control_panel, name, elements, initial_value, proc=nil)
42
+ def initialize(control_panel, name, elements, initial_value, proc = nil)
43
43
  super(elements.to_java(:String))
44
44
  set_preferred_size(java.awt.Dimension.new(190, 30))
45
45
  control_panel.add_element(self, name)
@@ -49,13 +49,13 @@ module ControlPanel
49
49
  end
50
50
  set_selected_index(initial_value ? elements.index(initial_value) : 0)
51
51
  end
52
-
52
+
53
53
  def value
54
54
  get_selected_item
55
55
  end
56
56
  end
57
-
58
-
57
+
58
+
59
59
  class Checkbox < javax.swing.JCheckBox
60
60
  def initialize(control_panel, name, proc=nil)
61
61
  @control_panel = control_panel
@@ -68,13 +68,13 @@ module ControlPanel
68
68
  proc.call(value) if proc
69
69
  end
70
70
  end
71
-
71
+
72
72
  def value
73
73
  is_selected
74
74
  end
75
75
  end
76
-
77
-
76
+
77
+
78
78
  class Button < javax.swing.JButton
79
79
  def initialize(control_panel, name, proc=nil)
80
80
  super(name.to_s)
@@ -86,19 +86,19 @@ module ControlPanel
86
86
  end
87
87
  end
88
88
  end
89
-
90
-
89
+
90
+
91
91
  class Panel < javax.swing.JFrame
92
92
  java_import javax.swing.UIManager
93
93
 
94
94
  attr_accessor :elements, :panel
95
-
95
+
96
96
  def initialize
97
97
  super()
98
98
  @elements = []
99
99
  @panel = javax.swing.JPanel.new(java.awt.FlowLayout.new(1, 0, 0))
100
100
  end
101
-
101
+
102
102
  def display
103
103
  add panel
104
104
  set_size 200, 30 + (64 * elements.size)
@@ -107,7 +107,7 @@ module ControlPanel
107
107
  set_location($app.width + 10, 0) unless ($app.width + 10 > $app.displayWidth)
108
108
  panel.visible = true
109
109
  end
110
-
110
+
111
111
  def add_element(element, name, has_label=true, button=false)
112
112
  if has_label
113
113
  label = javax.swing.JLabel.new("<html><br><b>#{name}</b></html>")
@@ -117,37 +117,37 @@ module ControlPanel
117
117
  panel.add element
118
118
  return has_label ? label : nil
119
119
  end
120
-
120
+
121
121
  def remove
122
122
  remove_all
123
123
  dispose
124
124
  end
125
-
125
+
126
126
  def slider(name, range=0..100, initial_value = nil, &block)
127
127
  slider = Slider.new(self, name, range, initial_value, block || nil)
128
128
  end
129
-
129
+
130
130
  def menu(name, elements, initial_value = nil, &block)
131
131
  menu = Menu.new(self, name, elements, initial_value, block || nil)
132
132
  end
133
-
133
+
134
134
  def checkbox(name, initial_value = nil, &block)
135
135
  checkbox = Checkbox.new(self, name, block || nil)
136
136
  checkbox.do_click if initial_value == true
137
137
  end
138
-
138
+
139
139
  def button(name, &block)
140
140
  button = Button.new(self, name, block || nil)
141
141
  end
142
-
143
- def look_feel lf = "Metal"
144
- lafs = javax.swing.UIManager::getInstalledLookAndFeels.select{|info| info.getName.eql? lf}
142
+
143
+ def look_feel(lf = 'Metal')
144
+ lafs = javax.swing.UIManager::getInstalledLookAndFeels.select { |info| info.getName.eql? lf }
145
145
  javax.swing.UIManager::setLookAndFeel(lafs[0].getClassName) if lafs.size > 0
146
146
  end
147
-
147
+
148
148
  end
149
-
150
-
149
+
150
+
151
151
  module InstanceMethods
152
152
  def control_panel
153
153
  @control_panel = ControlPanel::Panel.new unless @control_panel