ruby-processing 2.4.4 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b4495d11c567dab0a4324cbb26cfb493f18e413a
4
- data.tar.gz: 49efbea8dca4fcbbc160312bb6888b38217e935d
3
+ metadata.gz: a5b8a868675fde6dc0132b818e7587a83225334c
4
+ data.tar.gz: e8df4b54e6a1cd9a20b8c0595e659540a3245f34
5
5
  SHA512:
6
- metadata.gz: c3fd10e43df37279cd790a9705ee42fec592335461f09490127097f3bf0aaa649bd9968faa86193df6bdb7dc30be4b12c1a04aa46cb2cc8aa2ae82a25b9aebee
7
- data.tar.gz: 3b01b98834983da3428190813ac6e2a1d9c834d078d578b55a9131fcaaa75978fa4eec3d7fb39137f93745149cf1c501ec5aad8983ec4806c2e064ce64f8d41c
6
+ metadata.gz: 452ebce774bac88364da71c0800ed75cabb3017282d97adf2a0cf71b421c121e162a145d56c92974e12eb7b82358d204454c599cd86dee2f06418320cac90144
7
+ data.tar.gz: e409850694f47b0b6acacd3f46d9fad87bfac2a2dca2a0ae238443828c14a7c5097f70157799f3a4501f6606cc9fcd6b4d6841161bada1985365996945ecf876
Binary file
@@ -7,7 +7,7 @@ unless defined? RP5_ROOT
7
7
  RP5_ROOT = File.expand_path(File.dirname(__FILE__) + "/../")
8
8
  end
9
9
 
10
- SKETCH_ROOT = Dir.pwd unless defined? SKETCH_ROOT
10
+ SKETCH_ROOT ||= Dir.pwd
11
11
 
12
12
  require 'ruby-processing/version'
13
13
  require 'ruby-processing/helpers/string'
@@ -17,14 +17,16 @@ require 'ruby-processing/helpers/numeric'
17
17
  module Processing
18
18
 
19
19
  def self.exported?
20
- @exported ||= ENV['EXPORTED'].eql?('true')
20
+ @exported ||= ENV['EXPORTED'].eql?('true')
21
21
  end
22
22
 
23
- # Autoload a number of constants that we may end up using.
23
+ # Autoload a number of path/constants that we may end up using.
24
+ # mri ruby does not understand ** require 'java' ** and we may otherwise call it
25
+ # from mri ruby without lazy path loading of autoload
26
+ # NB: autoload is slated for possible removal by ruby-2.2
27
+
24
28
  autoload :App, 'ruby-processing/app'
25
29
  autoload :Runner, 'ruby-processing/runner'
26
30
  autoload :Watcher, 'ruby-processing/runners/watch'
27
- autoload :Creator, 'ruby-processing/exporters/creator'
28
- autoload :BaseExporter, 'ruby-processing/exporters/base_exporter'
29
- autoload :ApplicationExporter, 'ruby-processing/exporters/application_exporter'
31
+
30
32
  end
@@ -2,13 +2,12 @@
2
2
  # This class is a thin wrapper around Processing's PApplet.
3
3
  # Most of the code here is for interfacing with Swing,
4
4
  # web applets, going fullscreen and so on.
5
-
6
5
  require 'java'
7
- require 'ruby-processing/helper_methods'
8
- require 'ruby-processing/library_loader'
9
- require 'ruby-processing/config'
6
+ require_relative '../ruby-processing/helper_methods'
7
+ require_relative '../ruby-processing/library_loader'
8
+ require_relative '../ruby-processing/config'
10
9
 
11
- Dir["#{Processing::CONFIG["PROCESSING_ROOT"]}/core/library/\*.jar"].each { |jar| require jar }
10
+ Dir["#{Processing::RB_CONFIG["PROCESSING_ROOT"]}/core/library/\*.jar"].each { |jar| require jar }
12
11
 
13
12
  # Include some core processing classes that we'd like to use:
14
13
  %w(PApplet PConstants PFont PImage PShape PShapeOBJ PShapeSVG PStyle PGraphicsJava2D PGraphics PFont PVector PMatrix2D PMatrix3D).each do |klass|
@@ -16,7 +15,7 @@ Dir["#{Processing::CONFIG["PROCESSING_ROOT"]}/core/library/\*.jar"].each { |jar|
16
15
  end
17
16
 
18
17
  module Processing
19
-
18
+
20
19
  # This is the main Ruby-Processing class, and is what you'll
21
20
  # inherit from when you create a sketch. This class can call
22
21
  # all of the methods available in Processing, and has two
@@ -27,15 +26,15 @@ module Processing
27
26
  class App < PApplet
28
27
  include Math
29
28
  include HelperMethods
30
-
29
+
31
30
  # Alias some methods for familiarity for Shoes coders.
32
31
  #attr_accessor :frame, :title
33
32
  alias_method :oval, :ellipse
34
33
  alias_method :stroke_width, :stroke_weight
35
34
  alias_method :rgb, :color
36
35
  alias_method :gray, :color
37
-
38
-
36
+
37
+
39
38
  # When certain special methods get added to the sketch, we need to let
40
39
  # Processing call them by their expected Java names.
41
40
  def self.method_added(method_name) #:nodoc:
@@ -55,13 +54,13 @@ module Processing
55
54
  alias_method methods_to_alias[method_name], method_name
56
55
  end
57
56
  end
58
-
59
-
57
+
58
+
60
59
  # Class methods that we should make available in the instance.
61
60
  [:map, :pow, :norm, :lerp, :second, :minute, :hour, :day, :month, :year,
62
- :sq, :constrain, :dist, :blend_color, :degrees, :radians, :mag, :println,
63
- :hex, :min, :max, :abs, :binary, :ceil, :nf, :nfc, :nfp, :nfs,
64
- :norm, :round, :trim, :unbinary, :unhex ].each do |meth|
61
+ :sq, :constrain, :dist, :blend_color, :degrees, :radians, :mag, :println,
62
+ :hex, :min, :max, :abs, :binary, :ceil, :nf, :nfc, :nfp, :nfs,
63
+ :norm, :round, :trim, :unbinary, :unhex ].each do |meth|
65
64
  method = <<-EOS
66
65
  def #{meth}(*args)
67
66
  self.class.#{meth}(*args)
@@ -69,49 +68,49 @@ module Processing
69
68
  EOS
70
69
  eval method
71
70
  end
72
-
71
+
73
72
  # Handy getters and setters on the class go here:
74
73
  def self.sketch_class; @sketch_class; end
75
- @@full_screen = false
74
+ @@full_screen = false
76
75
  def self.full_screen; @@full_screen = true; end
77
76
  def full_screen?; @@full_screen; end
78
-
79
-
77
+
78
+
80
79
  # Keep track of what inherits from the Processing::App, because we're going
81
80
  # to want to instantiate one.
82
81
  def self.inherited(subclass)
83
82
  super(subclass)
84
83
  @sketch_class = subclass
85
84
  end
86
-
85
+
87
86
  def self.has_slider(*args) #:nodoc:
88
87
  raise "has_slider has been replaced with a nicer control_panel library. Check it out."
89
88
  end
90
-
89
+
91
90
  @@library_loader = LibraryLoader.new
92
91
  class << self
93
92
  def load_libraries(*args)
94
93
  @@library_loader.load_library(*args)
95
94
  end
96
- alias :load_library :load_libraries
97
-
95
+ alias :load_library :load_libraries
96
+
98
97
  def library_loaded?(library_name)
99
98
  @@library_loader.library_loaded?(library_name)
100
99
  end
101
-
100
+
102
101
  def load_ruby_library(*args)
103
102
  @@library_loader.load_ruby_library(*args)
104
103
  end
105
-
104
+
106
105
  def load_java_library(*args)
107
106
  @@library_loader.load_java_library(*args)
108
107
  end
109
108
  end
110
-
109
+
111
110
  def library_loaded?(library_name)
112
111
  self.class.library_loaded?(library_name)
113
112
  end
114
-
113
+
115
114
  # When you make a new sketch, you pass in (optionally),
116
115
  # a width, height, x, y, title, and whether or not you want to
117
116
  # run in full-screen.
@@ -125,33 +124,30 @@ module Processing
125
124
  set_sketch_path #unless Processing.online?
126
125
  mix_proxy_into_inner_classes
127
126
  #@started = false
128
-
129
- java.lang.Thread.default_uncaught_exception_handler = proc do |thread, exception|
127
+
128
+ java.lang.Thread.default_uncaught_exception_handler = proc do |_thread_, exception|
130
129
  puts(exception.class.to_s)
131
130
  puts(exception.message)
132
131
  puts(exception.backtrace.collect { |trace| "\t" + trace })
133
- close
132
+ close
134
133
  end
135
-
136
- # for the list of all available args, see
134
+
135
+ # for the list of all available args, see
137
136
  # http://processing.org/reference/
138
137
 
139
138
  args = []
140
-
141
139
  @width, @height = options[:width], options[:height]
142
-
143
- if @@full_screen || options[:full_screen]
140
+ if @@full_screen || options[:full_screen]
144
141
  @@full_screen = true
145
142
  args << "--present"
146
- end
143
+ end
147
144
  @render_mode ||= JAVA2D
148
- x = options[:x] || 0
149
- y = options[:y] || 0
150
- args << "--location=#{x}, #{y}"
151
-
152
- title = options[:title] || File.basename(SKETCH_PATH).sub(/(\.rb)$/, '').titleize
153
- args << title
154
- PApplet.run_sketch(args, self)
145
+ x = options[:x] || 0
146
+ y = options[:y] || 0
147
+ args << "--location=#{x}, #{y}"
148
+ title = options[:title] || File.basename(SKETCH_PATH).sub(/(\.rb)$/, '').titleize
149
+ args << title
150
+ PApplet.run_sketch(args, self)
155
151
  #end
156
152
  end
157
153
 
@@ -167,34 +163,33 @@ module Processing
167
163
  end
168
164
  end
169
165
  super(*args)
170
- end
171
-
166
+ end
167
+
172
168
  # Make sure we set the size if we set it before we start the animation thread.
173
169
  def start
174
170
  self.size(@width, @height) if @width && @height
175
171
  super()
176
172
  end
177
-
173
+
178
174
  # Provide a loggable string to represent this sketch.
179
175
  def inspect
180
176
  "#<Processing::App:#{self.class}:#{@title}>"
181
177
  end
182
-
183
-
178
+
184
179
  # Cleanly close and shutter a running sketch.
185
180
  def close
186
- control_panel.remove if respond_to?(:control_panel)
187
- self.dispose
188
- self.frame.dispose
181
+ control_panel.remove if respond_to?(:control_panel)
182
+ self.dispose
183
+ self.frame.dispose
189
184
  end
190
-
191
-
192
- private
193
-
185
+
186
+
187
+ private
188
+
194
189
  # Mix the Processing::Proxy into any inner classes defined for the
195
190
  # sketch, attempting to mimic the behavior of Java's inner classes.
196
191
  def mix_proxy_into_inner_classes
197
-
192
+
198
193
  klass = Processing::App.sketch_class
199
194
  klass.constants.each do |name|
200
195
  const = klass.const_get name
@@ -202,16 +197,13 @@ module Processing
202
197
  const.class_eval 'include Processing::Proxy'
203
198
  end
204
199
  end
205
-
206
200
  end # Processing::App
207
-
208
-
201
+
209
202
  # This module will get automatically mixed in to any inner class of
210
203
  # a Processing::App, in order to mimic Java's inner classes, which have
211
204
  # unfettered access to the methods defined in the surrounding class.
212
205
  module Proxy
213
206
  include Math
214
-
215
207
  # Generate the list of method names that we'd like to proxy for inner classes.
216
208
  # Nothing camelCased, nothing __internal__, just the Processing API.
217
209
  def self.desired_method_names(inner_class)
@@ -221,8 +213,7 @@ module Processing
221
213
  methods = Processing::App.public_instance_methods
222
214
  methods.reject {|m| unwanted.include?(m) || bad_method.match(m) || inner_class.method_defined?(m) }
223
215
  end
224
-
225
-
216
+
226
217
  # Proxy methods through to the sketch.
227
218
  def self.proxy_methods(inner_class)
228
219
  code = desired_method_names(inner_class).inject('') do |code, method|
@@ -238,8 +229,7 @@ module Processing
238
229
  end
239
230
  inner_class.class_eval(code)
240
231
  end
241
-
242
-
232
+
243
233
  # Proxy the sketch's constants on to the inner classes.
244
234
  def self.proxy_constants(inner_class)
245
235
  Processing::App.constants.each do |name|
@@ -247,14 +237,11 @@ module Processing
247
237
  inner_class.const_set(name, Processing::App.const_get(name))
248
238
  end
249
239
  end
250
-
251
-
240
+
252
241
  # Don't do all of the work unless we have an inner class that needs it.
253
242
  def self.included(inner_class)
254
243
  proxy_methods(inner_class)
255
244
  proxy_constants(inner_class)
256
245
  end
257
-
258
246
  end # Processing::Proxy
259
-
260
247
  end # Processing
@@ -3,15 +3,15 @@ require 'psych'
3
3
  module Processing
4
4
 
5
5
  if Processing.exported?
6
- CONFIG = {'PROCESSING_ROOT' => RP5_ROOT}
7
- end
6
+ RB_CONFIG = { 'PROCESSING_ROOT' => RP5_ROOT, 'JRUBY' => 'false' }
7
+ end
8
8
 
9
- unless defined? CONFIG
9
+ unless defined? RB_CONFIG
10
10
  begin
11
- CONFIG_FILE_PATH=File.expand_path("~/.rp5rc")
12
- CONFIG = (Psych.load_file(CONFIG_FILE_PATH))
13
- rescue
14
- warn("WARNING: you need to set PROCESSING_ROOT in ~/.rp5rc")
11
+ CONFIG_FILE_PATH=File.expand_path('~/.rp5rc')
12
+ RB_CONFIG = (Psych.load_file(CONFIG_FILE_PATH))
13
+ rescue
14
+ warn('WARNING: you need to set PROCESSING_ROOT in ~/.rp5rc')
15
15
  end
16
16
  end
17
17
  end
@@ -1,96 +1,95 @@
1
1
  require 'rbconfig'
2
2
 
3
3
  module Processing
4
-
5
- # A utility class to export Ruby-Processing sketches as
4
+ require_relative '../../ruby-processing/exporters/base_exporter'
5
+ # A utility class to export Ruby-Processing sketches as
6
6
  # Mac/Win/Nix Applications.
7
7
  class ApplicationExporter < BaseExporter
8
-
8
+
9
9
  USAGE = <<-EOS
10
-
10
+
11
11
  The application exporter will generate a Mac application for you.
12
12
  Usage: script/application <path_to_sketch>
13
- Example: script/applet samples/jwishy.rb
13
+ Example: script/applet samples/jwishy.rb
14
14
  Probably won't work with Oracle Java on Mac
15
-
15
+
16
16
  EOS
17
-
17
+
18
18
  def export!(sketch)
19
19
  # Check to make sure that the main file exists
20
20
  @main_file_path, @main_file, @main_folder = *get_main_file(sketch)
21
- usage( @main_file_path && File.exist?(@main_file_path) )
22
-
21
+ usage(@main_file_path && File.exist?(@main_file_path))
22
+
23
23
  extract_information
24
-
24
+
25
25
  compute_destination_name
26
-
26
+
27
27
  wipe_and_recreate_destination
28
-
28
+
29
29
  copy_over_necessary_files
30
-
30
+
31
31
  calculate_substitutions
32
-
32
+
33
33
  create_executables
34
-
34
+
35
35
  symlink_library_into_place
36
36
  end
37
-
37
+
38
38
  def compute_destination_name
39
39
  @dest = "#{@title}.app"
40
40
  end
41
-
41
+
42
42
  def copy_over_necessary_files
43
- @prefix = "lib"
43
+ @prefix = 'lib'
44
44
  cp_r(Dir["#{RP5_ROOT}/lib/templates/application/{*,**}"], @dest)
45
45
  @necessary_files = [@main_file_path]
46
- @necessary_files += Dir["#{CONFIG["PROCESSING_ROOT"]}/core/library/{*,**}"]
46
+ @necessary_files += Dir["#{RB_CONFIG['PROCESSING_ROOT']}/core/library/{*,**}"]
47
47
  @necessary_files += Dir["#{RP5_ROOT}/lib/{*,**}"]
48
48
  @necessary_files += @real_requires
49
- NECESSARY_FOLDERS.each do |folder|
49
+ NECESSARY_FOLDERS.each do |folder|
50
50
  resource_path = File.join(@main_folder, folder)
51
51
  @necessary_files << resource_path if File.exist?(resource_path)
52
52
  end
53
53
  @necessary_files.uniq!
54
54
  cp_r(@necessary_files, File.join(@dest, @prefix))
55
- cp_r(@libraries, File.join(@dest, @prefix, "library")) unless @libraries.empty?
55
+ cp_r(@libraries, File.join(@dest, @prefix, 'library')) unless @libraries.empty?
56
56
  # Then move the icon
57
- 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
57
+ 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
59
  end
60
-
60
+
61
61
  def calculate_substitutions
62
62
  file_list = ['lib/ruby/jruby-complete.jar']
63
- @class_path = file_list.map {|f| "$JAVAROOT/" + f.sub(@prefix+"/", "") }.join(":")
64
- @linux_class_path = ".:../lib/ruby/*:../lib/*:../lib/library/*"
65
- @windows_class_path = ".;../lib/ruby/*;../lib/*;../lib/library/*"
63
+ @class_path = file_list.map { |f| '$JAVAROOT/' + f.sub(@prefix+'/', '') }.join(':')
64
+ @linux_class_path = '.:../lib/ruby/*:../lib/*:../lib/library/*'
65
+ @windows_class_path = '.;../lib/ruby/*;../lib/*;../lib/library/*'
66
66
  end
67
-
67
+
68
68
  def create_executables
69
69
  render_erb_in_path_with_binding(@dest, binding, :delete => true)
70
- rm Dir.glob(@dest + "/**/*.java")
71
- runnable = @dest + "/" + File.basename(@main_file, ".rb")
72
- move @dest + "/run", runnable
73
- move @dest + "/run.exe", "#{runnable}.exe"
70
+ rm Dir.glob(@dest + '/**/*.java')
71
+ runnable = @dest + '/' + File.basename(@main_file, '.rb')
72
+ move @dest + '/run', runnable
73
+ move @dest + '/run.exe', "#{runnable}.exe"
74
74
  chmod 0755, runnable
75
75
  chmod 0755, "#{runnable}.exe"
76
76
  chmod 0755, File.join(@dest, 'Contents', 'MacOS', 'JavaApplicationStub')
77
77
  end
78
-
78
+
79
79
  def symlink_library_into_place
80
- cd @dest + "/Contents/Resources"
80
+ cd @dest + '/Contents/Resources'
81
81
  # Poor ol' windows can't symlink.
82
82
  # TODO...
83
- win ||= RbConfig::CONFIG['host_os'].match(/mswin/i)
83
+ win ||= RbConfig::CONFIG['host_os'].match(/mswin/i)
84
84
  win ||= RbConfig::CONFIG['host_os'].match(/windows/i)
85
- puts "\n[warning] Applications exported from Windows won't run on Macs...\n" if win
85
+ puts "\n[warning] Applications exported from Windows won't run on Macs...\n" if win
86
86
  ln_s('../../lib', 'Java') unless win
87
87
  end
88
-
88
+
89
89
  def usage(predicate)
90
90
  return if predicate
91
91
  puts USAGE
92
92
  exit
93
93
  end
94
-
95
94
  end
96
95
  end