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,88 @@
1
+ # RGB Cube.
2
+ #
3
+ # The three primary colors of the additive color model are red, green, and blue.
4
+ # This RGB color cube displays smooth transitions between these colors.
5
+
6
+ class RgbCube < Processing::App
7
+
8
+ def setup
9
+ size 640, 360, P3D
10
+
11
+ no_stroke
12
+ color_mode RGB, 2
13
+
14
+ @xmag = 0
15
+ @ymag = 0
16
+ @new_xmag = 0
17
+ @new_ymag = 0
18
+
19
+ # since each point is used three times
20
+ @box_points = {
21
+ :top_front_left => [-1, 1, 1],
22
+ :top_front_right => [ 1, 1, 1],
23
+ :top_back_right => [ 1, 1, -1],
24
+ :top_back_left => [-1, 1, -1],
25
+ :bottom_front_left => [-1, -1, 1],
26
+ :bottom_front_right => [ 1, -1, 1],
27
+ :bottom_back_right => [ 1, -1, -1],
28
+ :bottom_back_left => [-1, -1, -1]
29
+ }
30
+ # a box from defined points
31
+ @box = {
32
+ :top => [@box_points[:top_front_left], @box_points[:top_front_right], @box_points[:top_back_right], @box_points[:top_back_left]],
33
+ :front => [@box_points[:top_front_left], @box_points[:top_front_right], @box_points[:bottom_front_right], @box_points[:bottom_front_left]],
34
+ :left => [@box_points[:top_front_left], @box_points[:bottom_front_left], @box_points[:bottom_back_left], @box_points[:top_back_left]],
35
+ :back => [@box_points[:top_back_left], @box_points[:top_back_right], @box_points[:bottom_back_right], @box_points[:bottom_back_left]],
36
+ :right => [@box_points[:top_back_right], @box_points[:bottom_back_right], @box_points[:bottom_front_right], @box_points[:top_front_right]],
37
+ :bottom => [@box_points[:bottom_front_left], @box_points[:bottom_front_right], @box_points[:bottom_back_right], @box_points[:bottom_back_left]]
38
+ }
39
+ end
40
+
41
+ def draw
42
+
43
+ background 1
44
+
45
+ push_matrix
46
+
47
+ translate width/2, height/2, -30
48
+
49
+ @new_xmag = mouseX / width.to_f * TWO_PI
50
+ @new_ymag = mouseY / height.to_f * TWO_PI
51
+
52
+ diff = @xmag - @new_xmag
53
+ @xmag -= diff / 4 if diff.abs > 0.01
54
+
55
+ diff = @ymag - @new_ymag
56
+ @ymag -= diff / 4 if diff.abs > 0.01
57
+
58
+ rotate_x -@ymag
59
+ rotate_y -@xmag
60
+
61
+ scale 90
62
+
63
+ begin_shape QUADS
64
+
65
+ [:top, :front, :left, :back, :right, :bottom].each { |s|
66
+ @box[s].each { |p|
67
+ fill_from_points p
68
+ vertex_from_points p
69
+ }
70
+ }
71
+
72
+ end_shape
73
+
74
+ pop_matrix
75
+
76
+ end
77
+
78
+ def fill_from_points ( points )
79
+ fill points[0] + 1, points[1] + 1, points[2] + 1 # "+1" translates -1,1 to 0,2
80
+ end
81
+
82
+ def vertex_from_points ( points )
83
+ vertex points[0], points[1], points[2]
84
+ end
85
+
86
+ end
87
+
88
+ RgbCube.new :title => "Rgb Cube"
@@ -0,0 +1,94 @@
1
+ # Shape Transform
2
+ # by Ira Greenberg.
3
+ #
4
+ # Illustrates the geometric relationship
5
+ # between Cube, Pyramid, Cone and
6
+ # Cylinder 3D primitives.
7
+ #
8
+ # Instructions:
9
+ # Up Arrow - increases points
10
+ # Down Arrow - decreases points
11
+ # 'p' key toggles between cube/pyramid
12
+
13
+ class ShapeTransform < Processing::App
14
+
15
+ def setup
16
+
17
+ size 640, 360, P3D
18
+
19
+ no_stroke
20
+
21
+ @angle_inc = PI/300
22
+
23
+ @pts = 4
24
+ @angle = 0
25
+ @radius = 99
26
+ @cylinder_length = 95
27
+
28
+ @is_pyramid = false
29
+
30
+ end
31
+
32
+ def draw
33
+
34
+ background 170, 95, 95
35
+ lights
36
+ fill 255, 200, 200
37
+
38
+ translate width/2, height/2
39
+ rotate_x frame_count * @angle_inc
40
+ rotate_y frame_count * @angle_inc
41
+ rotate_z frame_count * @angle_inc
42
+
43
+ vertices = []
44
+
45
+ (0...2).each { |i|
46
+ @angle = 0
47
+ vertices[i] = []
48
+ 0.upto(@pts) { |j|
49
+ pvec = PVector.new 0, 0
50
+ (
51
+ pvec.x = cos(radians( @angle )) * @radius
52
+ pvec.y = sin(radians( @angle )) * @radius
53
+
54
+ ) unless ( @is_pyramid && i == 1 )
55
+
56
+ pvec.z = @cylinder_length
57
+ vertices[i][j] = pvec
58
+
59
+ @angle += 360.0/@pts
60
+ }
61
+ @cylinder_length *= -1
62
+ }
63
+
64
+ begin_shape QUAD_STRIP
65
+ 0.upto(@pts) { |j|
66
+ vertex vertices[0][j].x, vertices[0][j].y, vertices[0][j].z
67
+ vertex vertices[1][j].x, vertices[1][j].y, vertices[1][j].z
68
+ }
69
+ end_shape
70
+
71
+ [0,1].each { |i|
72
+ begin_shape
73
+ 0.upto(@pts) { |j|
74
+ vertex vertices[i][j].x, vertices[i][j].y, vertices[i][j].z
75
+ }
76
+ end_shape CLOSE
77
+ }
78
+
79
+ end
80
+
81
+ def key_pressed
82
+
83
+ if key == CODED
84
+ @pts += 1 if keyCode == UP && @pts < 90
85
+ @pts -= 1 if keyCode == DOWN && @pts > 4
86
+ end
87
+
88
+ @is_pyramid = !@is_pyramid if key.eql? "p"
89
+
90
+ end
91
+
92
+ end
93
+
94
+ ShapeTransform.new :title => "Shape Transform"
@@ -0,0 +1,130 @@
1
+ # Interactive Toroid
2
+ # by Ira Greenberg.
3
+ #
4
+ # Illustrates the geometric relationship between Toroid, Sphere, and Helix
5
+ # 3D primitives, as well as lathing principal.
6
+ #
7
+ # Instructions:
8
+ # UP arrow key ____ pts++
9
+ # DOWN arrow key __ pts--
10
+ # LEFT arrow key __ segments--
11
+ # RIGHT arrow key _ segments++
12
+ # 'a' key _________ toroid radius--
13
+ # 's' key _________ toroid radius++
14
+ # 'z' key _________ initial polygon radius--
15
+ # 'x' key _________ initial polygon radius++
16
+ # 'w' key _________ toggle wireframe/solid shading
17
+ # 'h' key _________ toggle sphere/helix
18
+
19
+
20
+ class Toroid < Processing::App
21
+
22
+ def setup
23
+
24
+ size 640, 360, P3D
25
+
26
+ @pts = 40
27
+ @angle = 0.0
28
+ @radius = 60.0
29
+ @segments = 60.0
30
+ @lathe_angle = 0.0
31
+ @lathe_radius = 100.0
32
+ @is_wireframe = false
33
+ @is_helix = false
34
+ @helix_offset = 5.0
35
+
36
+ end
37
+
38
+ def draw
39
+
40
+ background 50, 64, 42
41
+
42
+ lights
43
+
44
+ if @is_wireframe
45
+ stroke 255, 255, 150
46
+ no_fill
47
+ else
48
+ no_stroke
49
+ fill 150, 195, 125
50
+ end
51
+
52
+ translate width/2, height/2, -100
53
+
54
+ rotate_x frame_count * PI / 150
55
+ rotate_y frame_count * PI / 170
56
+ rotate_z frame_count * PI / 90
57
+
58
+ vertices = []
59
+ vertices2 = []
60
+
61
+ 0.upto(@pts) { |i|
62
+
63
+ vertices2[i] = PVector.new
64
+ vertices[i] = PVector.new
65
+
66
+ vertices[i].x = @lathe_radius + sin( radians( @angle ) ) * @radius
67
+
68
+ if @is_helix
69
+ vertices[i].z = cos( radians( @angle ) ) * @radius - (@helix_offset * @segments) / 2
70
+ else
71
+ vertices[i].z = cos( radians( @angle ) ) * @radius
72
+ end
73
+
74
+ @angle += 360.0 / @pts
75
+ }
76
+
77
+ @lathe_angle = 0
78
+
79
+ 0.upto(@segments) { |i|
80
+ begin_shape QUAD_STRIP
81
+ (0..@pts).each { |j|
82
+ vertex_for_pvector vertices2[j] if i > 0
83
+
84
+ vertices2[j].x = cos( radians( @lathe_angle ) ) * vertices[j].x
85
+ vertices2[j].y = sin( radians( @lathe_angle )
86
+ ) * vertices[j].x
87
+ vertices2[j].z = vertices[j].z
88
+
89
+ vertices[j].z += @helix_offset if @is_helix
90
+
91
+ vertex_for_pvector vertices2[j]
92
+ }
93
+
94
+ @lathe_angle += (@is_helix ? 720 : 360) / @segments
95
+ end_shape
96
+ }
97
+
98
+ end
99
+
100
+ def vertex_for_pvector ( pvec )
101
+ vertex( pvec.x, pvec.y, pvec.z )
102
+ end
103
+
104
+ def key_pressed
105
+
106
+ if key == CODED
107
+
108
+ @pts += 1 if keyCode == UP && @pts < 40
109
+ @pts -= 1 if keyCode == DOWN && @pts > 3
110
+
111
+ @segments += 1 if keyCode == RIGHT && @segments < 80
112
+ @segments -= 1 if keyCode == LEFT && @segments > 3
113
+
114
+ end
115
+
116
+ @lathe_radius += 1 if key.eql? "s"
117
+ @lathe_radius -= 1 if key.eql? "a" #&& @lathe_radius > 0
118
+
119
+ @radius += 1 if key.eql? "x"
120
+ @radius -= 1 if key.eql? "z" && @radius > 10
121
+
122
+ @is_wireframe = !@is_wireframe if key.eql? "w"
123
+
124
+ @is_helix = !@is_helix if key.eql? "h"
125
+
126
+ end
127
+
128
+ end
129
+
130
+ Toroid.new :title => "Toroid"
@@ -0,0 +1,81 @@
1
+ # Vertices
2
+ # by Simon Greenwold.
3
+ #
4
+ # Draw a cylinder centered on the y-axis, going down
5
+ # from y=0 to y=height. The radius at the top can be
6
+ # different from the radius at the bottom, and the
7
+ # number of sides drawn is variable.
8
+
9
+ class Vertices < Processing::App
10
+
11
+ def setup
12
+
13
+ size 640, 360, P3D
14
+
15
+ end
16
+
17
+ def draw
18
+
19
+ background 0
20
+ lights
21
+
22
+ translate width/2, height/2
23
+
24
+ rotate_y map( mouse_x, 0, width, 0, PI )
25
+ rotate_z map( mouse_y, 0, height, 0, -PI )
26
+
27
+ no_stroke
28
+ fill 255, 255, 255
29
+
30
+ translate 0, -40
31
+
32
+ draw_cylinder 10, 180, 200, 16 # Draw a mix between a cylinder and a cone
33
+ #draw_cylinder 70, 70, 120, 64 # Draw a cylinder
34
+ #draw_cylinder 0, 180, 200, 4 # Draw a pyramid
35
+
36
+ end
37
+
38
+ def draw_cylinder ( top_radius, bottom_radius, tall, sides )
39
+
40
+ angle = 0
41
+ angle_inc = TWO_PI / sides
42
+
43
+ begin_shape QUAD_STRIP
44
+ 0.upto(sides+1) { |i|
45
+ vertex top_radius * cos(angle), 0, top_radius * sin(angle)
46
+ vertex bottom_radius * cos(angle), tall, bottom_radius * sin(angle)
47
+ angle += angle_inc
48
+ }
49
+ end_shape
50
+
51
+ unless top_radius == 0
52
+ angle = 0
53
+
54
+ begin_shape TRIANGLE_FAN
55
+ vertex 0, 0, 0
56
+ 0.upto(sides+1){ |i|
57
+ vertex top_radius * cos(angle), 0, top_radius * sin(angle)
58
+ angle += angle_inc
59
+ }
60
+ end_shape
61
+
62
+ end
63
+
64
+ unless bottom_radius == 0
65
+ angle = 0
66
+
67
+ begin_shape TRIANGLE_FAN
68
+ vertex 0, 0, 0
69
+ 0.upto(sides+1) { |i|
70
+ vertex bottom_radius * cos(angle), tall, bottom_radius * sin(angle)
71
+ angle += angle_inc
72
+ }
73
+ end_shape
74
+
75
+ end
76
+
77
+ end
78
+
79
+ end
80
+
81
+ Vertices.new :title => "Vertices"
@@ -0,0 +1,56 @@
1
+ # Explode
2
+ # by Daniel Shiffman.
3
+ #
4
+ # Mouse horizontal location controls breaking apart of image and
5
+ # Maps pixels from a 2D image into 3D space. Pixel brightness controls
6
+ # translation along z axis.
7
+
8
+ class Explode < Processing::App
9
+
10
+ def setup
11
+
12
+ size 640, 360, P3D
13
+
14
+ @cell_size = 2
15
+ @img = load_image "eames.jpg"
16
+ @columns = @img.width / @cell_size
17
+ @rows = @img.height / @cell_size
18
+
19
+ end
20
+
21
+ def draw
22
+
23
+ background 0
24
+
25
+ (0...@columns).each { |i|
26
+
27
+ (0...@rows).each { |j|
28
+
29
+ x = i * @cell_size + @cell_size / 2
30
+ y = j * @cell_size + @cell_size / 2
31
+
32
+ loc = x + y * @img.width
33
+
34
+ c = @img.pixels[loc]
35
+
36
+ z = (mouse_x / width.to_f) * brightness( @img.pixels[loc] ) - 20
37
+
38
+ push_matrix
39
+
40
+ translate x + 200, y + 100, z
41
+
42
+ fill c, 204
43
+ no_stroke
44
+ rect_mode CENTER
45
+
46
+ rect 0, 0, @cell_size, @cell_size
47
+
48
+ pop_matrix
49
+ }
50
+ }
51
+
52
+ end
53
+
54
+ end
55
+
56
+ Explode.new :title => "Explode"