ruby-processing 2.4.2 → 2.4.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,7 +7,7 @@ class CA
7
7
  def initialize(rules = [])
8
8
  @width = $app.width
9
9
  @height = $app.height
10
- if rules.length > 0
10
+ if !rules.empty?
11
11
  @rules = rules
12
12
  else
13
13
  randomize
@@ -23,7 +23,7 @@ class CA
23
23
 
24
24
  # Return a random ruleset
25
25
  def randomize
26
- @rules = Array.new(8) {(rand(100) > 50)? 1 : 0}
26
+ @rules = Array.new(8) {rand(0 .. 1)}
27
27
  end
28
28
 
29
29
  # Reset to generation 0
@@ -86,6 +86,6 @@ class CA
86
86
 
87
87
  # The CA is done if it reaches the bottom of the screen
88
88
  def finished?
89
- return (generation > (height/SCL))
89
+ generation > (height/SCL)
90
90
  end
91
91
  end
@@ -0,0 +1,30 @@
1
+ # Simple demo Rakefile to autorun samples in current directory
2
+ # adjust path to rp5 executable, and or opts as required
3
+
4
+ SAMPLES_DIR="./"
5
+
6
+ desc 'run demo'
7
+ task :default => [:demo]
8
+
9
+ desc 'demo'
10
+ task :demo do
11
+ samples_list.shuffle.each{|sample| run_sample sample}
12
+ end
13
+
14
+ def samples_list
15
+ files = []
16
+ Dir.chdir(SAMPLES_DIR)
17
+ Dir.glob("*.rb").each do |file|
18
+ files << File.join(SAMPLES_DIR, file)
19
+ end
20
+ return files
21
+ end
22
+
23
+ def run_sample(sample_name)
24
+ puts "Running #{sample_name}...quit to run next sample"
25
+ open("|rp5 run #{sample_name}", "r") do |io|
26
+ while l = io.gets
27
+ puts(l.chop)
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,30 @@
1
+ # Simple demo Rakefile to autorun samples in current directory
2
+ # adjust path to rp5 executable, and or opts as required
3
+
4
+ SAMPLES_DIR="./"
5
+
6
+ desc 'run demo'
7
+ task :default => [:demo]
8
+
9
+ desc 'demo'
10
+ task :demo do
11
+ samples_list.shuffle.each{|sample| run_sample sample}
12
+ end
13
+
14
+ def samples_list
15
+ files = []
16
+ Dir.chdir(SAMPLES_DIR)
17
+ Dir.glob("*.rb").each do |file|
18
+ files << File.join(SAMPLES_DIR, file)
19
+ end
20
+ return files
21
+ end
22
+
23
+ def run_sample(sample_name)
24
+ puts "Running #{sample_name}...quit to run next sample"
25
+ open("|rp5 run #{sample_name}", "r") do |io|
26
+ while l = io.gets
27
+ puts(l.chop)
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,30 @@
1
+ # Simple demo Rakefile to autorun samples in current directory
2
+ # adjust path to rp5 executable, and or opts as required
3
+
4
+ SAMPLES_DIR="./"
5
+
6
+ desc 'run demo'
7
+ task :default => [:demo]
8
+
9
+ desc 'demo'
10
+ task :demo do
11
+ samples_list.shuffle.each{|sample| run_sample sample}
12
+ end
13
+
14
+ def samples_list
15
+ files = []
16
+ Dir.chdir(SAMPLES_DIR)
17
+ Dir.glob("*.rb").each do |file|
18
+ files << File.join(SAMPLES_DIR, file)
19
+ end
20
+ return files
21
+ end
22
+
23
+ def run_sample(sample_name)
24
+ puts "Running #{sample_name}...quit to run next sample"
25
+ open("|rp5 --nojruby run #{sample_name}", "r") do |io|
26
+ while l = io.gets
27
+ puts(l.chop)
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,59 @@
1
+ // Inspired by the "Angular Fisheye à la Bourke" sketch from
2
+ // Jonathan Cremieux, as shown in the OpenProcessing website:
3
+ // http://openprocessing.org/visuals/?visualID=12140
4
+ // Using the inverse transform of the angular fisheye as
5
+ // explained in Paul Bourke's website:
6
+ // http://paulbourke.net/miscellaneous/domefisheye/fisheye/
7
+
8
+ #ifdef GL_ES
9
+ precision mediump float;
10
+ precision mediump int;
11
+ #endif
12
+
13
+ #define PROCESSING_TEXTURE_SHADER
14
+
15
+ uniform sampler2D texture;
16
+ uniform mat4 texMatrix;
17
+
18
+ varying vec4 vertColor;
19
+ varying vec4 vertTexCoord;
20
+
21
+ uniform float aperture;
22
+
23
+ const float PI = 3.1415926535;
24
+
25
+ void main(void) {
26
+ float apertureHalf = 0.5 * aperture * (PI / 180.0);
27
+
28
+ // This factor ajusts the coordinates in the case that
29
+ // the aperture angle is less than 180 degrees, in which
30
+ // case the area displayed is not the entire half-sphere.
31
+ float maxFactor = sin(apertureHalf);
32
+
33
+ // The st factor takes into account the situation when non-pot
34
+ // textures are not supported, so that the maximum texture
35
+ // coordinate to cover the entire image might not be 1.
36
+ vec2 stFactor = vec2(1.0 / abs(texMatrix[0][0]), 1.0 / abs(texMatrix[1][1]));
37
+ vec2 pos = (2.0 * vertTexCoord.st * stFactor - 1.0);
38
+
39
+ float l = length(pos);
40
+ if (l > 1.0) {
41
+ gl_FragColor = vec4(0, 0, 0, 1);
42
+ } else {
43
+ float x = maxFactor * pos.x;
44
+ float y = maxFactor * pos.y;
45
+
46
+ float n = length(vec2(x, y));
47
+
48
+ float z = sqrt(1.0 - n * n);
49
+
50
+ float r = atan(n, z) / PI;
51
+
52
+ float phi = atan(y, x);
53
+
54
+ float u = r * cos(phi) + 0.5;
55
+ float v = r * sin(phi) + 0.5;
56
+
57
+ gl_FragColor = texture2D(texture, vec2(u, v) / stFactor) * vertColor;
58
+ }
59
+ }
data/vendors/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'rake/clean'
2
2
 
3
- JRUBY_VERSION = "1.7.10"
3
+ JRUBY_VERSION = "1.7.11"
4
4
 
5
5
  CLOBBER.include("jruby-complete-#{JRUBY_VERSION}.jar")
6
6
 
@@ -12,7 +12,7 @@ task :download => ["jruby-complete-#{JRUBY_VERSION}.jar"]
12
12
 
13
13
  file "jruby-complete-#{JRUBY_VERSION}.jar" do
14
14
  sh "wget http://jruby.org.s3.amazonaws.com/downloads/#{JRUBY_VERSION}/jruby-complete-#{JRUBY_VERSION}.jar"
15
- check_sha1("jruby-complete-#{JRUBY_VERSION}.jar", "f74a8b29da11e2ea430a1d1d92b72d424f7ee311")
15
+ check_sha1("jruby-complete-#{JRUBY_VERSION}.jar", "cf627710faa842c9ea9f1e9955866703c653c5d9")
16
16
  end
17
17
 
18
18
  directory "../lib/ruby"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-processing
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.2
4
+ version: 2.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Ashkenas
@@ -18,7 +18,7 @@ authors:
18
18
  autorequire:
19
19
  bindir: bin
20
20
  cert_chain: []
21
- date: 2014-01-10 00:00:00.000000000 Z
21
+ date: 2014-02-25 00:00:00.000000000 Z
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
24
24
  name: bundler
@@ -123,8 +123,13 @@ files:
123
123
  - library/boids/boids.rb
124
124
  - library/control_panel/control_panel.rb
125
125
  - library/file_chooser/file_chooser.rb
126
+ - library/vecmath/lib/arcball.rb
127
+ - library/vecmath/lib/quaternion.rb
128
+ - library/vecmath/lib/vec.rb
126
129
  - library/vecmath/vecmath.rb
127
130
  - ruby-processing.gemspec
131
+ - samples/Rakefile
132
+ - samples/contributed/Rakefile
128
133
  - samples/contributed/animator.rb
129
134
  - samples/contributed/bezier_playground.rb
130
135
  - samples/contributed/circle_collision.rb
@@ -400,6 +405,7 @@ files:
400
405
  - samples/processing_app/library/pdf/many_pdfs.rb
401
406
  - samples/processing_app/library/pdf/one_frame.rb
402
407
  - samples/processing_app/library/vecmath/README.txt
408
+ - samples/processing_app/library/vecmath/Rakefile
403
409
  - samples/processing_app/library/vecmath/acceleration_with_vectors.rb
404
410
  - samples/processing_app/library/vecmath/bouncing_ball.rb
405
411
  - samples/processing_app/library/vecmath/circle_collision.rb
@@ -425,6 +431,7 @@ files:
425
431
  - samples/processing_app/library/vecmath/vector_math.rb
426
432
  - samples/processing_app/library/vecmath/wiggle_pshape.rb
427
433
  - samples/processing_app/topics/advanced_data/README
434
+ - samples/processing_app/topics/advanced_data/Rakefile
428
435
  - samples/processing_app/topics/advanced_data/counting_words.rb
429
436
  - samples/processing_app/topics/advanced_data/data/Georgia.ttf
430
437
  - samples/processing_app/topics/advanced_data/data/Merriweather-Light.ttf
@@ -735,6 +742,7 @@ files:
735
742
  - samples/processing_app/topics/image_processing/linear_image.rb
736
743
  - samples/processing_app/topics/image_processing/pixel_array.rb
737
744
  - samples/processing_app/topics/image_processing/zoom.rb
745
+ - samples/processing_app/topics/lsystems/Rakefile
738
746
  - samples/processing_app/topics/lsystems/chequer.rb
739
747
  - samples/processing_app/topics/lsystems/csplant.rb
740
748
  - samples/processing_app/topics/lsystems/cstest.rb
@@ -753,6 +761,7 @@ files:
753
761
  - samples/processing_app/topics/lsystems/snake_kolam.rb
754
762
  - samples/processing_app/topics/lsystems/stochastic_test.rb
755
763
  - samples/processing_app/topics/lsystems/three_d_tree.rb
764
+ - samples/processing_app/topics/motion/Rakefile
756
765
  - samples/processing_app/topics/motion/bounce.rb
757
766
  - samples/processing_app/topics/motion/bouncy_bubbles.rb
758
767
  - samples/processing_app/topics/motion/brownian.rb
@@ -768,9 +777,11 @@ files:
768
777
  - samples/processing_app/topics/motion/reflection1.rb
769
778
  - samples/processing_app/topics/motion/reflection2.rb
770
779
  - samples/processing_app/topics/shaders/README
780
+ - samples/processing_app/topics/shaders/Rakefile
771
781
  - samples/processing_app/topics/shaders/blur_filter.rb
772
782
  - samples/processing_app/topics/shaders/bw_shader.rb
773
783
  - samples/processing_app/topics/shaders/conway.rb
784
+ - samples/processing_app/topics/shaders/data/FishEye.glsl
774
785
  - samples/processing_app/topics/shaders/data/GlossyFrag.glsl
775
786
  - samples/processing_app/topics/shaders/data/GlossyVert.glsl
776
787
  - samples/processing_app/topics/shaders/data/Texture01.jpg
@@ -796,7 +807,6 @@ files:
796
807
  - samples/processing_app/topics/shaders/data/sep_blur.glsl
797
808
  - samples/processing_app/topics/shaders/data/tex1.jpg
798
809
  - samples/processing_app/topics/shaders/deform.rb
799
- - samples/processing_app/topics/shaders/dome_projection.rb
800
810
  - samples/processing_app/topics/shaders/edge_detect.rb
801
811
  - samples/processing_app/topics/shaders/glossy_fish_eye.rb
802
812
  - samples/processing_app/topics/shaders/glsl_heightmap_noise.rb
@@ -853,7 +863,7 @@ requirements:
853
863
  - java runtime >= 1.6+
854
864
  - processing = 2.0.3+
855
865
  rubyforge_project:
856
- rubygems_version: 2.1.11
866
+ rubygems_version: 2.2.0
857
867
  signing_key:
858
868
  specification_version: 4
859
869
  summary: Code as Art, Art as Code. Processing and Ruby are meant for each other.
@@ -1,143 +0,0 @@
1
- #
2
- # DomeProjection
3
- #
4
- # This sketch uses use environmental mapping to render the output
5
- # on a full spherical dome.
6
- #
7
- # Based on the FullDome_template code from Christopher Warnow:
8
- # https://github.com/mphasize/FullDome
9
- #
10
- #
11
-
12
- attr_reader :fbo, :cube_map_shader, :dome_sphere, :env_map_texture_id
13
-
14
- ENV_MAP_SIZE = 1024
15
-
16
- def setup
17
- size(640, 640, P3D)
18
- init_cube_map
19
- end
20
-
21
- def draw
22
- background(0)
23
- draw_cube_map
24
- end
25
-
26
- def draw_scene
27
- background(0)
28
- stroke(255, 0, 0)
29
- stroke_weight(2)
30
-
31
- (-width ... 2 * width).step(50) do |i|
32
- line(i, -height, -100, i, 2 * height, -100)
33
- end
34
- (-height ... 2 * height).step(50) do |i|
35
- line(-width, i, -100, 2 * width, i, -100)
36
- end
37
-
38
- lights
39
- no_stroke
40
- translate(mouse_x, mouse_y, 200)
41
- rotate_x(frame_count * 0.01)
42
- rotate_y(frame_count * 0.01)
43
- box(100)
44
- end
45
-
46
- java_import "java.nio.IntBuffer"
47
-
48
- def init_cube_map
49
- sphere_detail(50)
50
- @dome_sphere = create_shape(SPHERE, height/2.0)
51
- dome_sphere.rotate_x(HALF_PI)
52
- dome_sphere.set_stroke(false)
53
-
54
- pgl = beginPGL
55
-
56
- @env_map_texture_id = IntBuffer.allocate(1)
57
- pgl.gen_textures(1, env_map_texture_id)
58
- pgl.bind_texture(PGL::TEXTURE_CUBE_MAP, env_map_texture_id.get(0))
59
- pgl.texParameteri(PGL::TEXTURE_CUBE_MAP, PGL::TEXTURE_WRAP_S, PGL::CLAMP_TO_EDGE)
60
- pgl.texParameteri(PGL::TEXTURE_CUBE_MAP, PGL::TEXTURE_WRAP_T, PGL::CLAMP_TO_EDGE)
61
- pgl.texParameteri(PGL::TEXTURE_CUBE_MAP, PGL::TEXTURE_WRAP_R, PGL::CLAMP_TO_EDGE)
62
- pgl.texParameteri(PGL::TEXTURE_CUBE_MAP, PGL::TEXTURE_MIN_FILTER, PGL::NEAREST)
63
- pgl.texParameteri(PGL::TEXTURE_CUBE_MAP, PGL::TEXTURE_MAG_FILTER, PGL::NEAREST)
64
- (PGL::TEXTURE_CUBE_MAP_POSITIVE_X ... PGL::TEXTURE_CUBE_MAP_POSITIVE_X + 6).each do |i|
65
- pgl.texImage2D(i, 0, PGL::RGBA8, ENV_MAP_SIZE, ENV_MAP_SIZE, 0, PGL::RGBA, PGL::UNSIGNED_BYTE, nil)
66
- end
67
-
68
- # Init fbo, rbo
69
- @fbo = IntBuffer.allocate(1)
70
- rbo = IntBuffer.allocate(1)
71
- pgl.genFramebuffers(1, fbo)
72
- pgl.bindFramebuffer(PGL::FRAMEBUFFER, fbo.get(0))
73
- pgl.framebufferTexture2D(PGL::FRAMEBUFFER, PGL::COLOR_ATTACHMENT0, PGL::TEXTURE_CUBE_MAP_POSITIVE_X, env_map_texture_id.get(0), 0)
74
-
75
- pgl.genRenderbuffers(1, rbo)
76
- pgl.bindRenderbuffer(PGL::RENDERBUFFER, rbo.get(0))
77
- pgl.renderbufferStorage(PGL::RENDERBUFFER, PGL::DEPTH_COMPONENT24, ENV_MAP_SIZE, ENV_MAP_SIZE)
78
-
79
- # Attach depth buffer to FBO
80
- pgl.framebufferRenderbuffer(PGL::FRAMEBUFFER, PGL::DEPTH_ATTACHMENT, PGL::RENDERBUFFER, rbo.get(0))
81
-
82
- pgl.enable(PGL::TEXTURE_CUBE_MAP)
83
- pgl.active_texture(PGL::TEXTURE1)
84
- pgl.bind_texture(PGL::TEXTURE_CUBE_MAP, env_map_texture_id.get(0))
85
-
86
- endPGL
87
-
88
- # Load cubemap shader.
89
- @cube_map_shader = load_shader("cubemapfrag.glsl", "cubemapvert.glsl")
90
- cube_map_shader.set("cubemap", 1)
91
- end
92
-
93
- def draw_cube_map
94
- regenerateEnvMap
95
- drawDomeMaster
96
- end
97
-
98
- def drawDomeMaster
99
- ortho
100
- reset_matrix
101
- shader(cube_map_shader)
102
- shape(dome_sphere)
103
- reset_shader
104
- end
105
-
106
- # Called to regenerate the envmap
107
- def regenerateEnvMap
108
- pgl = beginPGL
109
-
110
- # bind fbo
111
- pgl.bindFramebuffer(PGL::FRAMEBUFFER, fbo.get(0))
112
-
113
- # generate 6 views from origin(0, 0, 0)
114
- pgl.viewport(0, 0, ENV_MAP_SIZE, ENV_MAP_SIZE)
115
- perspective(90.0 * DEG_TO_RAD, 1.0, 1.0, 1025.0)
116
- (PGL::TEXTURE_CUBE_MAP_POSITIVE_X ... PGL::TEXTURE_CUBE_MAP_NEGATIVE_Z).each do |face|
117
- reset_matrix
118
- case face
119
- when PGL::TEXTURE_CUBE_MAP_POSITIVE_X
120
- camera(0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, -1.0, 0.0)
121
- when PGL::TEXTURE_CUBE_MAP_NEGATIVE_X
122
- camera(0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, -1.0, 0.0)
123
- when PGL::TEXTURE_CUBE_MAP_POSITIVE_Y
124
- camera(0.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, -1.0)
125
- when PGL::TEXTURE_CUBE_MAP_NEGATIVE_Y
126
- camera(0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0)
127
- when PGL::TEXTURE_CUBE_MAP_POSITIVE_Z
128
- camera(0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, -1.0, 0.0)
129
- end
130
-
131
- scale(-1, 1, -1)
132
- translate(-width * 0.5, -height * 0.5, -500)
133
- pgl.framebufferTexture2D(PGL::FRAMEBUFFER, PGL::COLOR_ATTACHMENT0, face, env_map_texture_id.get(0), 0)
134
- draw_scene# Draw objects in the scene
135
- flush# Make sure that the geometry in the scene is pushed to the GPU
136
- no_lights # Disabling lights to avoid adding many times
137
- pgl.framebufferTexture2D(PGL::FRAMEBUFFER, PGL::COLOR_ATTACHMENT0, face, 0, 0)
138
- end
139
-
140
- endPGL
141
- end
142
-
143
-