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.
- checksums.yaml +4 -4
- data/lib/rpextras.jar +0 -0
- data/lib/ruby-processing.rb +8 -6
- data/lib/ruby-processing/app.rb +54 -67
- data/lib/ruby-processing/config.rb +7 -7
- data/lib/ruby-processing/exporters/application_exporter.rb +37 -38
- data/lib/ruby-processing/exporters/base_exporter.rb +34 -37
- data/lib/ruby-processing/exporters/creator.rb +27 -25
- data/lib/ruby-processing/helper_methods.rb +18 -22
- data/lib/ruby-processing/helpers/numeric.rb +5 -6
- data/lib/ruby-processing/helpers/string.rb +11 -20
- data/lib/ruby-processing/library_loader.rb +33 -35
- data/lib/ruby-processing/runner.rb +118 -65
- data/lib/ruby-processing/runners/base.rb +21 -26
- data/lib/ruby-processing/runners/live.rb +3 -4
- data/lib/ruby-processing/runners/run.rb +1 -3
- data/lib/ruby-processing/runners/watch.rb +8 -8
- data/lib/ruby-processing/version.rb +1 -1
- data/lib/templates/application/lib/args.txt.erb +1 -1
- data/lib/templates/application/run.erb +3 -3
- data/library/control_panel/control_panel.rb +29 -29
- data/library/fastmath/fastmath.rb +3 -0
- data/library/file_chooser/file_chooser.rb +11 -13
- data/library/vecmath/vecmath.rb +6 -35
- data/samples/Rakefile +3 -1
- data/samples/configRP5/configRP5.pde +150 -0
- data/samples/contributed/Rakefile +6 -6
- data/samples/contributed/animator.rb +6 -6
- data/samples/contributed/bezier_playground.rb +29 -68
- data/samples/contributed/circle_collision.rb +6 -13
- data/samples/contributed/elegant_ball.rb +14 -17
- data/samples/contributed/empathy.rb +8 -5
- data/samples/contributed/fibonacci_sphere.rb +10 -49
- data/samples/contributed/full_screen.rb +1 -1
- data/samples/contributed/grapher.rb +10 -9
- data/samples/contributed/gravity.rb +11 -16
- data/samples/contributed/jwishy.rb +18 -20
- data/samples/contributed/quadraticvertex.rb +26 -26
- data/samples/external_library/java_processing/custom/landscape.rb +6 -4
- data/samples/external_library/java_processing/hemesh/twin_iso.rb +69 -71
- data/samples/external_library/java_processing/pbox2d/bumpy_surface_noise.rb +57 -0
- data/samples/external_library/java_processing/pbox2d/contact_test.rb +23 -0
- data/samples/external_library/java_processing/pbox2d/data/java_args.txt +2 -0
- data/samples/external_library/java_processing/pbox2d/library/custom_shape/custom_shape.rb +158 -0
- data/samples/external_library/java_processing/pbox2d/library/particle_system/particle_system.rb +212 -0
- data/samples/external_library/java_processing/pbox2d/library/surface/surface.rb +154 -0
- data/samples/external_library/java_processing/pbox2d/liquidy.rb +58 -0
- data/samples/external_library/java_processing/pbox2d/polygons.rb +58 -0
- data/samples/external_library/java_processing/toxiclibs/library/vbo/vbo.rb +52 -0
- data/samples/external_library/java_processing/toxiclibs/model_align.rb +9 -16
- data/samples/processing_app/basics/color/color_wheel.rb +1 -1
- data/samples/processing_app/basics/form/regular_polygon.rb +2 -2
- data/samples/processing_app/basics/form/rgb_cube.rb +2 -2
- data/samples/processing_app/basics/form/shape_primitives.rb +1 -1
- data/samples/processing_app/basics/form/star.rb +2 -2
- data/samples/processing_app/basics/input/clock.rb +21 -16
- data/samples/processing_app/basics/input/storing_input.rb +6 -6
- data/samples/processing_app/basics/math/additive_wave.rb +1 -1
- data/samples/processing_app/basics/math/sine.rb +2 -2
- data/samples/processing_app/basics/math/sine_cosine.rb +1 -1
- data/samples/processing_app/basics/math/sine_wave.rb +1 -1
- data/samples/processing_app/basics/objects/inheritance.rb +2 -0
- data/samples/processing_app/basics/objects/inheritance_two.rb +88 -0
- data/samples/processing_app/basics/objects/module.rb +89 -0
- data/samples/processing_app/{library/vecmath/drawolver.rb → basics/objects/module_two.rb} +1 -1
- data/samples/processing_app/basics/objects/multiple_constructors.rb +5 -0
- data/samples/processing_app/basics/objects/struct.rb +38 -0
- data/samples/processing_app/basics/structure/recursion2.rb +1 -1
- data/samples/processing_app/basics/transform/birds.rb +7 -10
- data/samples/processing_app/basics/transform/library/bird/bird.rb +3 -3
- data/samples/processing_app/basics/transform/rotate.rb +1 -1
- data/samples/processing_app/basics/transform/rotate1.rb +1 -1
- data/samples/processing_app/basics/transform/rotate_x_y.rb +1 -1
- data/samples/processing_app/demos/graphics/bezier_patch.rb +1 -38
- data/samples/processing_app/demos/graphics/trefoil.rb +50 -40
- data/samples/processing_app/demos/graphics/wiggling.rb +36 -38
- data/samples/processing_app/demos/performance/cubic_grid_retained.rb +14 -14
- data/samples/processing_app/demos/performance/esfera.rb +27 -39
- data/samples/processing_app/demos/performance/text_rendering.rb +1 -1
- data/samples/processing_app/library/fastmath/clock.rb +44 -0
- data/samples/processing_app/library/pdf/complex_3D.rb +26 -24
- data/samples/processing_app/library/vecmath/{Rakefile → arcball/Rakefile} +6 -6
- data/samples/processing_app/library/vecmath/arcball/arcball_box.rb +23 -0
- data/samples/processing_app/library/vecmath/arcball/arcball_radius.rb +23 -0
- data/samples/processing_app/library/vecmath/arcball/arcball_shape.rb +29 -0
- data/samples/processing_app/library/vecmath/{README.txt → vec2d/README.txt} +0 -0
- data/samples/processing_app/library/vecmath/vec2d/Rakefile +30 -0
- data/samples/processing_app/library/vecmath/{acceleration_with_vectors.rb → vec2d/acceleration_with_vectors.rb} +4 -5
- data/samples/processing_app/library/vecmath/{bouncing_ball.rb → vec2d/bouncing_ball.rb} +9 -15
- data/samples/processing_app/library/vecmath/{circle_collision.rb → vec2d/circle_collision.rb} +46 -51
- data/samples/processing_app/library/vecmath/{data → vec2d/data}/java_args.txt +0 -0
- data/samples/processing_app/library/vecmath/{data → vec2d/data}/sprite.png +0 -0
- data/samples/processing_app/library/vecmath/{data → vec2d/data}/texture.png +0 -0
- data/samples/processing_app/library/vecmath/{flocking.rb → vec2d/flocking.rb} +3 -6
- data/samples/processing_app/library/vecmath/{library → vec2d/library}/flock/flock.rb +47 -67
- data/samples/processing_app/library/vecmath/{library → vec2d/library}/particle/particle_system.rb +5 -5
- data/samples/processing_app/library/vecmath/vec2d/library/tile/tile.rb +85 -0
- data/samples/processing_app/library/vecmath/{morph.rb → vec2d/morph.rb} +17 -16
- data/samples/processing_app/library/vecmath/{multiple_particle_systems.rb → vec2d/multiple_particle_systems.rb} +11 -28
- data/samples/processing_app/library/vecmath/{particle_system_pshape.rb → vec2d/particle_system_pshape.rb} +4 -6
- data/samples/processing_app/library/vecmath/vec2d/penrose.rb +71 -0
- data/samples/processing_app/library/vecmath/{reflection1.rb → vec2d/reflection1.rb} +6 -6
- data/samples/processing_app/library/vecmath/{seeking_neural.rb → vec2d/seeking_neural.rb} +12 -16
- data/samples/processing_app/library/vecmath/{simple_particle_system.rb → vec2d/simple_particle_system.rb} +8 -12
- data/samples/processing_app/library/vecmath/{smoke_particle_system.rb → vec2d/smoke_particle_system.rb} +8 -13
- data/samples/processing_app/library/vecmath/{vector_math.rb → vec2d/vector_math.rb} +0 -0
- data/samples/processing_app/library/vecmath/{library/wiggler/wiggler.rb → vec2d/wiggle_pshape.rb} +28 -4
- data/samples/processing_app/library/vecmath/vec3d/Rakefile +30 -0
- data/samples/processing_app/library/vecmath/vec3d/drawolver.rb +86 -0
- data/samples/processing_app/library/vecmath/vec3d/frame_of_reference.rb +103 -0
- data/samples/processing_app/library/vecmath/{hilbert_fractal.rb → vec3d/hilbert_fractal.rb} +5 -33
- data/samples/processing_app/library/vecmath/vec3d/library/geometry/geometry.rb +3 -0
- data/samples/processing_app/library/vecmath/vec3d/library/geometry/lib/cylinder.rb +44 -0
- data/samples/processing_app/library/vecmath/vec3d/library/geometry/lib/mat4.rb +28 -0
- data/samples/processing_app/library/vecmath/vec3d/library/geometry/lib/plane.rb +60 -0
- data/samples/processing_app/library/vecmath/{library → vec3d/library}/hilbert/hilbert.rb +14 -17
- data/samples/processing_app/library/vecmath/{retained_menger.rb → vec3d/retained_menger.rb} +20 -55
- data/samples/processing_app/topics/advanced_data/Rakefile +6 -6
- data/samples/processing_app/topics/advanced_data/counting_words.rb +7 -7
- data/samples/processing_app/topics/advanced_data/data/data.xml +0 -15
- data/samples/processing_app/topics/advanced_data/data/struct_data.yml +5 -0
- data/samples/processing_app/topics/advanced_data/library/bubble/bubble.rb +8 -8
- data/samples/processing_app/topics/advanced_data/load_save_XML.rb +41 -42
- data/samples/processing_app/topics/advanced_data/load_save_json.rb +11 -11
- data/samples/processing_app/topics/advanced_data/load_save_struct_yaml.rb +22 -23
- data/samples/processing_app/topics/advanced_data/load_save_table.rb +12 -12
- data/samples/processing_app/topics/advanced_data/load_save_yaml.rb +10 -12
- data/samples/processing_app/topics/advanced_data/regex.rb +5 -6
- data/samples/processing_app/topics/advanced_data/threads.rb +27 -27
- data/samples/processing_app/topics/advanced_data/threads_two.rb +3 -2
- data/samples/processing_app/topics/advanced_data/word_frequency.rb +18 -16
- data/samples/processing_app/topics/advanced_data/yahoo_weather.rb +6 -5
- data/samples/processing_app/topics/animation/animated_sprite.rb +9 -7
- data/samples/processing_app/topics/animation/sequential.rb +19 -19
- data/samples/processing_app/topics/cellular_automata/library/ca/ca.rb +1 -1
- data/samples/processing_app/topics/cellular_automata/wolfram.rb +1 -1
- data/samples/processing_app/topics/create_shapes/begin_end_contour.rb +1 -1
- data/samples/processing_app/topics/create_shapes/library/wiggler/wiggler.rb +4 -4
- data/samples/processing_app/topics/create_shapes/particle_system_pshape.rb +2 -2
- data/samples/processing_app/topics/create_shapes/path_pshape.rb +1 -1
- data/samples/processing_app/topics/create_shapes/polygon_pshape_oo3.rb +1 -1
- data/samples/processing_app/topics/create_shapes/polygon_shape.rb +3 -3
- data/samples/processing_app/topics/file_io/load_file1.rb +1 -1
- data/samples/processing_app/topics/file_io/save_frames.rb +5 -5
- data/samples/processing_app/topics/file_io/save_one_image.rb +2 -2
- data/samples/processing_app/topics/file_io/tile_images.rb +1 -1
- data/samples/processing_app/topics/gui/scrollbar.rb +3 -3
- data/samples/processing_app/topics/image_processing/blending.rb +13 -13
- data/samples/processing_app/topics/image_processing/blur.rb +1 -1
- data/samples/processing_app/topics/image_processing/brightness.rb +1 -1
- data/samples/processing_app/topics/image_processing/convolution.rb +1 -1
- data/samples/processing_app/topics/image_processing/edge_detection.rb +4 -4
- data/samples/processing_app/topics/image_processing/explode.rb +1 -1
- data/samples/processing_app/topics/image_processing/extrusion.rb +1 -1
- data/samples/processing_app/topics/image_processing/histogram.rb +1 -1
- data/samples/processing_app/topics/image_processing/linear_image.rb +1 -1
- data/samples/processing_app/topics/image_processing/pixel_array.rb +1 -1
- data/samples/processing_app/topics/image_processing/zoom.rb +2 -2
- data/samples/processing_app/topics/lsystems/Rakefile +6 -6
- data/samples/processing_app/topics/lsystems/chequer.rb +4 -10
- data/samples/processing_app/topics/lsystems/csplant.rb +25 -25
- data/samples/processing_app/topics/lsystems/cstest.rb +9 -4
- data/samples/processing_app/topics/lsystems/david_tour.rb +14 -16
- data/samples/processing_app/topics/lsystems/koch.rb +8 -18
- data/samples/processing_app/topics/lsystems/library/cs_grammar/cs_grammar.rb +18 -24
- data/samples/processing_app/topics/lsystems/library/grammar/grammar.rb +7 -9
- data/samples/processing_app/topics/lsystems/library/koch/koch_fractal.rb +75 -94
- data/samples/processing_app/topics/lsystems/library/stochastic_grammar/stochastic_grammar.rb +11 -13
- data/samples/processing_app/topics/lsystems/mpeano.rb +29 -32
- data/samples/processing_app/topics/lsystems/peano.rb +19 -21
- data/samples/processing_app/topics/lsystems/penrose.rb +31 -37
- data/samples/processing_app/topics/lsystems/penrose_snowflake.rb +10 -15
- data/samples/processing_app/topics/lsystems/pentagonal.rb +20 -23
- data/samples/processing_app/topics/lsystems/snake_kolam.rb +13 -13
- data/samples/processing_app/topics/lsystems/stochastic_test.rb +25 -28
- data/samples/processing_app/topics/lsystems/three_d_tree.rb +25 -24
- data/samples/processing_app/topics/motion/bouncy_bubbles.rb +17 -17
- data/samples/processing_app/topics/motion/cubes_in_cube.rb +1 -3
- data/samples/processing_app/topics/motion/library/cube/cube.rb +2 -2
- data/samples/processing_app/topics/motion/reflection2.rb +1 -1
- data/samples/processing_app/topics/shaders/blur_filter.rb +3 -3
- data/samples/processing_app/topics/shaders/bw_shader.rb +3 -3
- data/samples/processing_app/topics/shaders/conway.rb +5 -5
- data/samples/processing_app/topics/shaders/deform.rb +5 -5
- data/samples/processing_app/topics/shaders/edge_detect.rb +3 -5
- data/samples/processing_app/topics/shaders/glossy_fish_eye.rb +15 -21
- data/samples/processing_app/topics/shaders/glsl_heightmap_noise.rb +21 -19
- data/samples/processing_app/topics/shaders/image_mask.rb +6 -6
- data/samples/processing_app/topics/shaders/landscape.rb +4 -4
- data/samples/processing_app/topics/shaders/monjori.rb +15 -15
- data/samples/processing_app/topics/shaders/nebula.rb +3 -3
- data/samples/processing_app/topics/shaders/sep_blur.rb +15 -15
- data/samples/processing_app/topics/shaders/toon_shading.rb +2 -2
- data/samples/processing_app/topics/simulate/chain.rb +16 -14
- data/samples/processing_app/topics/simulate/smoke_particle_system.rb +3 -3
- data/samples/processing_app/topics/vectors/acceleration_with_vectors.rb +3 -2
- data/samples/processing_app/topics/vectors/bouncing_ball.rb +1 -0
- data/samples/processing_app/topics/vectors/vector_math.rb +2 -1
- data/vendors/Rakefile +15 -3
- metadata +99 -86
- data/.gitignore +0 -13
- data/.travis.yml +0 -6
- data/.yardopts +0 -5
- data/CHANGELOG +0 -316
- data/CONTRIBUTING.md +0 -35
- data/Gemfile +0 -6
- data/LICENSE.md +0 -39
- data/README.md +0 -119
- data/Rakefile +0 -37
- data/bin/install_jruby_complete +0 -13
- data/lib/ruby-processing/exporters/exporters.rb +0 -7
- data/library/vecmath/lib/arcball.rb +0 -64
- data/library/vecmath/lib/quaternion.rb +0 -62
- data/library/vecmath/lib/vec.rb +0 -232
- data/ruby-processing.gemspec +0 -54
- data/samples/processing_app/library/pdf/.gitignore +0 -1
- data/samples/processing_app/library/vecmath/retained_test.rb +0 -65
- data/samples/processing_app/library/vecmath/retained_test2.rb +0 -65
- data/samples/processing_app/library/vecmath/wiggle_pshape.rb +0 -22
- data/test/README.md +0 -6
- data/test/basic.rb +0 -14
- data/test/draw_ex.rb +0 -12
- data/test/graphics.rb +0 -7
- data/test/p2d.rb +0 -14
- data/test/p3d.rb +0 -14
- data/test/rp5_test.rb +0 -86
- 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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
rp5 [
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
41
|
+
Everything Else:
|
|
52
42
|
http://wiki.github.com/jashkenas/ruby-processing
|
|
53
43
|
|
|
54
|
-
|
|
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 '
|
|
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 =
|
|
83
|
-
@options.jruby =
|
|
84
|
-
@options.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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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
|
-
|
|
152
|
-
|
|
153
|
-
exec
|
|
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::
|
|
167
|
-
args += Processing::
|
|
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
|
-
|
|
183
|
-
|
|
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
|
-
|
|
190
|
-
|
|
191
|
-
|
|
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
|
-
|
|
4
|
-
|
|
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
|
-
|
|
8
|
-
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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 =
|
|
30
|
-
has_sketch =
|
|
31
|
-
has_methods =
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
23
|
-
puts
|
|
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) +
|
|
53
|
+
@files = ([SKETCH_PATH] + Dir.glob(File.dirname(SKETCH_PATH) + '/*.rb')).uniq
|
|
54
54
|
end
|
|
55
55
|
end
|
|
56
56
|
end
|
|
@@ -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 <<
|
|
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
|
|
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
|