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
|
@@ -10,10 +10,10 @@ attr_reader :star
|
|
|
10
10
|
|
|
11
11
|
def setup
|
|
12
12
|
size(640, 360, P2D)
|
|
13
|
-
smooth
|
|
13
|
+
smooth
|
|
14
14
|
# First create the shape
|
|
15
|
-
@star = create_shape
|
|
16
|
-
star.begin_shape
|
|
15
|
+
@star = create_shape
|
|
16
|
+
star.begin_shape
|
|
17
17
|
# You can set fill and stroke
|
|
18
18
|
star.fill(102)
|
|
19
19
|
star.stroke(255)
|
|
@@ -19,7 +19,7 @@ def setup
|
|
|
19
19
|
# The use of vanilla processing load_strings convenience method is
|
|
20
20
|
# of dubious value in ruby processing when you can do this
|
|
21
21
|
|
|
22
|
-
File.open(
|
|
22
|
+
File.open('data/positions.txt').each_line do |line|
|
|
23
23
|
points << line.split(/\t/).map! { |i| i.to_i * 2 }
|
|
24
24
|
end
|
|
25
25
|
end
|
|
@@ -14,7 +14,7 @@ def setup
|
|
|
14
14
|
size(640, 360)
|
|
15
15
|
smooth
|
|
16
16
|
@recording = false
|
|
17
|
-
directory =
|
|
17
|
+
directory = 'output'
|
|
18
18
|
Dir::mkdir(directory) unless File.exist?(directory)
|
|
19
19
|
end
|
|
20
20
|
|
|
@@ -23,7 +23,7 @@ def draw
|
|
|
23
23
|
|
|
24
24
|
# An arbitrary oscillating rotating animation
|
|
25
25
|
# so that we have something to render
|
|
26
|
-
(0 ...
|
|
26
|
+
(0 ... TAU).step(0.2) do |a|
|
|
27
27
|
push_matrix
|
|
28
28
|
translate(width/2, height/2)
|
|
29
29
|
rotate(a+sin(frame_count*0.004*a))
|
|
@@ -36,7 +36,7 @@ def draw
|
|
|
36
36
|
# The number signs (#) indicate to Processing to
|
|
37
37
|
# number the files automatically
|
|
38
38
|
if (recording)
|
|
39
|
-
save_frame(
|
|
39
|
+
save_frame('output/frames####.png'.to_java)
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
# Let's draw some stuff to tell us what is happening
|
|
@@ -45,9 +45,9 @@ def draw
|
|
|
45
45
|
textAlign(CENTER)
|
|
46
46
|
fill(255)
|
|
47
47
|
if (!recording)
|
|
48
|
-
text(
|
|
48
|
+
text('Press r to start recording.', width/2, height-24)
|
|
49
49
|
else
|
|
50
|
-
text(
|
|
50
|
+
text('Press r to stop recording.', width/2, height-24)
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
# A red dot for when we are recording
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
#
|
|
4
4
|
# The save function allows you to save an image from the
|
|
5
5
|
# display window. In this example, save is run when a mouse
|
|
6
|
-
# button is pressed. The image
|
|
6
|
+
# button is pressed. The image 'line.tif' is saved to the
|
|
7
7
|
# same folder as the sketch's program file.
|
|
8
8
|
#
|
|
9
9
|
|
|
@@ -18,5 +18,5 @@ def draw
|
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def mouse_pressed
|
|
21
|
-
save(
|
|
21
|
+
save('line.tif')
|
|
22
22
|
end
|
|
@@ -15,8 +15,8 @@ def setup
|
|
|
15
15
|
@hs2 = HScrollbar.new(0, height/2+8, width, 16, 16)
|
|
16
16
|
|
|
17
17
|
# Load images
|
|
18
|
-
@img1 = loadImage(
|
|
19
|
-
@img2 = loadImage(
|
|
18
|
+
@img1 = loadImage('seedTop.jpg')
|
|
19
|
+
@img2 = loadImage('seedBottom.jpg')
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def draw
|
|
@@ -47,7 +47,7 @@ class HScrollbar
|
|
|
47
47
|
attr_reader :swidth, :sheight, :xpos, :ypos, :spos, :newspos
|
|
48
48
|
attr_reader :spos_max, :spos_min, :loose, :over, :locked, :ratio
|
|
49
49
|
def initialize(xp, yp, sw, sh, l)
|
|
50
|
-
super
|
|
50
|
+
super
|
|
51
51
|
@swidth = sw
|
|
52
52
|
@sheight = sh
|
|
53
53
|
widthtoheight = sw - sh
|
|
@@ -14,9 +14,9 @@ attr_reader :img1, :img2, :pic_alpha, :name, :sel_mode
|
|
|
14
14
|
|
|
15
15
|
def setup
|
|
16
16
|
size(640, 360, P3D)
|
|
17
|
-
@img1 = loadImage(
|
|
18
|
-
@img2 = loadImage(
|
|
19
|
-
@name =
|
|
17
|
+
@img1 = loadImage('layer1.jpg')
|
|
18
|
+
@img2 = loadImage('layer2.jpg')
|
|
19
|
+
@name = 'REPLACE'
|
|
20
20
|
noStroke
|
|
21
21
|
@sel_mode = REPLACE
|
|
22
22
|
end
|
|
@@ -44,34 +44,34 @@ end
|
|
|
44
44
|
def mouse_pressed
|
|
45
45
|
if (sel_mode == REPLACE)
|
|
46
46
|
@sel_mode = BLEND
|
|
47
|
-
@name =
|
|
47
|
+
@name = 'BLEND'
|
|
48
48
|
elsif (sel_mode == BLEND)
|
|
49
49
|
@sel_mode = ADD
|
|
50
|
-
@name =
|
|
50
|
+
@name = 'ADD'
|
|
51
51
|
elsif (sel_mode == ADD)
|
|
52
52
|
@sel_mode = SUBTRACT
|
|
53
|
-
@name =
|
|
53
|
+
@name = 'SUBTRACT'
|
|
54
54
|
elsif (sel_mode == SUBTRACT)
|
|
55
55
|
@sel_mode = LIGHTEST
|
|
56
|
-
@name =
|
|
56
|
+
@name = 'LIGHTEST'
|
|
57
57
|
elsif (sel_mode == LIGHTEST)
|
|
58
58
|
@sel_mode = DARKEST
|
|
59
|
-
@name =
|
|
59
|
+
@name = 'DARKEST'
|
|
60
60
|
elsif (sel_mode == DARKEST)
|
|
61
61
|
@sel_mode = DIFFERENCE
|
|
62
|
-
@name =
|
|
62
|
+
@name = 'DIFFERENCE'
|
|
63
63
|
elsif (sel_mode == DIFFERENCE)
|
|
64
64
|
@sel_mode = EXCLUSION
|
|
65
|
-
@name =
|
|
65
|
+
@name = 'EXCLUSION'
|
|
66
66
|
elsif (sel_mode == EXCLUSION)
|
|
67
67
|
@sel_mode = MULTIPLY
|
|
68
|
-
@name =
|
|
68
|
+
@name = 'MULTIPLY'
|
|
69
69
|
elsif (sel_mode == MULTIPLY)
|
|
70
70
|
@sel_mode = SCREEN
|
|
71
|
-
@name =
|
|
71
|
+
@name = 'SCREEN'
|
|
72
72
|
elsif (sel_mode == SCREEN)
|
|
73
73
|
@sel_mode = REPLACE
|
|
74
|
-
@name =
|
|
74
|
+
@name = 'REPLACE'
|
|
75
75
|
end
|
|
76
76
|
end
|
|
77
77
|
|
|
@@ -13,7 +13,7 @@ attr_reader :img
|
|
|
13
13
|
def setup
|
|
14
14
|
size(640, 360)
|
|
15
15
|
frame_rate(30)
|
|
16
|
-
@img = load_image(
|
|
16
|
+
@img = load_image('moon-wide.jpg')
|
|
17
17
|
img.load_pixels
|
|
18
18
|
# Only need to load the pixels[] array once, because we're only
|
|
19
19
|
# manipulating pixels[] inside draw, not drawing shapes.
|
|
@@ -12,13 +12,13 @@ attr_reader :img
|
|
|
12
12
|
|
|
13
13
|
def setup
|
|
14
14
|
size(640, 360)
|
|
15
|
-
@img = load_image(
|
|
16
|
-
noLoop
|
|
15
|
+
@img = load_image('moon.jpg') # Load the original image
|
|
16
|
+
noLoop
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def draw
|
|
20
20
|
image(img, 0, 0) # Displays the image from point (0,0)
|
|
21
|
-
img.load_pixels
|
|
21
|
+
img.load_pixels
|
|
22
22
|
# Create an opaque image of the same size as the original
|
|
23
23
|
edge_img = create_image(img.width, img.height, RGB)
|
|
24
24
|
# Loop through every pixel in the image
|
|
@@ -41,7 +41,7 @@ def draw
|
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
43
|
# State that there are changes to edge_img.pixels[]
|
|
44
|
-
edge_img.update_pixels
|
|
44
|
+
edge_img.update_pixels
|
|
45
45
|
image(edge_img, width/2, 0) # Draw the new image
|
|
46
46
|
end
|
|
47
47
|
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
# Simple demo Rakefile to autorun samples in current directory
|
|
2
2
|
# adjust path to rp5 executable, and or opts as required
|
|
3
3
|
|
|
4
|
-
SAMPLES_DIR=
|
|
4
|
+
SAMPLES_DIR = './'
|
|
5
5
|
|
|
6
6
|
desc 'run demo'
|
|
7
|
-
task :
|
|
7
|
+
task default: [:demo]
|
|
8
8
|
|
|
9
9
|
desc 'demo'
|
|
10
10
|
task :demo do
|
|
11
|
-
samples_list.shuffle.each{|sample| run_sample sample}
|
|
11
|
+
samples_list.shuffle.each{ |sample| run_sample sample }
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def samples_list
|
|
15
15
|
files = []
|
|
16
16
|
Dir.chdir(SAMPLES_DIR)
|
|
17
|
-
Dir.glob(
|
|
17
|
+
Dir.glob('*.rb').each do |file|
|
|
18
18
|
files << File.join(SAMPLES_DIR, file)
|
|
19
19
|
end
|
|
20
20
|
return files
|
|
@@ -22,9 +22,9 @@ end
|
|
|
22
22
|
|
|
23
23
|
def run_sample(sample_name)
|
|
24
24
|
puts "Running #{sample_name}...quit to run next sample"
|
|
25
|
-
open("|rp5 run #{sample_name}",
|
|
25
|
+
open("|rp5 run #{sample_name}", 'r') do |io|
|
|
26
26
|
while l = io.gets
|
|
27
|
-
puts(l.chop)
|
|
27
|
+
puts(l.chop)
|
|
28
28
|
end
|
|
29
29
|
end
|
|
30
30
|
end
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
# Lindenmayer System in ruby-processing by Martin Prout
|
|
4
4
|
########################################################
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
load_libraries 'grammar'
|
|
6
|
+
load_library :grammar
|
|
8
7
|
|
|
9
8
|
attr_reader :chequer
|
|
10
9
|
|
|
@@ -22,22 +21,17 @@ end
|
|
|
22
21
|
|
|
23
22
|
class Chequer
|
|
24
23
|
include Processing::Proxy
|
|
25
|
-
import 'grammar'
|
|
26
24
|
attr_accessor :axiom, :grammar, :production, :draw_length, :theta, :xpos, :ypos
|
|
27
25
|
DELTA = HALF_PI
|
|
28
26
|
|
|
29
|
-
def initialize
|
|
27
|
+
def initialize(xpos, ypos)
|
|
30
28
|
@xpos = xpos
|
|
31
29
|
@ypos = ypos
|
|
32
|
-
@axiom =
|
|
33
|
-
@grammar = Grammar.new(
|
|
34
|
-
axiom,
|
|
35
|
-
{"F" => "FF-F-F-F-FF"} # Rules
|
|
36
|
-
)
|
|
30
|
+
@axiom = 'F-F-F-F' # Axiom
|
|
31
|
+
@grammar = Grammar.new(axiom, 'F' => 'FF-F-F-F-FF')
|
|
37
32
|
@draw_length = 500
|
|
38
33
|
stroke 0, 255, 0
|
|
39
34
|
stroke_weight 2
|
|
40
|
-
|
|
41
35
|
@theta = 0
|
|
42
36
|
end
|
|
43
37
|
|
|
@@ -3,12 +3,15 @@
|
|
|
3
3
|
# A 3D Plant implemented using a Context Sensitive
|
|
4
4
|
# Lindenmayer System in ruby-processing
|
|
5
5
|
# by Martin Prout (30 January 2013)
|
|
6
|
+
# Hold down 'y' key and drag mouse to rotate about y axis
|
|
6
7
|
########################################################
|
|
7
8
|
|
|
9
|
+
load_libraries :cs_grammar, :vecmath
|
|
8
10
|
attr_reader :csplant
|
|
9
11
|
|
|
10
12
|
def setup
|
|
11
13
|
size 800, 800, P3D
|
|
14
|
+
ArcBall.init(self)
|
|
12
15
|
@csplant = CSPlant.new(height)
|
|
13
16
|
csplant.create_grammar 5
|
|
14
17
|
no_stroke
|
|
@@ -17,8 +20,7 @@ end
|
|
|
17
20
|
def draw
|
|
18
21
|
background 0
|
|
19
22
|
lights
|
|
20
|
-
translate(
|
|
21
|
-
rotate_y QUARTER_PI
|
|
23
|
+
translate(0, height*0.3)
|
|
22
24
|
csplant.render
|
|
23
25
|
end
|
|
24
26
|
|
|
@@ -26,63 +28,61 @@ end
|
|
|
26
28
|
# CSPlant
|
|
27
29
|
############
|
|
28
30
|
|
|
29
|
-
load_libraries 'cs_grammar'
|
|
30
|
-
|
|
31
31
|
class CSPlant
|
|
32
32
|
include Processing::Proxy
|
|
33
|
-
|
|
34
|
-
IGNORE =
|
|
33
|
+
|
|
34
|
+
IGNORE = '[]+-^&3'
|
|
35
35
|
attr_reader :grammar, :axiom, :production, :premis, :rule,
|
|
36
36
|
:theta, :scale_factor, :len, :phi, :len
|
|
37
37
|
|
|
38
38
|
def initialize(len)
|
|
39
|
-
@axiom =
|
|
39
|
+
@axiom = 'F'
|
|
40
40
|
@grammar = Grammar.new(
|
|
41
41
|
axiom,
|
|
42
42
|
{
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
'F' => 'F[-EF[3&A]]E[+F[3^A]]',
|
|
44
|
+
'F<E' => 'F[&F[3+A]][^F[3-A]]'
|
|
45
45
|
},
|
|
46
|
-
IGNORE
|
|
46
|
+
IGNORE
|
|
47
47
|
)
|
|
48
48
|
@production = axiom
|
|
49
49
|
@len = len
|
|
50
50
|
@theta = radians 25
|
|
51
51
|
@phi = radians 25
|
|
52
|
-
no_stroke
|
|
52
|
+
no_stroke
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
-
def render
|
|
55
|
+
def render
|
|
56
56
|
fill(0, 75, 152)
|
|
57
57
|
light_specular(204, 204, 204)
|
|
58
58
|
specular(255, 255, 255)
|
|
59
59
|
shininess(1.0)
|
|
60
60
|
repeat = 1
|
|
61
61
|
production.each_char do |ch|
|
|
62
|
-
case
|
|
63
|
-
when
|
|
64
|
-
translate(0, len
|
|
65
|
-
box(len/9, len, len/9)
|
|
66
|
-
translate(0, len
|
|
67
|
-
when
|
|
62
|
+
case ch
|
|
63
|
+
when 'F'
|
|
64
|
+
translate(0, len / -2, 0)
|
|
65
|
+
box(len / 9, len, len / 9)
|
|
66
|
+
translate(0, len / -2, 0)
|
|
67
|
+
when '+'
|
|
68
68
|
rotateX(-theta * repeat)
|
|
69
69
|
repeat = 1
|
|
70
|
-
when
|
|
70
|
+
when '-'
|
|
71
71
|
rotateX(theta * repeat)
|
|
72
72
|
repeat = 1
|
|
73
|
-
when
|
|
73
|
+
when '&'
|
|
74
74
|
rotateZ(-phi * repeat)
|
|
75
75
|
repeat = 1
|
|
76
|
-
when
|
|
76
|
+
when '^'
|
|
77
77
|
rotateZ(phi * repeat)
|
|
78
78
|
repeat = 1
|
|
79
|
-
when
|
|
79
|
+
when '3'
|
|
80
80
|
repeat = 3
|
|
81
|
-
when
|
|
81
|
+
when '['
|
|
82
82
|
push_matrix
|
|
83
|
-
when
|
|
83
|
+
when ']'
|
|
84
84
|
pop_matrix
|
|
85
|
-
when
|
|
85
|
+
when 'E', 'A'
|
|
86
86
|
else
|
|
87
87
|
puts("character '#{ch}' not in grammar")
|
|
88
88
|
end
|