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,37 +1,37 @@
|
|
|
1
1
|
#######################################################
|
|
2
|
-
# Lindenmayer System in ruby-
|
|
3
|
-
# snake_kolam.rb
|
|
2
|
+
# Lindenmayer System in ruby-procesDegLut.sing by Martin Prout
|
|
3
|
+
# snake_kolam.rb uDegLut.sing l-systems
|
|
4
4
|
#######################################################
|
|
5
5
|
|
|
6
|
-
load_library
|
|
6
|
+
load_library :grammar, :fastmath
|
|
7
7
|
|
|
8
8
|
class SnakeKolam
|
|
9
9
|
include Processing::Proxy
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
attr_accessor :axiom, :start_length, :xpos, :ypos, :grammar, :production, :draw_length, :gen
|
|
12
12
|
XPOS = 0
|
|
13
13
|
YPOS = 1
|
|
14
14
|
ANGLE = 2
|
|
15
|
-
DELTA =
|
|
15
|
+
DELTA = 90 # degrees
|
|
16
16
|
|
|
17
17
|
def initialize xpos, ypos
|
|
18
18
|
setup_grammar
|
|
19
19
|
@start_length = 120.0
|
|
20
|
-
@theta =
|
|
20
|
+
@theta = 90 # degrees
|
|
21
21
|
@draw_length = start_length
|
|
22
22
|
@xpos = xpos
|
|
23
23
|
@ypos = ypos
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
def setup_grammar
|
|
27
|
-
@axiom =
|
|
27
|
+
@axiom = 'FX+F+FX+F'
|
|
28
28
|
@grammar = Grammar.new(
|
|
29
29
|
axiom,
|
|
30
|
-
{
|
|
30
|
+
{'X' => 'X-F-F+FX+F+FX-F-F+FX'}
|
|
31
31
|
)
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
-
def render # NB not
|
|
34
|
+
def render # NB not uDegLut.sing affine transforms here
|
|
35
35
|
turtle = [xpos, ypos, 0.0]
|
|
36
36
|
production.each do |element|
|
|
37
37
|
case element
|
|
@@ -61,13 +61,13 @@ class SnakeKolam
|
|
|
61
61
|
|
|
62
62
|
private
|
|
63
63
|
######################################################
|
|
64
|
-
# draws line
|
|
64
|
+
# draws line uDegLut.sing current turtle and length parameters
|
|
65
65
|
# returns a turtle corresponding to the new position
|
|
66
66
|
######################################################
|
|
67
67
|
|
|
68
68
|
def draw_line(turtle, length)
|
|
69
|
-
new_xpos = turtle[XPOS] + length *
|
|
70
|
-
new_ypos = turtle[YPOS] + length *
|
|
69
|
+
new_xpos = turtle[XPOS] + length * DegLut.cos(turtle[ANGLE])
|
|
70
|
+
new_ypos = turtle[YPOS] + length * DegLut.sin(turtle[ANGLE])
|
|
71
71
|
line(turtle[XPOS], turtle[YPOS], new_xpos, new_ypos)
|
|
72
72
|
turtle = [new_xpos, new_ypos, turtle[ANGLE]]
|
|
73
73
|
end
|
|
@@ -78,7 +78,7 @@ attr_reader :kolam
|
|
|
78
78
|
|
|
79
79
|
def setup
|
|
80
80
|
size 500, 500
|
|
81
|
-
@kolam = SnakeKolam.new width/8, height*0.8
|
|
81
|
+
@kolam = SnakeKolam.new width / 8, height * 0.8
|
|
82
82
|
kolam.create_grammar 3 # create grammar from rules
|
|
83
83
|
no_loop
|
|
84
84
|
end
|
|
@@ -2,54 +2,51 @@
|
|
|
2
2
|
# stochastic_test.rb
|
|
3
3
|
#
|
|
4
4
|
# Lindenmayer System in ruby-processing by Martin Prout
|
|
5
|
-
# Exploring terminals with minimum logic
|
|
5
|
+
# Exploring terminals with minimum logic
|
|
6
6
|
########################################################
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
load_library :stochastic_grammar, :fastmath
|
|
10
|
+
|
|
11
|
+
Turtle = Struct.new(:x, :y, :angle)
|
|
9
12
|
|
|
10
13
|
class StochasticPlant
|
|
11
14
|
include Processing::Proxy
|
|
12
15
|
|
|
13
|
-
attr_reader :grammar, :axiom, :draw_length, :
|
|
14
|
-
|
|
15
|
-
XPOS = 0 # placeholders for turtle array
|
|
16
|
-
YPOS = 1
|
|
17
|
-
ANGLE = 2
|
|
16
|
+
attr_reader :grammar, :axiom, :draw_length, :turtle, :production
|
|
18
17
|
|
|
19
|
-
DELTA =
|
|
18
|
+
DELTA = 23
|
|
20
19
|
|
|
21
|
-
def initialize
|
|
20
|
+
def initialize xpos, ypos
|
|
22
21
|
@draw_length = 350
|
|
23
|
-
|
|
24
|
-
@
|
|
25
|
-
@theta = HALF_PI # this way is up?
|
|
22
|
+
# use Struct as turtle
|
|
23
|
+
@turtle = Turtle.new(xpos, ypos, 90) # this way is up?
|
|
26
24
|
setup_grammar
|
|
27
25
|
end
|
|
28
26
|
|
|
29
27
|
def setup_grammar
|
|
30
|
-
@axiom =
|
|
31
|
-
@grammar = StochasticGrammar.new(axiom)
|
|
32
|
-
grammar.add_rule(
|
|
33
|
-
grammar.add_rule(
|
|
34
|
-
grammar.add_rule(
|
|
28
|
+
@axiom = 'F'
|
|
29
|
+
@grammar = StochasticGrammar.new(axiom)
|
|
30
|
+
grammar.add_rule('F', 'F[+F]F[-F]F', 0.1)
|
|
31
|
+
grammar.add_rule('F', 'F[+F]F', 0.45)
|
|
32
|
+
grammar.add_rule('F', 'F[-F]F', 0.45)
|
|
35
33
|
@production = axiom
|
|
36
34
|
end
|
|
37
35
|
|
|
38
36
|
def render
|
|
39
37
|
stack = [] # ruby array as the turtle stack
|
|
40
|
-
turtle = [xpos, ypos, theta] # ruby array as a turtle
|
|
41
38
|
production.each_char do |element|
|
|
42
39
|
case element
|
|
43
40
|
when 'F' # NB NOT using affine transforms
|
|
44
|
-
turtle = draw_line(turtle, draw_length)
|
|
41
|
+
@turtle = draw_line(turtle, draw_length)
|
|
45
42
|
when '+'
|
|
46
|
-
turtle
|
|
43
|
+
turtle.angle += DELTA
|
|
47
44
|
when '-'
|
|
48
|
-
turtle
|
|
45
|
+
turtle.angle -= DELTA
|
|
49
46
|
when '['
|
|
50
|
-
stack
|
|
47
|
+
stack << turtle.dup # push a copy of the current turtle to stack
|
|
51
48
|
when ']'
|
|
52
|
-
turtle = stack.pop # assign current turtle to an instance popped from the stack
|
|
49
|
+
@turtle = stack.pop # assign current turtle to an instance popped from the stack
|
|
53
50
|
else
|
|
54
51
|
puts "Character '#{element}' is not in grammar"
|
|
55
52
|
end
|
|
@@ -64,14 +61,14 @@ class StochasticPlant
|
|
|
64
61
|
private
|
|
65
62
|
######################################################
|
|
66
63
|
# draws a line using current turtle and length parameters
|
|
67
|
-
# returns a turtle corresponding to the
|
|
64
|
+
# returns a new turtle corresponding to the next position
|
|
68
65
|
######################################################
|
|
69
66
|
|
|
70
67
|
def draw_line(turtle, length)
|
|
71
|
-
new_xpos = turtle
|
|
72
|
-
new_ypos = turtle
|
|
73
|
-
line(turtle
|
|
74
|
-
|
|
68
|
+
new_xpos = turtle.x + length * DegLut.cos(turtle.angle)
|
|
69
|
+
new_ypos = turtle.y - length * DegLut.sin(turtle.angle)
|
|
70
|
+
line(turtle.x, turtle.y, new_xpos, new_ypos)
|
|
71
|
+
Turtle.new(new_xpos, new_ypos, turtle.angle)
|
|
75
72
|
end
|
|
76
73
|
end
|
|
77
74
|
|
|
@@ -6,21 +6,22 @@
|
|
|
6
6
|
load_libraries :stochastic_grammar, :control_panel
|
|
7
7
|
attr_reader :plant, :zoom, :rot_y, :panel
|
|
8
8
|
|
|
9
|
-
def setup
|
|
9
|
+
def setup
|
|
10
10
|
size(800, 800, P3D)
|
|
11
11
|
camera(400.0, 500.0, 200.0, 0.0, -160.0, 0.0,
|
|
12
12
|
0.0, 1.0, 0.0)
|
|
13
13
|
setup_panel
|
|
14
14
|
@plant = Plant.new
|
|
15
15
|
plant.create_grammar(5)
|
|
16
|
-
no_stroke
|
|
16
|
+
no_stroke
|
|
17
17
|
@rot_y = 0
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
def setup_panel
|
|
22
22
|
control_panel do |c|
|
|
23
|
-
c.title =
|
|
23
|
+
c.title = 'Control:'
|
|
24
|
+
c.look_feel 'Metal'
|
|
24
25
|
c.slider :zoom, 1..8, 3
|
|
25
26
|
c.slider :rot_y, -PI..PI, 0
|
|
26
27
|
c.button :reset
|
|
@@ -33,7 +34,7 @@ def reset
|
|
|
33
34
|
@zoom = 1
|
|
34
35
|
end
|
|
35
36
|
|
|
36
|
-
def draw
|
|
37
|
+
def draw
|
|
37
38
|
panel.set_visible true if self.visible
|
|
38
39
|
background(0)
|
|
39
40
|
rotate_y rot_y
|
|
@@ -53,42 +54,42 @@ class Plant
|
|
|
53
54
|
attr_reader :grammar, :axiom, :production, :premis, :rule,
|
|
54
55
|
:theta, :scale_factor, :distance, :phi
|
|
55
56
|
|
|
56
|
-
def initialize
|
|
57
|
-
@axiom =
|
|
57
|
+
def initialize
|
|
58
|
+
@axiom = 'F'
|
|
58
59
|
@grammar = StochasticGrammar.new(axiom)
|
|
59
60
|
@production = axiom
|
|
60
|
-
@premis =
|
|
61
|
-
@rule =
|
|
61
|
+
@premis = 'F'
|
|
62
|
+
@rule = 'F[&+F]F[->F][->F][&F]'
|
|
62
63
|
@scale_factor = 0.8
|
|
63
64
|
@distance = 8
|
|
64
|
-
@theta = radians
|
|
65
|
-
@phi = radians
|
|
65
|
+
@theta = 28.radians
|
|
66
|
+
@phi = 28.radians
|
|
66
67
|
grammar.add_rule(premis, rule)
|
|
67
|
-
no_stroke
|
|
68
|
+
no_stroke
|
|
68
69
|
end
|
|
69
70
|
|
|
70
|
-
def render
|
|
71
|
+
def render
|
|
71
72
|
production.each_char do |ch|
|
|
72
73
|
case(ch)
|
|
73
|
-
when
|
|
74
|
+
when 'F'
|
|
74
75
|
fill(0, 200, 0)
|
|
76
|
+
translate(0, distance / -2, 0)
|
|
77
|
+
box(distance / 4 , distance, distance / 4)
|
|
75
78
|
translate(0, distance/-2, 0)
|
|
76
|
-
|
|
77
|
-
translate(0, distance/-2, 0)
|
|
78
|
-
when "-"
|
|
79
|
+
when '-'
|
|
79
80
|
rotateX(-theta)
|
|
80
|
-
when
|
|
81
|
+
when '+'
|
|
81
82
|
rotateX(theta)
|
|
82
|
-
when
|
|
83
|
-
rotateY(-phi %
|
|
84
|
-
when
|
|
85
|
-
rotateZ(phi %
|
|
86
|
-
when
|
|
83
|
+
when '&'
|
|
84
|
+
rotateY(-phi % TAU)
|
|
85
|
+
when '>'
|
|
86
|
+
rotateZ(phi % TAU)
|
|
87
|
+
when '<'
|
|
87
88
|
rotateZ(-phi)
|
|
88
|
-
when
|
|
89
|
+
when '['
|
|
89
90
|
push_matrix
|
|
90
91
|
@distance = distance * scale_factor
|
|
91
|
-
when
|
|
92
|
+
when ']'
|
|
92
93
|
pop_matrix
|
|
93
94
|
@distance = distance / scale_factor
|
|
94
95
|
else
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#
|
|
2
|
-
# Bouncy Bubbles
|
|
3
|
-
# based on code from Keith Peters.
|
|
4
|
-
#
|
|
2
|
+
# Bouncy Bubbles
|
|
3
|
+
# based on code from Keith Peters.
|
|
4
|
+
#
|
|
5
5
|
# Multiple-object collision.
|
|
6
6
|
#
|
|
7
7
|
|
|
@@ -13,7 +13,7 @@ NUM_BALLS = 12
|
|
|
13
13
|
attr_reader :balls, :id
|
|
14
14
|
|
|
15
15
|
def setup
|
|
16
|
-
size(640, 360)
|
|
16
|
+
size(640, 360)
|
|
17
17
|
@balls = []
|
|
18
18
|
(0 ... NUM_BALLS).each do |i|
|
|
19
19
|
balls << Ball.new(rand(width), rand(height), rand(30 .. 70), i, balls)
|
|
@@ -24,9 +24,9 @@ end
|
|
|
24
24
|
|
|
25
25
|
def draw
|
|
26
26
|
background(0)
|
|
27
|
-
(0 ... NUM_BALLS).each do |i|
|
|
28
|
-
balls[i].collide
|
|
29
|
-
balls[i].move
|
|
27
|
+
(0 ... NUM_BALLS).each do |i|
|
|
28
|
+
balls[i].collide
|
|
29
|
+
balls[i].move
|
|
30
30
|
balls[i].display
|
|
31
31
|
end
|
|
32
32
|
end
|
|
@@ -34,7 +34,7 @@ end
|
|
|
34
34
|
class Ball
|
|
35
35
|
attr_accessor :vx, :vy
|
|
36
36
|
attr_reader :x, :y, :diameter, :others, :id, :width, :height
|
|
37
|
-
|
|
37
|
+
|
|
38
38
|
def initialize(xin, yin, din, idin, oin)
|
|
39
39
|
@x = xin
|
|
40
40
|
@y = yin
|
|
@@ -45,8 +45,8 @@ class Ball
|
|
|
45
45
|
@others = oin
|
|
46
46
|
@width = $app.width
|
|
47
47
|
@height = $app.height
|
|
48
|
-
end
|
|
49
|
-
|
|
48
|
+
end
|
|
49
|
+
|
|
50
50
|
def collide
|
|
51
51
|
((id + 1) ... NUM_BALLS).each do |i|
|
|
52
52
|
dx = others[i].x - x
|
|
@@ -54,7 +54,7 @@ class Ball
|
|
|
54
54
|
sq_dist = dx*dx + dy*dy
|
|
55
55
|
min_dist = (others[i].diameter/2 + diameter/2)
|
|
56
56
|
sq_min_dist = min_dist * min_dist
|
|
57
|
-
if (sq_dist < sq_min_dist)
|
|
57
|
+
if (sq_dist < sq_min_dist)
|
|
58
58
|
angle = atan2(dy, dx)
|
|
59
59
|
target_x = x + cos(angle) * min_dist
|
|
60
60
|
target_y = y + sin(angle) * min_dist
|
|
@@ -65,30 +65,30 @@ class Ball
|
|
|
65
65
|
others[i].vx += ax
|
|
66
66
|
others[i].vy += ay
|
|
67
67
|
end
|
|
68
|
-
|
|
68
|
+
|
|
69
69
|
end
|
|
70
|
-
|
|
70
|
+
|
|
71
71
|
def move
|
|
72
72
|
@vy += GRAVITY
|
|
73
73
|
@x += vx
|
|
74
74
|
@y += vy
|
|
75
75
|
if (x + diameter/2 > width)
|
|
76
76
|
@x = width - diameter/2
|
|
77
|
-
@vx *= FRICTION
|
|
77
|
+
@vx *= FRICTION
|
|
78
78
|
elsif (x - diameter/2 < 0)
|
|
79
79
|
@x = diameter/2
|
|
80
80
|
@vx *= FRICTION
|
|
81
81
|
end
|
|
82
|
-
|
|
82
|
+
|
|
83
83
|
if (y + diameter/2 > height)
|
|
84
84
|
@y = height - diameter/2
|
|
85
|
-
@vy *= FRICTION
|
|
85
|
+
@vy *= FRICTION
|
|
86
86
|
elsif (y - diameter/2 < 0)
|
|
87
87
|
@y = diameter/2
|
|
88
88
|
@vy *= FRICTION
|
|
89
89
|
end
|
|
90
90
|
end
|
|
91
|
-
|
|
91
|
+
|
|
92
92
|
def display
|
|
93
93
|
ellipse(x, y, diameter, diameter)
|
|
94
94
|
end
|
|
@@ -18,9 +18,7 @@ CUBE_NO = 20
|
|
|
18
18
|
java_alias :background_int, :background, [Java::int]
|
|
19
19
|
java_alias :stroke_int, :stroke, [Java::int]
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
# in the cube class, need to call $app.fill_int in cube
|
|
23
|
-
java_alias :fill_int, :fill, [Java::int]
|
|
21
|
+
|
|
24
22
|
|
|
25
23
|
attr_reader :cubies
|
|
26
24
|
|
|
@@ -7,7 +7,7 @@ class Cube
|
|
|
7
7
|
# Colors are hardcoded
|
|
8
8
|
BOUNDS=300
|
|
9
9
|
COLORS = [0, 51, 102, 153, 204, 255]
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
# Position, velocity vectors
|
|
12
12
|
attr_reader :position, :velocity, :rotation, :vertices, :w, :h, :d
|
|
13
13
|
attr_reader :boundary
|
|
@@ -61,7 +61,7 @@ class Cube
|
|
|
61
61
|
def draw_cube
|
|
62
62
|
# Draw cube
|
|
63
63
|
COLORS.length.times do |i|
|
|
64
|
-
|
|
64
|
+
fill(COLORS[i])
|
|
65
65
|
begin_shape(QUADS)
|
|
66
66
|
4.times do |j|
|
|
67
67
|
vertex(*vertices[j + 4 * i]) # splat vertices
|
|
@@ -10,14 +10,14 @@ attr_reader :blur
|
|
|
10
10
|
|
|
11
11
|
def setup
|
|
12
12
|
size(640, 360, P2D)
|
|
13
|
-
@blur = load_shader(
|
|
13
|
+
@blur = load_shader('blur.glsl')
|
|
14
14
|
stroke(255, 0, 0)
|
|
15
15
|
rectMode(CENTER)
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def draw
|
|
19
|
-
filter(blur)
|
|
20
|
-
rect(mouse_x, mouse_y, 150, 150)
|
|
19
|
+
filter(blur)
|
|
20
|
+
rect(mouse_x, mouse_y, 150, 150)
|
|
21
21
|
ellipse(mouse_x, mouse_y, 100, 100)
|
|
22
22
|
end
|
|
23
23
|
|
|
@@ -5,9 +5,9 @@ attr_reader :label, :can, :angle, :bw_shader
|
|
|
5
5
|
|
|
6
6
|
def setup
|
|
7
7
|
size(640, 360, P3D)
|
|
8
|
-
@label = load_image(
|
|
8
|
+
@label = load_image('lachoy.jpg')
|
|
9
9
|
@can = create_can(100, 200, 32, label)
|
|
10
|
-
@bw_shader = load_shader(
|
|
10
|
+
@bw_shader = load_shader('bwfrag.glsl')
|
|
11
11
|
@angle = 0
|
|
12
12
|
end
|
|
13
13
|
|
|
@@ -27,7 +27,7 @@ def create_can(r, h, detail, tex)
|
|
|
27
27
|
sh.no_stroke
|
|
28
28
|
sh.texture(tex)
|
|
29
29
|
(0 .. detail).each do |i|
|
|
30
|
-
angle =
|
|
30
|
+
angle = TAU / detail
|
|
31
31
|
x = sin(i * angle)
|
|
32
32
|
z = cos(i * angle)
|
|
33
33
|
u = i.to_f / detail
|
|
@@ -8,15 +8,15 @@ def setup
|
|
|
8
8
|
size(400, 400, P3D)
|
|
9
9
|
@pg = createGraphics(400, 400, P2D)
|
|
10
10
|
pg.no_smooth
|
|
11
|
-
@conway = load_shader(
|
|
12
|
-
conway.set(
|
|
11
|
+
@conway = load_shader('data/conway.glsl')
|
|
12
|
+
conway.set('resolution', width.to_f, height.to_f)
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def draw
|
|
16
|
-
conway.set(
|
|
17
|
-
xm = map(mouse_x, 0, width, 0, 1)
|
|
16
|
+
conway.set('time', millis / 1000.0)
|
|
17
|
+
xm = map(mouse_x, 0, width, 0, 1) # NB: processings map function
|
|
18
18
|
ym = map(mouse_y, 0, height, 1, 0)
|
|
19
|
-
conway.set(
|
|
19
|
+
conway.set('mouse', xm, ym)
|
|
20
20
|
pg.begin_draw
|
|
21
21
|
pg.background(0)
|
|
22
22
|
pg.shader(conway)
|