ruby-processing 2.4.4 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,6 +1,6 @@
|
|
1
1
|
########################
|
2
|
-
# NB:
|
3
|
-
# but, performs Ok after
|
2
|
+
# NB: Bit slow to get going
|
3
|
+
# but, performs Ok after
|
4
4
|
########################
|
5
5
|
|
6
6
|
BOX_SIZE = 20
|
@@ -16,15 +16,15 @@ def setup
|
|
16
16
|
@fcount = 0
|
17
17
|
@lastm = 0
|
18
18
|
no_smooth
|
19
|
-
no_stroke
|
20
|
-
@grid = create_shape(GROUP)
|
21
|
-
# Build grid using multiple translations
|
19
|
+
no_stroke
|
20
|
+
@grid = create_shape(GROUP)
|
21
|
+
# Build grid using multiple translations
|
22
22
|
(-(DEPTH/2 + MARGIN) ... (DEPTH/2 - MARGIN)).step(BOX_SIZE) do |i|
|
23
23
|
(-(height + MARGIN) ... (height - MARGIN)).step(BOX_SIZE) do |j|
|
24
24
|
(-(width + MARGIN) ... (width - MARGIN)).step(BOX_SIZE) do |k|
|
25
|
-
# Base fill color on counter values, abs function
|
25
|
+
# Base fill color on counter values, abs function
|
26
26
|
# ensures values stay within legal range
|
27
|
-
@box_fill = color(i.abs.to_i, j.abs.to_i, k.abs.to_i, 50)
|
27
|
+
@box_fill = color(i.abs.to_i, j.abs.to_i, k.abs.to_i, 50)
|
28
28
|
cube = create_shape(BOX, BOX_SIZE.to_f, BOX_SIZE.to_f, BOX_SIZE.to_f)
|
29
29
|
cube.set_fill(box_fill)
|
30
30
|
cube.translate(k, j, i)
|
@@ -35,24 +35,24 @@ def setup
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def draw
|
38
|
-
background(255)
|
39
|
-
hint(DISABLE_DEPTH_TEST)
|
38
|
+
background(255)
|
39
|
+
hint(DISABLE_DEPTH_TEST)
|
40
40
|
# Center and spin grid
|
41
41
|
push_matrix()
|
42
42
|
translate(width/2, height/2, -DEPTH)
|
43
43
|
rotate_y(frame_count * 0.01)
|
44
44
|
rotate_x(frame_count * 0.01)
|
45
45
|
shape(grid)
|
46
|
-
pop_matrix()
|
47
|
-
hint(ENABLE_DEPTH_TEST)
|
46
|
+
pop_matrix()
|
47
|
+
hint(ENABLE_DEPTH_TEST)
|
48
48
|
@fcount += 1
|
49
49
|
m = millis()
|
50
|
-
if (m - lastm > 1000 * FINT)
|
50
|
+
if (m - lastm > 1000 * FINT)
|
51
51
|
@frate = fcount / FINT
|
52
52
|
@fcount = 0
|
53
53
|
@lastm = m
|
54
|
-
puts("fps: #{frate}")
|
55
|
-
end
|
54
|
+
puts("fps: #{frate}")
|
55
|
+
end
|
56
56
|
fill(0)
|
57
57
|
text("fps: #{frate}", 10, 20)
|
58
58
|
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
#
|
2
2
|
# Esfera
|
3
|
-
# by David Pena.
|
3
|
+
# by David Pena.
|
4
4
|
# Somewhat re-factored for ruby-processing
|
5
5
|
# by Martin Prout
|
6
|
-
# Distribucion aleatoria uniforme sobre la superficie de una esfera.
|
6
|
+
# Distribucion aleatoria uniforme sobre la superficie de una esfera.
|
7
7
|
#
|
8
|
+
load_library :vecmath
|
8
9
|
|
9
|
-
|
10
|
-
QUANTITY = 16000
|
10
|
+
QUANTITY = 16000
|
11
11
|
|
12
12
|
attr_reader :orb, :phi, :radius, :rx, :ry
|
13
13
|
|
@@ -19,26 +19,20 @@ java_alias :stroke_float_float, :stroke, [Java::float, Java::float]
|
|
19
19
|
|
20
20
|
def setup
|
21
21
|
size(800, 600, P3D)
|
22
|
+
ArcBall.init(self, width / 2.0, height / 2.0)
|
22
23
|
@rx = 0
|
23
24
|
@ry =0
|
24
25
|
no_smooth
|
25
26
|
@radius = height/3.5
|
26
27
|
@orb = HairyOrb.new(self, radius)
|
27
28
|
QUANTITY.times do
|
28
|
-
orb <<
|
29
|
+
orb << create_hair(radius)
|
29
30
|
end
|
30
31
|
noise_detail(3)
|
31
32
|
end
|
32
33
|
|
33
34
|
def draw
|
34
35
|
background_int(0)
|
35
|
-
translate(width/2,height/2)
|
36
|
-
rxp = ((mouse_x - (width/2))*0.005)
|
37
|
-
ryp = ((mouse_y - (height/2))*0.005)
|
38
|
-
@rx = (rx*0.9)+(rxp*0.1)
|
39
|
-
@ry = (ry*0.9)+(ryp*0.1)
|
40
|
-
rotate_y(rx)
|
41
|
-
rotate_x(ry)
|
42
36
|
fill_int 0
|
43
37
|
no_stroke
|
44
38
|
sphere(radius)
|
@@ -48,21 +42,30 @@ def draw
|
|
48
42
|
end
|
49
43
|
end
|
50
44
|
|
51
|
-
|
45
|
+
def create_hair radius
|
46
|
+
z = rand(-radius .. radius)
|
47
|
+
phi = rand(0 .. TAU)
|
48
|
+
len = rand(1.15 .. 1.2)
|
49
|
+
theta = Math.asin(z / radius)
|
50
|
+
Hair.new(z, phi, len, theta)
|
51
|
+
end
|
52
|
+
|
53
|
+
require 'forwardable'
|
54
|
+
|
55
|
+
class HairyOrb
|
52
56
|
extend Enumerable
|
57
|
+
extend Forwardable
|
58
|
+
def_delegators(:@hairs, :each, :<<)
|
59
|
+
|
53
60
|
attr_reader :app, :hairs, :radius
|
54
|
-
|
61
|
+
|
55
62
|
def initialize app, radius
|
56
63
|
@app, @radius = app, radius
|
57
|
-
@hairs = []
|
64
|
+
@hairs = []
|
58
65
|
end
|
59
|
-
|
60
|
-
def
|
61
|
-
|
62
|
-
end
|
63
|
-
|
64
|
-
def render
|
65
|
-
hairs.each do |hair|
|
66
|
+
|
67
|
+
def render
|
68
|
+
self.each do |hair|
|
66
69
|
off = (app.noise(app.millis() * 0.0005, sin(hair.phi)) - 0.5) * 0.3
|
67
70
|
offb = (app.noise(app.millis() * 0.0007, sin(hair.z) * 0.01) - 0.5) * 0.3
|
68
71
|
thetaff = hair.theta + off
|
@@ -83,23 +86,8 @@ class HairyOrb
|
|
83
86
|
app.stroke_float_float(200, 150)
|
84
87
|
app.vertex(xb, yb, zb)
|
85
88
|
app.end_shape()
|
86
|
-
end
|
89
|
+
end
|
87
90
|
end
|
88
91
|
end
|
89
92
|
|
90
|
-
|
91
|
-
def self.create_hair radius
|
92
|
-
z = rand(-radius .. radius)
|
93
|
-
phi = rand * Math::PI * 2
|
94
|
-
len = rand(1.15 .. 1.2)
|
95
|
-
theta = Math.asin(z / radius)
|
96
|
-
return Hair.new(z, phi, len, theta)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
class Hair
|
101
|
-
attr_reader :z, :phi, :len, :theta
|
102
|
-
def initialize z, phi, len, theta
|
103
|
-
@z, @phi, @len, @theta = z, phi, len, theta
|
104
|
-
end
|
105
|
-
end
|
93
|
+
Hair = Struct.new(:z, :phi, :len, :theta )
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# The current time can be read with the second(), minute(), and hour()
|
2
|
+
# functions. In this example, DegLut.sin() and DegLut.cos() values are used to
|
3
|
+
# set the position of the hands, perfect for degree precision Lookup Table.
|
4
|
+
load_library :fastmath
|
5
|
+
|
6
|
+
def setup
|
7
|
+
size 200, 200
|
8
|
+
stroke 255
|
9
|
+
smooth 8
|
10
|
+
end
|
11
|
+
|
12
|
+
def draw
|
13
|
+
background 0
|
14
|
+
fill 80
|
15
|
+
no_stroke
|
16
|
+
# adj factor to map 0-60 to 0-360 (seconds/minutes) & 0-12 to 0-360 (hours)
|
17
|
+
# since angles for DegLut.sin() and DegLut.cos() start at 3 o'clock we
|
18
|
+
# subtract 90 degrees to make them start at the top.
|
19
|
+
clock_x = lambda do |val, adj, length|
|
20
|
+
DegLut.cos((val * adj).to_i - 90) * length + width / 2
|
21
|
+
end
|
22
|
+
clock_y = lambda do |val, adj, length|
|
23
|
+
DegLut.sin((val * adj).to_i - 90) * length + height / 2
|
24
|
+
end
|
25
|
+
ellipse 100, 100, 160, 160
|
26
|
+
stroke 220
|
27
|
+
stroke_weight 6
|
28
|
+
line(100, 100, clock_x.call(hour % 12 + (minute / 60.0), 30, 50),
|
29
|
+
clock_y.call(hour % 12 + (minute / 60.0), 30, 50))
|
30
|
+
stroke_weight 3
|
31
|
+
line(100, 100, clock_x.call(minute + (second / 60.0), 6, 60),
|
32
|
+
clock_y.call(minute + (second / 60.0), 6, 60))
|
33
|
+
stroke 255, 0, 0
|
34
|
+
stroke_weight 1
|
35
|
+
line(100, 100, clock_x.call(second, 6, 72), clock_y.call(second, 6, 72))
|
36
|
+
# Draw the minute ticks
|
37
|
+
stroke_weight 2
|
38
|
+
stroke 255
|
39
|
+
(0..360).step(6) do |a|
|
40
|
+
x = 100 + DegLut.cos(a) * 72
|
41
|
+
y = 100 + DegLut.sin(a) * 72
|
42
|
+
point x, y
|
43
|
+
end
|
44
|
+
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# Geometry
|
3
3
|
# by Marius Watz.
|
4
4
|
#
|
5
|
-
|
5
|
+
load_libraries :pdf, :fastmath
|
6
6
|
include_package 'processing.pdf'
|
7
7
|
|
8
8
|
attr_reader :num, :pt, :style, :dosave
|
@@ -18,37 +18,38 @@ def setup
|
|
18
18
|
# Set up arc shapes
|
19
19
|
index = 0
|
20
20
|
(0 ... num).each do |i|
|
21
|
-
pt
|
22
|
-
pt
|
21
|
+
pt << rand(TAU) # Random X axis rotation
|
22
|
+
pt << rand(TAU) # Random Y axis rotation
|
23
23
|
|
24
|
-
pt
|
24
|
+
pt << rand(60 .. 80) # Short to quarter-circle arcs
|
25
25
|
if (rand(100)>90)
|
26
26
|
pt[pt.length - 1] = rand(8 .. 27) * 10
|
27
27
|
end
|
28
|
-
pt
|
28
|
+
pt << rand(2 .. 50) * 5 # Radius. Space them out nicely
|
29
29
|
|
30
|
-
pt
|
30
|
+
pt << rand(4 .. 32) # Width of band
|
31
31
|
if (rand(100) > 90)
|
32
32
|
pt[pt.length - 1] = rand(40 .. 60) # Width of band
|
33
33
|
end
|
34
34
|
|
35
|
-
pt
|
35
|
+
pt << rand(0.005 .. 0.0334)# Speed of rotation
|
36
36
|
|
37
37
|
# get colors
|
38
38
|
prob = rand(100)
|
39
|
-
|
39
|
+
case prob
|
40
|
+
when (0 .. 30)
|
40
41
|
style[i*2] = color_blended(rand, 255,0,100, 255,0,0, 210)
|
41
|
-
|
42
|
+
when (30 .. 70)
|
42
43
|
style[i*2] = color_blended(rand, 0,153,255, 170,225,255, 210)
|
43
|
-
|
44
|
+
when (70 .. 90)
|
44
45
|
style[i*2] = color_blended(rand, 200,255,0, 150,255,0, 210)
|
45
46
|
else
|
46
47
|
style[i*2] = color(255,255,255, 220)
|
47
48
|
end
|
48
|
-
|
49
|
-
|
49
|
+
case prob
|
50
|
+
when (0 .. 50)
|
50
51
|
style[i*2] = color_blended(rand, 200,255,0, 50,120,0, 210)
|
51
|
-
|
52
|
+
when (50 .. 90)
|
52
53
|
style[i*2] = color_blended(rand, 255,100,0, 255,255,0, 210)
|
53
54
|
else
|
54
55
|
style[i*2] = color(255, 255, 255, 220)
|
@@ -78,13 +79,14 @@ def draw
|
|
78
79
|
rotate_x(pt[index])
|
79
80
|
rotate_y(pt[index + 1])
|
80
81
|
index += 2
|
81
|
-
|
82
|
+
case (style[i*2+1])
|
83
|
+
when 0
|
82
84
|
stroke(style[i*2])
|
83
85
|
no_fill
|
84
86
|
stroke_weight(1)
|
85
87
|
arc_line(0,0, pt[index],pt[index + 1],pt[index + 2])
|
86
88
|
index += 3
|
87
|
-
|
89
|
+
when 1
|
88
90
|
fill(style[i*2])
|
89
91
|
no_stroke
|
90
92
|
arc_line_bars(0,0, pt[index],pt[index + 1],pt[index + 2])
|
@@ -113,7 +115,7 @@ def color_blended(fract, r, g, b, r2, g2, b2, a)
|
|
113
115
|
r2 = (r2 - r)
|
114
116
|
g2 = (g2 - g)
|
115
117
|
b2 = (b2 - b)
|
116
|
-
|
118
|
+
color(r + r2 * fract, g + g2 * fract, b + b2 * fract, a)
|
117
119
|
end
|
118
120
|
|
119
121
|
|
@@ -124,7 +126,7 @@ def arc_line(x, y, deg, rad, w)
|
|
124
126
|
(0 ... numlines).each do
|
125
127
|
begin_shape
|
126
128
|
(0 ... a).each do |i|
|
127
|
-
vertex(cos(i
|
129
|
+
vertex(DegLut.cos(i)*rad+x,DegLut.sin(i)*rad+y)
|
128
130
|
end
|
129
131
|
end_shape
|
130
132
|
rad += 2
|
@@ -136,21 +138,21 @@ def arc_line_bars(x, y, deg, rad, w)
|
|
136
138
|
a=(deg < 360)? deg / 16 : 0
|
137
139
|
begin_shape(QUADS)
|
138
140
|
(0 ... a).step(4) do |i|
|
139
|
-
vertex(cos(i
|
140
|
-
vertex(cos(i
|
141
|
-
vertex(cos((i + 2)
|
142
|
-
vertex(cos((i + 2)
|
141
|
+
vertex(DegLut.cos(i)*(rad)+x,DegLut.sin(i)*(rad)+y)
|
142
|
+
vertex(DegLut.cos(i)*(rad+w)+x,DegLut.sin(i)*(rad+w)+y)
|
143
|
+
vertex(DegLut.cos((i + 2))*(rad+w)+x,DegLut.sin((i + 2))*(rad+w)+y)
|
144
|
+
vertex(DegLut.cos((i + 2))*(rad)+x,DegLut.sin((i + 2))*(rad)+y)
|
143
145
|
end
|
144
146
|
end_shape
|
145
147
|
end
|
146
148
|
|
147
149
|
# Draw solid arc
|
148
|
-
def arc(x,y,deg,rad,w)
|
150
|
+
def arc(x, y, deg, rad, w)
|
149
151
|
a = (deg < 360)? deg : 0
|
150
152
|
begin_shape(QUAD_STRIP)
|
151
153
|
(0 ... a).each do |i|
|
152
|
-
vertex(cos(i
|
153
|
-
vertex(cos(i
|
154
|
+
vertex(DegLut.cos(i)*(rad)+x,DegLut.sin(i)*(rad)+y)
|
155
|
+
vertex(DegLut.cos(i)*(rad+w)+x,DegLut.sin(i)*(rad+w)+y)
|
154
156
|
end
|
155
157
|
end_shape
|
156
158
|
end
|
@@ -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
|
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
|
@@ -0,0 +1,23 @@
|
|
1
|
+
load_library :vecmath
|
2
|
+
|
3
|
+
############################
|
4
|
+
# Use mouse drag to rotate
|
5
|
+
# the arcball. Use mousewheel
|
6
|
+
# to zoom. Hold down x, y, z
|
7
|
+
# to constrain rotation axis.
|
8
|
+
############################
|
9
|
+
|
10
|
+
def setup
|
11
|
+
size(600, 600, P3D)
|
12
|
+
smooth(16)
|
13
|
+
ArcBall.init(self, 300, 300)
|
14
|
+
fill 180
|
15
|
+
end
|
16
|
+
|
17
|
+
def draw
|
18
|
+
background(50)
|
19
|
+
box(300, 300, 300)
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
load_library :vecmath
|
2
|
+
|
3
|
+
############################
|
4
|
+
# Use mouse drag to rotate
|
5
|
+
# the arcball. Use mousewheel
|
6
|
+
# to zoom. Hold down x, y, z
|
7
|
+
# to constrain rotation axis.
|
8
|
+
############################
|
9
|
+
|
10
|
+
def setup
|
11
|
+
size(600, 600, P3D)
|
12
|
+
smooth(16)
|
13
|
+
ArcBall.init(self, 300, 300, 250)
|
14
|
+
fill 180
|
15
|
+
end
|
16
|
+
|
17
|
+
def draw
|
18
|
+
background(50)
|
19
|
+
box(300, 300, 300)
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
load_library :vecmath
|
2
|
+
|
3
|
+
attr_reader :my_cube
|
4
|
+
|
5
|
+
def setup
|
6
|
+
size(600, 600, P3D)
|
7
|
+
smooth(16)
|
8
|
+
ArcBall.init(self)
|
9
|
+
@my_cube = create_shape(BOX, 400, 400, 400)
|
10
|
+
my_cube.set_fill(color(100, 10, 100))
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
def draw
|
15
|
+
background(50, 50, 100)
|
16
|
+
define_lights
|
17
|
+
lights
|
18
|
+
stroke(0)
|
19
|
+
shape(my_cube)
|
20
|
+
end
|
21
|
+
|
22
|
+
def define_lights
|
23
|
+
ambient(20, 20, 20)
|
24
|
+
ambient_light(50, 50, 50)
|
25
|
+
point_light(30, 30, 30, 200, -150, 0)
|
26
|
+
directional_light(0, 30, 50, 1, 0, 0)
|
27
|
+
spot_light(30, 30, 30, 0, 40, 200, 0, -0.5, -0.5, PI / 2, 2)
|
28
|
+
end
|
29
|
+
|