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
|
@@ -14,15 +14,15 @@ def setup
|
|
|
14
14
|
size(640, 360, P2D)
|
|
15
15
|
|
|
16
16
|
textureWrap(REPEAT)
|
|
17
|
-
@tex = loadImage(
|
|
17
|
+
@tex = loadImage('tex1.jpg')
|
|
18
18
|
|
|
19
|
-
@deform = loadShader(
|
|
20
|
-
deform.set(
|
|
19
|
+
@deform = loadShader('deform.glsl')
|
|
20
|
+
deform.set('resolution', width.to_f, height.to_f)
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def draw
|
|
24
|
-
deform.set(
|
|
25
|
-
deform.set(
|
|
24
|
+
deform.set('time', millis / 1000.0)
|
|
25
|
+
deform.set('mouse', mouse_x.to_f, mouse_y.to_f)
|
|
26
26
|
shader(deform)
|
|
27
27
|
image(tex, 0, 0, width, height)
|
|
28
28
|
end
|
|
@@ -11,14 +11,12 @@ attr_reader :edges, :img , :enabled
|
|
|
11
11
|
def setup
|
|
12
12
|
size(640, 360, P2D)
|
|
13
13
|
@enabled = true
|
|
14
|
-
@img = load_image(
|
|
15
|
-
@edges = load_shader(
|
|
14
|
+
@img = load_image('leaves.jpg');
|
|
15
|
+
@edges = load_shader('edges.glsl')
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def draw
|
|
19
|
-
if
|
|
20
|
-
shader(edges)
|
|
21
|
-
end
|
|
19
|
+
shader(edges) if enabled
|
|
22
20
|
image(img, 0, 0)
|
|
23
21
|
end
|
|
24
22
|
|
|
@@ -9,22 +9,20 @@
|
|
|
9
9
|
attr_reader :ball, :canvas, :glossy, :fisheye, :img, :use_fish_eye
|
|
10
10
|
|
|
11
11
|
def setup
|
|
12
|
-
size(640, 640, P3D)
|
|
12
|
+
size(640, 640, P3D)
|
|
13
13
|
@canvas = create_graphics(width, height, P3D)
|
|
14
14
|
@use_fish_eye = true
|
|
15
|
-
@fisheye = load_shader(
|
|
16
|
-
fisheye.set(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
glossy.set(
|
|
20
|
-
glossy.set(
|
|
21
|
-
glossy.set(
|
|
22
|
-
glossy.set(
|
|
23
|
-
glossy.set(
|
|
24
|
-
glossy.set(
|
|
25
|
-
glossy.set(
|
|
26
|
-
glossy.set("Sharpness", 0.0)
|
|
27
|
-
|
|
15
|
+
@fisheye = load_shader('FishEye.glsl')
|
|
16
|
+
fisheye.set('aperture', 180.0)
|
|
17
|
+
@glossy = load_shader('GlossyFrag.glsl', 'GlossyVert.glsl')
|
|
18
|
+
glossy.set('AmbientColour', 0.0, 0.0, 0.0)
|
|
19
|
+
glossy.set('DiffuseColour', 0.9, 0.2, 0.2)
|
|
20
|
+
glossy.set('SpecularColour', 1.0, 1.0, 1.0)
|
|
21
|
+
glossy.set('AmbientIntensity', 1.0)
|
|
22
|
+
glossy.set('DiffuseIntensity', 1.0)
|
|
23
|
+
glossy.set('SpecularIntensity', 0.7)
|
|
24
|
+
glossy.set('Roughness', 0.7)
|
|
25
|
+
glossy.set('Sharpness', 0.0)
|
|
28
26
|
@ball = create_shape(SPHERE, 50)
|
|
29
27
|
ball.set_stroke(false)
|
|
30
28
|
end
|
|
@@ -53,11 +51,7 @@ def draw
|
|
|
53
51
|
image(canvas, 0, 0, width, height)
|
|
54
52
|
end
|
|
55
53
|
|
|
56
|
-
def
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
reset_shader
|
|
60
|
-
else
|
|
61
|
-
@use_fish_eye = true
|
|
62
|
-
end
|
|
54
|
+
def mouse_pressed
|
|
55
|
+
@use_fish_eye = !use_fish_eye
|
|
56
|
+
reset_shader
|
|
63
57
|
end
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
#
|
|
8
8
|
# c = cycle through the color maps
|
|
9
9
|
#
|
|
10
|
-
# Tested with
|
|
10
|
+
# Tested with ruby-procesing 2.5.0
|
|
11
11
|
#
|
|
12
12
|
# Photographs by Folkert Gorter (@folkertgorter / http://superfamous.com/) made available under a CC Attribution 3.0 license.
|
|
13
13
|
#
|
|
@@ -25,46 +25,47 @@ attr_reader :displace # GLSL shader
|
|
|
25
25
|
attr_reader :images # array to hold 2 input images
|
|
26
26
|
attr_reader :current_color_map # variable to keep track of the current colorMap
|
|
27
27
|
|
|
28
|
+
|
|
28
29
|
def setup
|
|
29
30
|
size(1280, 720, P3D) # use the P3D OpenGL renderer
|
|
30
|
-
|
|
31
|
-
@
|
|
31
|
+
|
|
32
|
+
@blur_factor = 3
|
|
33
|
+
@resize_factor = 0.25
|
|
32
34
|
displace_strength = 0.25 # the displace strength of the GLSL shader displacement effect
|
|
33
35
|
# load the images from the _Images folder (relative path from this sketch's folder)
|
|
34
36
|
@images = []
|
|
35
|
-
images << load_image(data_path(
|
|
36
|
-
images << load_image(data_path(
|
|
37
|
+
images << load_image(data_path('Texture01.jpg'))
|
|
38
|
+
images << load_image(data_path('Texture02.jpg'))
|
|
37
39
|
@current_color_map = 0
|
|
38
40
|
# load the PShader with a fragment and a vertex shader
|
|
39
|
-
@displace = load_shader(
|
|
40
|
-
displace.set(
|
|
41
|
-
displace.set(
|
|
41
|
+
@displace = load_shader('displaceFrag.glsl', 'displaceVert.glsl')
|
|
42
|
+
displace.set('displaceStrength', displace_strength) # set the displace_strength
|
|
43
|
+
displace.set('colorMap', images[current_color_map]) # set the initial colorMap
|
|
42
44
|
# create the heightmap PShape (see custom creation method) and put it in the global height_map reference
|
|
43
45
|
@height_map = create_plane(DIM, DIM)
|
|
44
46
|
end
|
|
45
47
|
|
|
46
48
|
def draw
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
# required for texLight shader
|
|
50
|
+
pointLight(255, 255, 255, 2 * (mouse_x - width / 2), 2 * (mouse_y - height / 2), 500)
|
|
49
51
|
translate(width / 2, height / 2) # translate to center of the screen
|
|
50
52
|
rotate_x(radians(60)) # fixed rotation of 60 degrees over the X axis
|
|
51
|
-
rotate_z(frame_count*0.005)
|
|
53
|
+
rotate_z(frame_count * 0.005) # dynamic frameCount-based rotation over the Z axis
|
|
52
54
|
|
|
53
55
|
background(0) # black background
|
|
54
56
|
perspective(PI/3.0, width.to_f / height, 0.1, 1000000) # perspective for close shapes
|
|
55
57
|
scale(750) # scale by 750 (the model itself is unit length
|
|
56
58
|
|
|
57
|
-
displace.set(
|
|
59
|
+
displace.set('time', millis / 5000.0) # feed time to the GLSL shader
|
|
58
60
|
shader(displace) # use shader
|
|
59
61
|
shape(height_map) # display the PShape
|
|
60
62
|
|
|
61
63
|
# write the fps and the current colorMap in the top-left of the window
|
|
62
|
-
frame.set_title(
|
|
64
|
+
frame.set_title('FrameRate: #{frame_rate.to_i} | colorMap: #{current_color_map + 1}')
|
|
63
65
|
end
|
|
64
66
|
|
|
65
67
|
# custom method to create a PShape plane with certain xy DIMensions
|
|
66
|
-
def create_plane(xsegs, ysegs)
|
|
67
|
-
|
|
68
|
+
def create_plane(xsegs, ysegs)
|
|
68
69
|
# STEP 1: create all the relevant data
|
|
69
70
|
|
|
70
71
|
@positions = [] # arrayList to hold positions
|
|
@@ -95,16 +96,17 @@ def create_plane(xsegs, ysegs)
|
|
|
95
96
|
# STEP 2: put all the relevant data into the PShape
|
|
96
97
|
|
|
97
98
|
texture_mode(NORMAL) # set texture_mode to normalized (range 0 to 1)
|
|
98
|
-
tex = load_image(data_path
|
|
99
|
+
tex = load_image(data_path 'Texture01.jpg')
|
|
99
100
|
|
|
100
101
|
mesh = create_shape # create the initial PShape
|
|
102
|
+
renderer = ShapeRender.new(mesh) # initialize the shape renderer
|
|
101
103
|
mesh.begin_shape(QUADS) # define the PShape type: QUADS
|
|
102
104
|
mesh.no_stroke
|
|
103
105
|
mesh.texture(tex) # set a texture to make a textured PShape
|
|
104
106
|
# put all the vertices, uv texture coordinates and normals into the PShape
|
|
105
107
|
positions.each_with_index { |p, i|
|
|
106
108
|
t = tex_coords[i]
|
|
107
|
-
|
|
109
|
+
p.to_vertex_uv(renderer, t.x, t.y)
|
|
108
110
|
}
|
|
109
111
|
mesh.end_shape
|
|
110
112
|
|
|
@@ -115,9 +117,9 @@ def key_pressed
|
|
|
115
117
|
case key
|
|
116
118
|
when '1', '2'
|
|
117
119
|
@current_color_map = key.to_i % 2 #images.size
|
|
118
|
-
displace.set(
|
|
120
|
+
displace.set('colorMap', images[current_color_map])
|
|
119
121
|
else
|
|
120
|
-
puts
|
|
122
|
+
puts 'key pressed: #{key}'
|
|
121
123
|
end # cycle through colorMaps (set variable and set colorMap in PShader)
|
|
122
124
|
end
|
|
123
125
|
|
|
@@ -8,24 +8,24 @@ attr_reader :mask_shader, :src_image, :mask_image
|
|
|
8
8
|
|
|
9
9
|
def setup
|
|
10
10
|
size(640, 360, P2D)
|
|
11
|
-
@src_image = load_image(
|
|
11
|
+
@src_image = load_image('leaves.jpg')
|
|
12
12
|
@mask_image = create_graphics(src_image.width, src_image.height, P2D)
|
|
13
13
|
mask_image.no_smooth
|
|
14
|
-
@mask_shader = load_shader(
|
|
15
|
-
mask_shader.set(
|
|
14
|
+
@mask_shader = load_shader('mask.glsl')
|
|
15
|
+
mask_shader.set('mask', mask_image)
|
|
16
16
|
background(255)
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
def draw
|
|
19
|
+
def draw
|
|
20
20
|
mask_image.begin_draw
|
|
21
21
|
mask_image.background(0)
|
|
22
|
-
if (mouse_x != 0 && mouse_y != 0)
|
|
22
|
+
if (mouse_x != 0) && (mouse_y != 0)
|
|
23
23
|
mask_image.no_stroke
|
|
24
24
|
mask_image.fill(255, 0, 0)
|
|
25
25
|
mask_image.ellipse(mouse_x, mouse_y, 50, 50)
|
|
26
26
|
end
|
|
27
27
|
mask_image.end_draw
|
|
28
|
-
shader(mask_shader)
|
|
28
|
+
shader(mask_shader)
|
|
29
29
|
image(src_image, 0, 0, width, height)
|
|
30
30
|
end
|
|
31
31
|
|
|
@@ -16,17 +16,17 @@ def setup
|
|
|
16
16
|
|
|
17
17
|
# The code of this shader shows how to integrate shaders from shadertoy
|
|
18
18
|
# into Processing with minimal changes.
|
|
19
|
-
@landscape = load_shader(
|
|
20
|
-
landscape.set(
|
|
19
|
+
@landscape = load_shader('landscape.glsl')
|
|
20
|
+
landscape.set('resolution', width.to_f, height.to_f)
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def draw
|
|
24
24
|
background_int 0
|
|
25
25
|
|
|
26
|
-
landscape.set(
|
|
26
|
+
landscape.set('time', (millis/1000.0).to_f)
|
|
27
27
|
shader(landscape)
|
|
28
28
|
rect(0, 0, width, height)
|
|
29
29
|
|
|
30
|
-
frame.set_title
|
|
30
|
+
frame.set_title 'frame: #{frame_count} - fps: #{format('%.2f', frame_rate)}'
|
|
31
31
|
end
|
|
32
32
|
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
##
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
# Monjori.
|
|
3
|
+
#
|
|
4
|
+
# GLSL version of the 1k intro Monjori from the demoscene
|
|
5
|
+
# (http://www.pouet.net/prod.php?which=52761)
|
|
6
|
+
# Ported from the webGL version available in ShaderToy:
|
|
7
|
+
# http://www.iquilezles.org/apps/shadertoy/
|
|
8
|
+
# (Look for Monjori under the Plane Deformations Presets)
|
|
9
|
+
|
|
10
10
|
|
|
11
11
|
attr_reader :monjori
|
|
12
12
|
|
|
13
13
|
def setup
|
|
14
14
|
size(640, 360, P2D)
|
|
15
|
-
no_stroke
|
|
16
|
-
@monjori =
|
|
17
|
-
monjori.set(
|
|
15
|
+
no_stroke
|
|
16
|
+
@monjori = load_shader('monjori.glsl')
|
|
17
|
+
monjori.set('resolution', width.to_f, height.to_f)
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def draw
|
|
21
|
-
monjori.set(
|
|
21
|
+
monjori.set('time', millis / 1000.0)
|
|
22
22
|
shader(monjori)
|
|
23
23
|
# This kind of effects are entirely implemented in the
|
|
24
|
-
# fragment shader, they only need a quad covering the
|
|
24
|
+
# fragment shader, they only need a quad covering the
|
|
25
25
|
# entire view area so every pixel is pushed through the
|
|
26
|
-
# shader.
|
|
27
|
-
rect(0, 0, width, height)
|
|
26
|
+
# shader.
|
|
27
|
+
rect(0, 0, width, height)
|
|
28
28
|
end
|
|
@@ -2,12 +2,12 @@ attr_reader :nebula
|
|
|
2
2
|
|
|
3
3
|
def setup
|
|
4
4
|
size(512, 384, P2D)
|
|
5
|
-
@nebula = load_shader(
|
|
6
|
-
nebula.set(
|
|
5
|
+
@nebula = load_shader('nebula.glsl')
|
|
6
|
+
nebula.set('resolution', width.to_f, height.to_f)
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
def draw
|
|
10
|
-
nebula.set(
|
|
10
|
+
nebula.set('time', millis / 1000.0)
|
|
11
11
|
shader(nebula)
|
|
12
12
|
# The rect is needed to make the fragment shader go through every pixel of
|
|
13
13
|
# the screen, but is not used for anything else since the rendering is entirely
|
|
@@ -10,9 +10,9 @@ attr_reader :blur, :src, :pass1, :pass2
|
|
|
10
10
|
|
|
11
11
|
def setup
|
|
12
12
|
size(640, 360, P2D)
|
|
13
|
-
@blur = load_shader(
|
|
14
|
-
blur.set(
|
|
15
|
-
blur.set(
|
|
13
|
+
@blur = load_shader('sep_blur.glsl')
|
|
14
|
+
blur.set('blurSize', 9)
|
|
15
|
+
blur.set('sigma', 5.0)
|
|
16
16
|
@src = create_graphics(width, height, P2D)
|
|
17
17
|
@pass1 = create_graphics(width, height, P2D)
|
|
18
18
|
pass1.no_smooth
|
|
@@ -28,14 +28,14 @@ def draw
|
|
|
28
28
|
src.end_draw
|
|
29
29
|
|
|
30
30
|
# Applying the blur shader along the vertical direction
|
|
31
|
-
blur.set(
|
|
31
|
+
blur.set('horizontalPass', 0)
|
|
32
32
|
pass1.begin_draw
|
|
33
33
|
pass1.shader(blur)
|
|
34
34
|
pass1.image(src, 0, 0)
|
|
35
35
|
pass1.end_draw
|
|
36
36
|
|
|
37
37
|
# Applying the blur shader along the horizontal direction
|
|
38
|
-
blur.set(
|
|
38
|
+
blur.set('horizontalPass', 1)
|
|
39
39
|
pass2.begin_draw
|
|
40
40
|
pass2.shader(blur)
|
|
41
41
|
pass2.image(pass1, 0, 0)
|
|
@@ -46,19 +46,19 @@ end
|
|
|
46
46
|
def key_pressed
|
|
47
47
|
case(key)
|
|
48
48
|
when '9'
|
|
49
|
-
blur.set(
|
|
50
|
-
blur.set(
|
|
49
|
+
blur.set('blurSize', 9)
|
|
50
|
+
blur.set('sigma', 5.0)
|
|
51
51
|
when '7'
|
|
52
|
-
blur.set(
|
|
53
|
-
blur.set(
|
|
52
|
+
blur.set('blurSize', 7)
|
|
53
|
+
blur.set('sigma', 3.0)
|
|
54
54
|
when '5'
|
|
55
|
-
blur.set(
|
|
56
|
-
blur.set(
|
|
55
|
+
blur.set('blurSize', 5)
|
|
56
|
+
blur.set('sigma', 2.0)
|
|
57
57
|
when '3'
|
|
58
|
-
blur.set(
|
|
59
|
-
blur.set(
|
|
58
|
+
blur.set('blurSize', 5)
|
|
59
|
+
blur.set('sigma', 1.0)
|
|
60
60
|
else
|
|
61
|
-
blur.set(
|
|
62
|
-
blur.set(
|
|
61
|
+
blur.set('blurSize', 9)
|
|
62
|
+
blur.set('sigma', 5.0)
|
|
63
63
|
end
|
|
64
64
|
end
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# Toon Shading.
|
|
3
3
|
#
|
|
4
4
|
# Example showing the use of a custom lighting shader in order
|
|
5
|
-
# to apply a
|
|
5
|
+
# to apply a 'toon' effect on the scene. Based on the glsl tutorial
|
|
6
6
|
# from lighthouse 3D:
|
|
7
7
|
# http://www.lighthouse3d.com/tutorials/glsl-tutorial/toon-shader-version-ii/
|
|
8
8
|
#
|
|
@@ -14,7 +14,7 @@ def setup
|
|
|
14
14
|
@shader_enabled = true
|
|
15
15
|
no_stroke
|
|
16
16
|
fill(204)
|
|
17
|
-
@toon = load_shader(
|
|
17
|
+
@toon = load_shader('ToonFrag.glsl', 'ToonVert.glsl')
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def draw
|
|
@@ -12,26 +12,26 @@ def setup
|
|
|
12
12
|
size 640, 340
|
|
13
13
|
fill 0
|
|
14
14
|
|
|
15
|
-
# Inputs: spring1, spring2, mass, gravity
|
|
16
|
-
@gravity = 6.0
|
|
17
|
-
@mass = 2.0
|
|
18
|
-
@s1 = Spring2d.new(width/2, height/2, @mass)
|
|
19
|
-
@s2 = Spring2d.new(width/2, height/2, @mass)
|
|
20
|
-
|
|
21
15
|
# Control panel for changing gravity
|
|
22
16
|
control_panel do |c|
|
|
23
|
-
c.slider :gravity, 0..30
|
|
17
|
+
c.slider :gravity, 0..30, 6
|
|
24
18
|
@panel = c
|
|
25
19
|
end
|
|
20
|
+
|
|
21
|
+
@mass = 2.0
|
|
22
|
+
@s1 = Spring2d.new(width/2, height/2, @mass, gravity)
|
|
23
|
+
@s2 = Spring2d.new(width/2, height/2, @mass, gravity)
|
|
24
|
+
|
|
25
|
+
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def draw
|
|
29
29
|
panel.set_visible(true) if self.visible
|
|
30
30
|
background 204
|
|
31
|
-
@s1.update(mouse_x, mouse_y)
|
|
31
|
+
@s1.update(mouse_x, mouse_y, gravity)
|
|
32
32
|
display(@s1, mouse_x, mouse_y)
|
|
33
33
|
|
|
34
|
-
@s2.update(@s1.x, @s1.y)
|
|
34
|
+
@s2.update(@s1.x, @s1.y, gravity)
|
|
35
35
|
display(@s2, @s1.x, @s1.y)
|
|
36
36
|
end
|
|
37
37
|
|
|
@@ -45,12 +45,14 @@ end
|
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
class Spring2d
|
|
48
|
+
include Processing::Proxy
|
|
48
49
|
|
|
49
|
-
attr_reader :x, :y
|
|
50
|
+
attr_reader :x, :y, :gravity
|
|
50
51
|
|
|
51
|
-
def initialize(xpos, ypos, mass)
|
|
52
|
+
def initialize(xpos, ypos, mass, gravity)
|
|
52
53
|
@x = xpos # The x-coordinate
|
|
53
54
|
@y = ypos # The y-coordinate
|
|
55
|
+
@gravity = gravity
|
|
54
56
|
@mass = mass
|
|
55
57
|
@vx, @vy = 0, 0 # The x- and y-axis velocities
|
|
56
58
|
@radius = 20
|
|
@@ -58,14 +60,14 @@ class Spring2d
|
|
|
58
60
|
@damping = 0.7
|
|
59
61
|
end
|
|
60
62
|
|
|
61
|
-
def update(target_x, target_y)
|
|
63
|
+
def update(target_x, target_y, gravity)
|
|
62
64
|
force_x = (target_x - self.x) * @stiffness
|
|
63
65
|
ax = force_x / @mass
|
|
64
66
|
@vx = @damping * (@vx + ax)
|
|
65
67
|
@x += @vx
|
|
66
|
-
|
|
68
|
+
@gravity = gravity
|
|
67
69
|
force_y = (target_y - self.y) * @stiffness
|
|
68
|
-
force_y +=
|
|
70
|
+
force_y += gravity
|
|
69
71
|
ay = force_y / @mass
|
|
70
72
|
@vy = @damping * (@vy + ay)
|
|
71
73
|
@y += @vy
|