ruby-processing 1.0.9 → 1.0.10.1

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -0,0 +1,36 @@
1
+ # Ignore Styles.
2
+ # Illustration by George Brower.
3
+ #
4
+ # Shapes are loaded with style information that tells them how
5
+ # to draw (the color, stroke weight, etc.) The disableStyle()
6
+ # method of PShape turns off this information. The enableStyle()
7
+ # method turns it back on.
8
+
9
+ class DisableStyle < Processing::App
10
+
11
+ def setup
12
+
13
+ size 640, 360
14
+ smooth
15
+
16
+ @bot = load_shape "bot1.svg"
17
+
18
+ no_loop
19
+ end
20
+
21
+ def draw
22
+
23
+ background 102
24
+
25
+ @bot.disable_style
26
+ fill 0, 102, 153
27
+ stroke 255
28
+ shape @bot, 20, 25
29
+
30
+ @bot.enable_style
31
+ shape @bot, 320, 25
32
+ end
33
+
34
+ end
35
+
36
+ DisableStyle.new :title => "Disable Style"
@@ -0,0 +1,43 @@
1
+ # Get Child.
2
+ #
3
+ # SVG files can be made of many individual shapes.
4
+ # Each of these shapes (called a "child") has its own name
5
+ # that can be used to extract it from the "parent" file.
6
+ # This example loads a map of the United States and creates
7
+ # two new PShape objects by extracting the data from two states.
8
+
9
+ class GetChild < Processing::App
10
+
11
+ def setup
12
+
13
+ size 640, 360
14
+
15
+ @usa = load_shape "usa-wikipedia.svg"
16
+ @michigan = @usa.get_child "MI"
17
+ @ohio = @usa.get_child "OH"
18
+
19
+ smooth
20
+ no_loop
21
+ end
22
+
23
+ def draw
24
+
25
+ background 255
26
+
27
+ shape @usa, -600, -180
28
+
29
+ @michigan.disable_style
30
+
31
+ fill 0, 51, 102
32
+ no_stroke
33
+ shape @michigan, -600, -180
34
+
35
+ @ohio.disable_style
36
+
37
+ fill 153, 0, 0
38
+ shape @ohio, -600, -180
39
+ end
40
+
41
+ end
42
+
43
+ GetChild.new :title => "Get Child"
@@ -0,0 +1,33 @@
1
+ # Load and Display a Shape.
2
+ # Illustration by George Brower.
3
+ #
4
+ # The loadShape() command is used to read simple SVG (Scalable Vector Graphics)
5
+ # files into a Processing sketch. This library was specifically tested under
6
+ # SVG files created from Adobe Illustrator. For now, we can't guarantee that
7
+ # it'll work for SVGs created with anything else.
8
+
9
+ class LoadDisplayShape < Processing::App
10
+
11
+ def setup
12
+
13
+ size 640, 360
14
+
15
+ smooth
16
+
17
+ @bot = load_shape "bot1.svg"
18
+
19
+ no_loop
20
+ end
21
+
22
+ def draw
23
+
24
+ background 102
25
+
26
+ shape @bot, 110, 90, 100, 100
27
+
28
+ shape @bot, 280, 40
29
+ end
30
+
31
+ end
32
+
33
+ LoadDisplayShape.new :title => "Load Display Shape"
@@ -0,0 +1,33 @@
1
+ # Scale Shape.
2
+ # Illustration by George Brower.
3
+ #
4
+ # Move the mouse left and right to zoom the SVG file.
5
+ # This shows how, unlike an imported image, the lines
6
+ # remain smooth at any size.
7
+
8
+ class ScaleShape < Processing::App
9
+
10
+ def setup
11
+
12
+ size 640, 360
13
+
14
+ smooth
15
+
16
+ @bot = load_shape "bot1.svg"
17
+ end
18
+
19
+ def draw
20
+
21
+ background 102
22
+
23
+ translate width/2, height/2
24
+
25
+ zoom = map( mouse_x, 0, width, 0.1, 4.5 )
26
+ scale zoom
27
+
28
+ shape @bot, -140, -140
29
+ end
30
+
31
+ end
32
+
33
+ ScaleShape.new :title => "Scale Shape"
@@ -0,0 +1,55 @@
1
+ # Coordinates.
2
+ #
3
+ # All shapes drawn to the screen have a position that is specified as a coordinate.
4
+ # All coordinates are measured as the distance from the origin in units of pixels.
5
+ # The origin [0, 0] is the coordinate is in the upper left of the window
6
+ # and the coordinate in the lower right is [width-1, height-1].
7
+
8
+ class Coordinates < Processing::App
9
+
10
+ def setup
11
+
12
+ # Sets the screen to be 200, 200, so the width of the window is 200 pixels
13
+ # and the height of the window is 200 pixels
14
+
15
+ size 200, 200
16
+ background 0
17
+ no_fill
18
+ stroke 255
19
+
20
+ # The two parameters of the point() method each specify coordinates.
21
+ # This call to point() draws at the position [100, 100]
22
+
23
+ point width/2, height/2
24
+
25
+ # Draws to the position [100, 50]
26
+
27
+ point width/2, height/4
28
+
29
+ # It is also possible to specify a point with any parameter,
30
+ # but only coordinates on the screen are visible
31
+
32
+ point 60, 30
33
+ point 60, 134
34
+ point 160, 50
35
+ point 280, -800
36
+ point 201, 100
37
+
38
+ # Coordinates are used for drawing all shapes, not just points.
39
+ # Parameters for different methods are used for different purposes.
40
+ # For example, the first two parameters to line() specify the coordinates of the
41
+ # first point and the second two parameters specify the second point
42
+
43
+ stroke 204
44
+ line 0, 73, width, 73
45
+
46
+ # The first two parameters to rect() are coordinates
47
+ # and the second two are the width and height
48
+
49
+ rect 110, 55, 40, 36
50
+
51
+ end
52
+
53
+ end
54
+
55
+ Coordinates.new :title => "Coordinates"
@@ -0,0 +1,39 @@
1
+ # Create Graphics.
2
+ #
3
+ # The createGraphics() function creates an object from the PGraphics class
4
+ # (PGraphics is the main graphics and rendering context for Processing).
5
+ # The beginDraw() method is necessary to prepare for drawing and endDraw() is
6
+ # necessary to finish. Use this class if you need to draw into an off-screen
7
+ # graphics buffer or to maintain two contexts with different properties.
8
+
9
+ class CreateGraphics < Processing::App
10
+
11
+ def setup
12
+
13
+ size 200, 200
14
+
15
+ @pg = create_graphics 80, 80, P3D
16
+ end
17
+
18
+ def draw
19
+
20
+ fill 0, 12
21
+ rect 0, 0, width, height
22
+
23
+ fill 255
24
+ no_stroke
25
+ ellipse mouse_x, mouse_y, 60, 60
26
+
27
+ @pg.begin_draw
28
+ @pg.background 102
29
+ @pg.no_fill
30
+ @pg.stroke 255
31
+ @pg.ellipse mouse_x-60, mouse_y-60, 60, 60
32
+ @pg.end_draw
33
+
34
+ image @pg, 60, 60
35
+ end
36
+
37
+ end
38
+
39
+ CreateGraphics.new :title => "Create Graphics"
@@ -0,0 +1,41 @@
1
+ # Functions.
2
+ #
3
+ # The drawTarget() function makes it easy to draw many distinct targets.
4
+ # Each call to drawTarget() specifies the position, size, and number of
5
+ # rings for each target.
6
+
7
+ class Functions < Processing::App
8
+
9
+ def setup
10
+
11
+ size 200, 200
12
+
13
+ no_stroke
14
+ smooth
15
+ no_loop
16
+ end
17
+
18
+ def draw
19
+
20
+ background 51
21
+
22
+ draw_target 68, 34, 200, 10
23
+ draw_target 152, 16, 100, 3
24
+ draw_target 100, 144, 80, 5
25
+ end
26
+
27
+ def draw_target ( x, y, size, num )
28
+
29
+ greys = 255 / num
30
+ steps = size / num
31
+
32
+ (0...num).each do |i|
33
+
34
+ fill greys * i
35
+ ellipse x, y, size - i*steps, size - i*steps
36
+ end
37
+ end
38
+
39
+ end
40
+
41
+ Functions.new :title => "Functions"
@@ -0,0 +1,39 @@
1
+ # Loop.
2
+ #
3
+ # The loop() function causes draw() to execute
4
+ # continuously. If noLoop is called in setup()
5
+ # the draw() is only executed once. In this example
6
+ # click the mouse to execute loop(), which will
7
+ # cause the draw() the execute continuously.
8
+
9
+ class Loop < Processing::App
10
+
11
+ def setup
12
+
13
+ size 200, 200
14
+ stroke 255
15
+
16
+ no_loop # stops program
17
+
18
+ @y = 100
19
+ end
20
+
21
+ def draw
22
+
23
+ background 0
24
+
25
+ line 0, @y, width, @y
26
+
27
+ @y = @y - 1
28
+
29
+ @y = height if @y < 0
30
+ end
31
+
32
+ def mouse_pressed
33
+
34
+ loop # starts program
35
+ end
36
+
37
+ end
38
+
39
+ Loop.new :title => "Loop"
@@ -0,0 +1,33 @@
1
+ # No Loop.
2
+ #
3
+ # The noLoop() function causes draw() to only
4
+ # execute once. Without calling noLoop(), draw()
5
+ # executed continually.
6
+
7
+ class Noloop < Processing::App
8
+
9
+ def setup
10
+
11
+ size 200, 200
12
+
13
+ @y = 100
14
+
15
+ stroke 255
16
+ frame_rate 30
17
+
18
+ no_loop
19
+ end
20
+
21
+ def draw
22
+
23
+ background 0
24
+
25
+ @y = @y - 1
26
+ @y = height if @y < 0
27
+
28
+ line 0, @y, width, @y
29
+ end
30
+
31
+ end
32
+
33
+ Noloop.new :title => "Noloop"
@@ -0,0 +1,42 @@
1
+ # Recursion.
2
+ #
3
+ # A demonstration of recursion, which means functions call themselves.
4
+ # Notice how the drawCircle() function calls itself at the end of its block.
5
+ # It continues to do this until the variable "level" is equal to 1.
6
+
7
+ class Recursion1 < Processing::App
8
+
9
+ def setup
10
+
11
+ size 200, 200
12
+
13
+ no_stroke
14
+ smooth
15
+ no_loop
16
+ end
17
+
18
+ def draw
19
+
20
+ draw_circle 126, 170, 6
21
+ end
22
+
23
+ def draw_circle ( x, radius, level )
24
+
25
+ tt = 126 * level / 4.0
26
+
27
+ fill tt
28
+
29
+ ellipse x, 100, radius*2, radius*2
30
+
31
+ if level > 1
32
+
33
+ level = level - 1
34
+
35
+ draw_circle x - radius/2, radius/2, level
36
+ draw_circle x + radius/2, radius/2, level
37
+ end
38
+ end
39
+
40
+ end
41
+
42
+ Recursion1.new :title => "Recursion1"
@@ -0,0 +1,39 @@
1
+ # Recursion2
2
+
3
+ class Recursion2 < Processing::App
4
+
5
+ def setup
6
+
7
+ size 200, 200
8
+
9
+ no_stroke
10
+ smooth
11
+
12
+ draw_circle 100, 100, 80, 8
13
+ end
14
+
15
+ def draw_circle ( x, y, radius, level )
16
+
17
+ tt = 126 * level / 6.0
18
+ fill tt, 153
19
+
20
+ ellipse x, y, radius*2, radius*2
21
+
22
+ if level > 1
23
+
24
+ level = level - 1
25
+ num = random( 2, 6 ).to_i
26
+
27
+ 0.upto( num-1 ) do |i|
28
+
29
+ a = random 0, TWO_PI
30
+ nx = x + cos( a ) * 6.0 * level
31
+ ny = y + sin( a ) * 6.0 * level
32
+ draw_circle nx, ny, radius/2, level
33
+ end
34
+ end
35
+ end
36
+
37
+ end
38
+
39
+ Recursion2.new :title => "Recursion2"