ruby-processing 1.0.9 → 1.0.10.1

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.
Files changed (193) hide show
  1. data/CHANGELOG +13 -1
  2. data/bin/rp5 +8 -2
  3. data/lib/core/core.jar +0 -0
  4. data/lib/core/jruby-complete.jar +0 -0
  5. data/lib/ruby-processing.rb +2 -2
  6. data/lib/ruby-processing/app.rb +108 -338
  7. data/lib/ruby-processing/config.rb +6 -0
  8. data/lib/ruby-processing/helper_methods.rb +120 -0
  9. data/lib/ruby-processing/library_loader.rb +140 -0
  10. data/lib/ruby-processing/runner.rb +34 -4
  11. data/lib/ruby-processing/runners/base.rb +10 -11
  12. data/lib/ruby-processing/runners/live.rb +1 -1
  13. data/lib/ruby-processing/runners/run.rb +1 -1
  14. data/lib/ruby-processing/runners/watch.rb +18 -76
  15. data/lib/templates/applet/index.html.erb +8 -9
  16. data/library/control_panel/control_panel.rb +1 -1
  17. data/library/dxf/library/dxf.jar +0 -0
  18. data/library/dxf/library/export.txt +1 -0
  19. data/library/javascript/library/export.txt +3 -1
  20. data/library/minim/library/export.txt +1 -0
  21. data/library/minim/library/jl1.0.jar +0 -0
  22. data/library/minim/library/jsminim.jar +0 -0
  23. data/library/minim/library/minim-spi.jar +0 -0
  24. data/library/minim/library/minim.jar +0 -0
  25. data/library/minim/library/mp3spi1.9.4.jar +0 -0
  26. data/library/minim/library/tritonus_aos.jar +0 -0
  27. data/library/minim/library/tritonus_share.jar +0 -0
  28. data/library/net/library/export.txt +1 -0
  29. data/library/net/library/net.jar +0 -0
  30. data/library/opengl/library/export.txt +7 -10
  31. data/library/opengl/library/gluegen-rt.jar +0 -0
  32. data/library/opengl/library/jogl.jar +0 -0
  33. data/library/opengl/library/{libgluegen-rt.so → linux32/libgluegen-rt.so} +0 -0
  34. data/library/opengl/library/{libjogl.so → linux32/libjogl.so} +0 -0
  35. data/library/opengl/library/{libjogl_awt.so → linux32/libjogl_awt.so} +0 -0
  36. data/library/opengl/library/{libjogl_cg.so → linux32/libjogl_cg.so} +0 -0
  37. data/library/opengl/library/linux64/libgluegen-rt.so +0 -0
  38. data/library/opengl/library/linux64/libjogl.so +0 -0
  39. data/library/opengl/library/linux64/libjogl_awt.so +0 -0
  40. data/library/opengl/library/linux64/libjogl_cg.so +0 -0
  41. data/library/opengl/library/{libgluegen-rt.jnilib → macosx/libgluegen-rt.jnilib} +0 -0
  42. data/library/opengl/library/{libjogl.jnilib → macosx/libjogl.jnilib} +0 -0
  43. data/library/opengl/library/{libjogl_awt.jnilib → macosx/libjogl_awt.jnilib} +0 -0
  44. data/library/opengl/library/{libjogl_cg.jnilib → macosx/libjogl_cg.jnilib} +0 -0
  45. data/library/opengl/library/opengl.jar +0 -0
  46. data/library/opengl/library/{gluegen-rt.dll → windows32/gluegen-rt.dll} +0 -0
  47. data/library/opengl/library/{jogl.dll → windows32/jogl.dll} +0 -0
  48. data/library/opengl/library/{jogl_awt.dll → windows32/jogl_awt.dll} +0 -0
  49. data/library/opengl/library/{jogl_cg.dll → windows32/jogl_cg.dll} +0 -0
  50. data/library/opengl/library/windows64/gluegen-rt.dll +0 -0
  51. data/library/opengl/library/windows64/jogl.dll +0 -0
  52. data/library/opengl/library/windows64/jogl_awt.dll +0 -0
  53. data/library/opengl/library/windows64/jogl_cg.dll +0 -0
  54. data/library/pdf/library/export.txt +1 -0
  55. data/library/pdf/library/itext.jar +0 -0
  56. data/library/pdf/library/pdf.jar +0 -0
  57. data/library/serial/library/RXTXcomm.jar +0 -0
  58. data/library/serial/library/export.txt +1 -3
  59. data/library/serial/library/linux32/librxtxSerial.so +0 -0
  60. data/library/serial/library/linux64/librxtxSerial.so +0 -0
  61. data/library/serial/library/macosx/librxtxSerial.jnilib +0 -0
  62. data/library/serial/library/serial.jar +0 -0
  63. data/library/serial/library/windows32/rxtxSerial.dll +0 -0
  64. data/library/serial/library/windows64/rxtxSerial.dll +0 -0
  65. data/library/video/library/export.txt +1 -0
  66. data/library/video/library/video.jar +0 -0
  67. data/samples/{animator.rb → contributed/animator.rb} +0 -0
  68. data/samples/{bezier_playground.rb → contributed/bezier_playground.rb} +0 -0
  69. data/samples/{circle_collision.rb → contributed/circle_collision.rb} +0 -0
  70. data/samples/contributed/drawolver.rb +182 -0
  71. data/samples/{empathy.rb → contributed/empathy.rb} +7 -7
  72. data/samples/{fern.rb → contributed/fern.rb} +0 -0
  73. data/samples/{flight_patterns.rb → contributed/flight_patterns.rb} +0 -0
  74. data/samples/{full_screen.rb → contributed/full_screen.rb} +0 -0
  75. data/samples/{getting_started.rb → contributed/getting_started.rb} +0 -0
  76. data/samples/{gravity.rb → contributed/gravity.rb} +0 -0
  77. data/samples/{jwishy.rb → contributed/jwishy.rb} +0 -0
  78. data/samples/{orbit.rb → contributed/orbit.rb} +0 -0
  79. data/samples/{pong.rb → contributed/pong.rb} +0 -0
  80. data/samples/{reflection.rb → contributed/reflection.rb} +0 -0
  81. data/samples/{simple_buffer.rb → contributed/simple_buffer.rb} +0 -0
  82. data/samples/{tree.rb → contributed/tree.rb} +0 -0
  83. data/samples/peasy_cam/library/hilbert/hilbert.rb +11 -10
  84. data/samples/processing_app/3D/camera/move_eye.rb +29 -0
  85. data/samples/processing_app/3D/form/brick_tower.rb +11 -11
  86. data/samples/processing_app/3D/form/cubic_grid.rb +51 -0
  87. data/samples/processing_app/3D/form/icosahedra/icosahedra.rb +76 -0
  88. data/samples/processing_app/3D/form/icosahedra/icosahedron.rb +116 -0
  89. data/samples/processing_app/3D/form/icosahedra/shape_3D.rb +25 -0
  90. data/samples/processing_app/3D/form/primitives.rb +42 -0
  91. data/samples/processing_app/3D/form/rgb_cube.rb +88 -0
  92. data/samples/processing_app/3D/form/shape_transform.rb +94 -0
  93. data/samples/processing_app/3D/form/toroid.rb +130 -0
  94. data/samples/processing_app/3D/form/vertices.rb +81 -0
  95. data/samples/processing_app/3D/image/data/eames.jpg +0 -0
  96. data/samples/processing_app/3D/image/data/ystone08.jpg +0 -0
  97. data/samples/processing_app/3D/image/explode.rb +56 -0
  98. data/samples/processing_app/3D/image/extrusion.rb +49 -0
  99. data/samples/processing_app/3D/image/zoom.rb +83 -0
  100. data/samples/processing_app/3D/lights/directional.rb +41 -0
  101. data/samples/processing_app/3D/lights/lights1.rb +39 -0
  102. data/samples/processing_app/3D/lights/lights2.rb +42 -0
  103. data/samples/processing_app/3D/lights/reflection.rb +38 -0
  104. data/samples/processing_app/3D/lights/spot.rb +39 -0
  105. data/samples/processing_app/3D/textures/data/berlin-1.jpg +0 -0
  106. data/samples/processing_app/3D/textures/texture1.rb +41 -0
  107. data/samples/processing_app/3D/textures/texture2.rb +38 -0
  108. data/samples/processing_app/3D/textures/texture3.rb +68 -0
  109. data/samples/processing_app/3D/textures/texture_cube.rb +106 -0
  110. data/samples/processing_app/3D/transform/bird.rb +61 -0
  111. data/samples/processing_app/3D/transform/birds/bird.rb +87 -0
  112. data/samples/processing_app/3D/transform/birds/birds.rb +48 -0
  113. data/samples/processing_app/3D/transform/cubes_in_cube/cube.rb +57 -0
  114. data/samples/processing_app/3D/transform/cubes_in_cube/cubes_in_cube.rb +102 -0
  115. data/samples/processing_app/3D/transform/push_pop_cubes.rb +152 -0
  116. data/samples/processing_app/3D/transform/rotate1.rb +43 -0
  117. data/samples/processing_app/3D/transform/rotate2.rb +45 -0
  118. data/samples/processing_app/3D/typography/data/Univers45.vlw +0 -0
  119. data/samples/processing_app/3D/typography/letter_k.rb +136 -0
  120. data/samples/processing_app/3D/typography/typing.rb +77 -0
  121. data/samples/processing_app/basics/form/triangle_strip.rb +19 -19
  122. data/samples/processing_app/basics/math/distance1.rb +59 -0
  123. data/samples/processing_app/basics/math/distance2.rb +38 -0
  124. data/samples/processing_app/basics/math/double_random.rb +38 -0
  125. data/samples/processing_app/basics/math/graphing_2_d_equation.rb +53 -0
  126. data/samples/processing_app/basics/math/increment_decrement.rb +59 -0
  127. data/samples/processing_app/basics/math/modulo.rb +43 -0
  128. data/samples/processing_app/basics/math/noise_1_d.rb +37 -0
  129. data/samples/processing_app/basics/math/noise_2_d.rb +47 -0
  130. data/samples/processing_app/basics/math/noise_3_d.rb +50 -0
  131. data/samples/processing_app/basics/math/noise_wave.rb +61 -0
  132. data/samples/processing_app/basics/math/operator_precedence.rb +70 -0
  133. data/samples/processing_app/basics/math/polar_to_cartesian.rb +44 -0
  134. data/samples/processing_app/basics/math/random.rb +35 -0
  135. data/samples/processing_app/basics/math/sine.rb +49 -0
  136. data/samples/processing_app/basics/math/sine_cosine.rb +60 -0
  137. data/samples/processing_app/basics/math/sine_wave.rb +62 -0
  138. data/samples/processing_app/basics/objects/composite_objects.rb +139 -0
  139. data/samples/processing_app/basics/objects/inheritance.rb +104 -0
  140. data/samples/processing_app/basics/objects/multiple_constructors.rb +66 -0
  141. data/samples/processing_app/basics/objects/objects.rb +72 -0
  142. data/samples/processing_app/basics/shape/data/bot1.svg +160 -0
  143. data/samples/processing_app/basics/shape/data/usa-wikipedia.svg +452 -0
  144. data/samples/processing_app/basics/shape/disable_style.rb +36 -0
  145. data/samples/processing_app/basics/shape/get_child.rb +43 -0
  146. data/samples/processing_app/basics/shape/load_display_shape.rb +33 -0
  147. data/samples/processing_app/basics/shape/scale_shape.rb +33 -0
  148. data/samples/processing_app/basics/structure/coordinates.rb +55 -0
  149. data/samples/processing_app/basics/structure/create_graphics.rb +39 -0
  150. data/samples/processing_app/basics/structure/functions.rb +41 -0
  151. data/samples/processing_app/basics/structure/loop.rb +39 -0
  152. data/samples/processing_app/basics/structure/noloop.rb +33 -0
  153. data/samples/processing_app/basics/structure/recursion1.rb +42 -0
  154. data/samples/processing_app/basics/structure/recursion2.rb +39 -0
  155. data/samples/processing_app/basics/structure/redraw.rb +36 -0
  156. data/samples/processing_app/basics/structure/setup_draw.rb +30 -0
  157. data/samples/processing_app/basics/structure/statements_comments.rb +32 -0
  158. data/samples/processing_app/basics/structure/width_height.rb +29 -0
  159. data/samples/processing_app/basics/transform/arm.rb +47 -0
  160. data/samples/processing_app/basics/transform/rotate.rb +43 -0
  161. data/samples/processing_app/basics/transform/scale.rb +45 -0
  162. data/samples/processing_app/basics/transform/translate.rb +41 -0
  163. data/samples/processing_app/basics/transform/triangle_flower.rb +69 -0
  164. data/samples/processing_app/basics/typography/data/CourierNew36.vlw +0 -0
  165. data/samples/processing_app/basics/typography/data/Ziggurat-HTF-Black-32.vlw +0 -0
  166. data/samples/processing_app/basics/typography/letters.rb +52 -0
  167. data/samples/processing_app/basics/typography/words.rb +37 -0
  168. data/samples/processing_app/basics/web/embedded_links.rb +58 -0
  169. data/samples/processing_app/basics/web/loading_images.rb +25 -0
  170. metadata +181 -86
  171. data/lib/patches/JRubyApplet.diff +0 -24
  172. data/lib/patches/PATCHES.txt +0 -3
  173. data/lib/patches/PApplet.diff +0 -27
  174. data/library/minim/license.txt +0 -339
  175. data/library/minim/version.txt +0 -1
  176. data/library/opengl/library/gluegen-rt-natives-linux-amd64.jar +0 -0
  177. data/library/opengl/library/gluegen-rt-natives-linux-i586.jar +0 -0
  178. data/library/opengl/library/gluegen-rt-natives-macosx-ppc.jar +0 -0
  179. data/library/opengl/library/gluegen-rt-natives-macosx-universal.jar +0 -0
  180. data/library/opengl/library/gluegen-rt-natives-windows-amd64.jar +0 -0
  181. data/library/opengl/library/gluegen-rt-natives-windows-i586.jar +0 -0
  182. data/library/opengl/library/gluegen-rt.jar.pack.gz +0 -0
  183. data/library/opengl/library/jogl-natives-linux-amd64.jar +0 -0
  184. data/library/opengl/library/jogl-natives-linux-i586.jar +0 -0
  185. data/library/opengl/library/jogl-natives-macosx-ppc.jar +0 -0
  186. data/library/opengl/library/jogl-natives-macosx-universal.jar +0 -0
  187. data/library/opengl/library/jogl-natives-windows-amd64.jar +0 -0
  188. data/library/opengl/library/jogl-natives-windows-i586.jar +0 -0
  189. data/library/opengl/library/jogl.jar.pack.gz +0 -0
  190. data/library/pdf/notes.txt +0 -8
  191. data/library/serial/library/librxtxSerial.jnilib +0 -0
  192. data/library/serial/library/librxtxSerial.so +0 -0
  193. data/library/serial/library/rxtxSerial.dll +0 -0
@@ -1,11 +1,11 @@
1
1
  require 'ruby-processing'
2
2
 
3
3
  # TRIANGLE_STRIP Mode
4
- # by Ira Greenberg.
5
- #
6
- # Generate a closed ring using vertex()
4
+ # by Ira Greenberg.
5
+ #
6
+ # Generate a closed ring using vertex()
7
7
  # function and beginShape(TRIANGLE_STRIP)
8
- # mode. outerRad and innerRad variables
8
+ # mode. outerRad and innerRad variables
9
9
  # control ring's outer/inner radii respectively.
10
10
  # Trig functions generate ring.
11
11
 
@@ -14,7 +14,7 @@ class TriangleStrip < Processing::App
14
14
  def setup
15
15
  background 204
16
16
  smooth
17
-
17
+
18
18
  x = width/2
19
19
  y = height/2
20
20
  outer_radius = 80
@@ -22,22 +22,22 @@ class TriangleStrip < Processing::App
22
22
  px, py, angle = 0.0, 0.0, 0.0
23
23
  number_of_points = 36
24
24
  rotation = 360.0/number_of_points
25
-
26
- shape(TRIANGLE_STRIP) do
27
- number_of_points.times do |i|
28
- px = x + cos(angle.radians)*outer_radius
29
- py = y + sin(angle.radians)*outer_radius
30
- angle += rotation
31
- vertex px, py
32
-
33
- px = x + cos(angle.radians)*inner_radius
34
- py = y + sin(angle.radians)*inner_radius
35
- angle += rotation
36
- vertex px, py
37
- end
25
+
26
+ begin_shape TRIANGLE_STRIP
27
+ number_of_points.times do |i|
28
+ px = x + cos(angle.radians)*outer_radius
29
+ py = y + sin(angle.radians)*outer_radius
30
+ angle += rotation
31
+ vertex px, py
32
+
33
+ px = x + cos(angle.radians)*inner_radius
34
+ py = y + sin(angle.radians)*inner_radius
35
+ angle += rotation
36
+ vertex px, py
38
37
  end
38
+ end_shape
39
39
  end
40
-
40
+
41
41
  end
42
42
 
43
43
  TriangleStrip.new :title => "Triangle Strip", :width => 200, :height => 200
@@ -0,0 +1,59 @@
1
+ # Distance 1D.
2
+ #
3
+ # Move the mouse left and right to control the
4
+ # speed and direction of the moving shapes.
5
+
6
+ class Distance1 < Processing::App
7
+
8
+ def setup
9
+
10
+ size 200, 200
11
+ no_stroke
12
+ frame_rate 60
13
+
14
+ @thin = 8
15
+ @thick = 36
16
+ @xpos1 = 134
17
+ @xpos2 = 44
18
+ @xpos3 = 58
19
+ @xpos4 = 120
20
+
21
+ end
22
+
23
+ def draw
24
+
25
+ background 0
26
+
27
+ mx = mouse_x * 0.4 - width / 5.0
28
+
29
+ fill 102
30
+ rect @xpos2, 0, @thick, height/2
31
+
32
+ fill 204
33
+ rect @xpos1, 0, @thin, height/2
34
+
35
+ fill 102
36
+ rect @xpos4, height/2, @thick, height/2
37
+
38
+ fill 204
39
+ rect @xpos3, height/2, @thin, height/2
40
+
41
+ @xpos1 += mx/16
42
+ @xpos2 += mx/64
43
+ @xpos3 -= mx/16
44
+ @xpos4 -= mx/64
45
+
46
+ @xpos1 = width if @xpos1 < -@thin
47
+ @xpos1 = -@thin if @xpos1 > width
48
+ @xpos2 = width if @xpos2 < -@thick
49
+ @xpos2 = -@thick if @xpos2 > width
50
+ @xpos3 = width if @xpos3 < -@thin
51
+ @xpos3 = -@thin if @xpos3 > width
52
+ @xpos4 = width if @xpos4 < -@thick
53
+ @xpos4 = -@thick if @xpos4 > width
54
+
55
+ end
56
+
57
+ end
58
+
59
+ Distance1.new :title => "Distance1"
@@ -0,0 +1,38 @@
1
+ # Distance 2D.
2
+ #
3
+ # Move the mouse across the image to obscure and reveal the matrix.
4
+ # Measures the distance from the mouse to each square and sets the
5
+ # size proportionally.
6
+
7
+ class Distance2 < Processing::App
8
+
9
+ def setup
10
+
11
+ size 200, 200
12
+
13
+ smooth
14
+ no_stroke
15
+ @max_distance = dist 0, 0, width, height
16
+
17
+ end
18
+
19
+ def draw
20
+
21
+ background 51
22
+
23
+ (0..width).step( 20 ) { |i|
24
+
25
+ (0..height).step( 20 ) { |j|
26
+
27
+ size = dist mouse_x, mouse_y, i, j
28
+ size = size / @max_distance * 66
29
+
30
+ ellipse i, j, size, size
31
+ }
32
+ }
33
+
34
+ end
35
+
36
+ end
37
+
38
+ Distance2.new :title => "Distance2"
@@ -0,0 +1,38 @@
1
+ # Double Random
2
+ # by Ira Greenberg.
3
+ #
4
+ # Using two random() calls and the point() function
5
+ # to create an irregular sawtooth line.
6
+
7
+ class DoubleRandom < Processing::App
8
+
9
+ def setup
10
+
11
+ size 200, 200
12
+
13
+ background 0
14
+
15
+ total_pts = 300
16
+
17
+ steps = total_pts + 1.0
18
+
19
+ stroke 255
20
+
21
+ rand = 0
22
+
23
+ (1...steps).each { |i|
24
+
25
+ point( (width/steps) * i, height/2 + random( -rand, rand ) )
26
+ rand += random( -5, 5 )
27
+
28
+ }
29
+
30
+ end
31
+
32
+ def draw
33
+
34
+ end
35
+
36
+ end
37
+
38
+ DoubleRandom.new :title => "Double Random"
@@ -0,0 +1,53 @@
1
+ # Graphing 2D Equations
2
+ # by Daniel Shiffman.
3
+ #
4
+ # Graphics the following equation:
5
+ # sin(n*cos(r) + 5*theta)
6
+ # where n is a function of horizontal mouse location.
7
+
8
+ class Graphing2DEquation < Processing::App
9
+
10
+ def setup
11
+
12
+ size 200, 200
13
+ frame_rate 30
14
+
15
+ end
16
+
17
+ def draw
18
+
19
+ load_pixels
20
+
21
+ n = mouse_x * 10.0 / width
22
+ w = 16.0
23
+ h = 16.0
24
+ dx = w / width
25
+ dy = h / height
26
+ x = -w / 2
27
+
28
+ (0...width).each { |i|
29
+
30
+ y = -h / 2
31
+
32
+ (0...height).each { |j|
33
+
34
+ r = sqrt( x*x + y*y )
35
+ theta = atan2 y, x
36
+
37
+ val = sin( n*cos(r) + 5 * theta)
38
+
39
+ pixels[i+j*width] = color( map( val, -1, 1, 0, 255) )
40
+
41
+ y += dy
42
+ }
43
+
44
+ x += dx
45
+ }
46
+
47
+ update_pixels
48
+
49
+ end
50
+
51
+ end
52
+
53
+ Graphing2DEquation.new :title => "Graphing 2 D Equation"
@@ -0,0 +1,59 @@
1
+ # Increment Decrement.
2
+ #
3
+ # In Java and C ...
4
+ # Writing "a++" is equivalent to "a = a + 1".
5
+ # Writing "a--" is equivalent to "a = a - 1".
6
+
7
+ # In Ruby there is += 1 and -= 1:
8
+ # a += 1 is equal to a = a + 1
9
+
10
+ class IncrementDecrement < Processing::App
11
+
12
+ def setup
13
+
14
+ size 200, 200
15
+
16
+ color_mode RGB, width
17
+
18
+ @a = 0
19
+ @b = width
20
+ @direction = false
21
+
22
+ frame_rate 30
23
+
24
+ end
25
+
26
+ def draw
27
+
28
+ @a += 1
29
+
30
+ if @a > width
31
+ @a = 0
32
+ @direction = !@direction
33
+ end
34
+
35
+ if @direction
36
+ stroke @a
37
+ else
38
+ stroke width-@a
39
+ end
40
+
41
+ line @a, 0, @a, height/2
42
+
43
+ @b -= 1
44
+
45
+ @b = width if @b < 0
46
+
47
+ if @direction
48
+ stroke width-@b
49
+ else
50
+ stroke @b
51
+ end
52
+
53
+ line @b, height/2+1, @b, height
54
+
55
+ end
56
+
57
+ end
58
+
59
+ IncrementDecrement.new :title => "Increment Decrement"
@@ -0,0 +1,43 @@
1
+ # Modulo.
2
+ #
3
+ # The modulo operator (%) returns the remainder of a number
4
+ # divided by another. As in this example, it is often used
5
+ # to keep numerical values within a set range.
6
+
7
+ class Modulo < Processing::App
8
+
9
+ def setup
10
+
11
+ size 200, 200
12
+
13
+ @c = 0.0
14
+ @num = 20
15
+
16
+ fill 255
17
+ frame_rate 30
18
+
19
+ end
20
+
21
+ def draw
22
+
23
+ background 0
24
+
25
+ @c += 0.1
26
+
27
+ (1...(height/@num)).each { |i|
28
+
29
+ x = (@c %i ) * i * i
30
+ stroke 102
31
+
32
+ line 0, i*@num, x, i*@num
33
+
34
+ no_stroke
35
+
36
+ rect x, i*@num-@num/2, 8, @num
37
+ }
38
+
39
+ end
40
+
41
+ end
42
+
43
+ Modulo.new :title => "Modulo"
@@ -0,0 +1,37 @@
1
+ # Noise1D.
2
+ #
3
+ # Using 1D Perlin Noise to assign location.
4
+
5
+ class Noise1D < Processing::App
6
+
7
+ def setup
8
+
9
+ size 200, 200
10
+
11
+ @xoff = 0.0
12
+ @x_increment = 0.01
13
+
14
+ background 0
15
+ frame_rate 30
16
+ smooth
17
+ no_stroke
18
+
19
+ end
20
+
21
+ def draw
22
+
23
+ fill 0, 10
24
+ rect 0, 0, width, height
25
+
26
+ n = noise( @xoff ) * width
27
+
28
+ @xoff += @x_increment
29
+
30
+ fill 200
31
+ ellipse n, height/2, 16, 16
32
+
33
+ end
34
+
35
+ end
36
+
37
+ Noise1D.new :title => "Noise 1 D"
@@ -0,0 +1,47 @@
1
+ # Noise2D
2
+ # by Daniel Shiffman.
3
+ #
4
+ # Using 2D noise to create simple texture.
5
+
6
+ class Noise2D < Processing::App
7
+
8
+ def setup
9
+
10
+ size 200, 200
11
+
12
+ @increment = 0.02
13
+
14
+ no_loop
15
+
16
+ end
17
+
18
+ def draw
19
+
20
+ background 0
21
+
22
+ load_pixels
23
+
24
+ xoff = 0.0
25
+
26
+ (0...width).each { |x|
27
+
28
+ xoff += @increment
29
+ yoff = 0.0
30
+
31
+ (0...height).each { |y|
32
+
33
+ yoff += @increment
34
+
35
+ bright = noise( xoff, yoff) * 255
36
+
37
+ pixels[x+y*width] = color bright
38
+ }
39
+ }
40
+
41
+ update_pixels
42
+
43
+ end
44
+
45
+ end
46
+
47
+ Noise2D.new :title => "Noise 2 D"