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.
Files changed (227) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rpextras.jar +0 -0
  3. data/lib/ruby-processing.rb +8 -6
  4. data/lib/ruby-processing/app.rb +54 -67
  5. data/lib/ruby-processing/config.rb +7 -7
  6. data/lib/ruby-processing/exporters/application_exporter.rb +37 -38
  7. data/lib/ruby-processing/exporters/base_exporter.rb +34 -37
  8. data/lib/ruby-processing/exporters/creator.rb +27 -25
  9. data/lib/ruby-processing/helper_methods.rb +18 -22
  10. data/lib/ruby-processing/helpers/numeric.rb +5 -6
  11. data/lib/ruby-processing/helpers/string.rb +11 -20
  12. data/lib/ruby-processing/library_loader.rb +33 -35
  13. data/lib/ruby-processing/runner.rb +118 -65
  14. data/lib/ruby-processing/runners/base.rb +21 -26
  15. data/lib/ruby-processing/runners/live.rb +3 -4
  16. data/lib/ruby-processing/runners/run.rb +1 -3
  17. data/lib/ruby-processing/runners/watch.rb +8 -8
  18. data/lib/ruby-processing/version.rb +1 -1
  19. data/lib/templates/application/lib/args.txt.erb +1 -1
  20. data/lib/templates/application/run.erb +3 -3
  21. data/library/control_panel/control_panel.rb +29 -29
  22. data/library/fastmath/fastmath.rb +3 -0
  23. data/library/file_chooser/file_chooser.rb +11 -13
  24. data/library/vecmath/vecmath.rb +6 -35
  25. data/samples/Rakefile +3 -1
  26. data/samples/configRP5/configRP5.pde +150 -0
  27. data/samples/contributed/Rakefile +6 -6
  28. data/samples/contributed/animator.rb +6 -6
  29. data/samples/contributed/bezier_playground.rb +29 -68
  30. data/samples/contributed/circle_collision.rb +6 -13
  31. data/samples/contributed/elegant_ball.rb +14 -17
  32. data/samples/contributed/empathy.rb +8 -5
  33. data/samples/contributed/fibonacci_sphere.rb +10 -49
  34. data/samples/contributed/full_screen.rb +1 -1
  35. data/samples/contributed/grapher.rb +10 -9
  36. data/samples/contributed/gravity.rb +11 -16
  37. data/samples/contributed/jwishy.rb +18 -20
  38. data/samples/contributed/quadraticvertex.rb +26 -26
  39. data/samples/external_library/java_processing/custom/landscape.rb +6 -4
  40. data/samples/external_library/java_processing/hemesh/twin_iso.rb +69 -71
  41. data/samples/external_library/java_processing/pbox2d/bumpy_surface_noise.rb +57 -0
  42. data/samples/external_library/java_processing/pbox2d/contact_test.rb +23 -0
  43. data/samples/external_library/java_processing/pbox2d/data/java_args.txt +2 -0
  44. data/samples/external_library/java_processing/pbox2d/library/custom_shape/custom_shape.rb +158 -0
  45. data/samples/external_library/java_processing/pbox2d/library/particle_system/particle_system.rb +212 -0
  46. data/samples/external_library/java_processing/pbox2d/library/surface/surface.rb +154 -0
  47. data/samples/external_library/java_processing/pbox2d/liquidy.rb +58 -0
  48. data/samples/external_library/java_processing/pbox2d/polygons.rb +58 -0
  49. data/samples/external_library/java_processing/toxiclibs/library/vbo/vbo.rb +52 -0
  50. data/samples/external_library/java_processing/toxiclibs/model_align.rb +9 -16
  51. data/samples/processing_app/basics/color/color_wheel.rb +1 -1
  52. data/samples/processing_app/basics/form/regular_polygon.rb +2 -2
  53. data/samples/processing_app/basics/form/rgb_cube.rb +2 -2
  54. data/samples/processing_app/basics/form/shape_primitives.rb +1 -1
  55. data/samples/processing_app/basics/form/star.rb +2 -2
  56. data/samples/processing_app/basics/input/clock.rb +21 -16
  57. data/samples/processing_app/basics/input/storing_input.rb +6 -6
  58. data/samples/processing_app/basics/math/additive_wave.rb +1 -1
  59. data/samples/processing_app/basics/math/sine.rb +2 -2
  60. data/samples/processing_app/basics/math/sine_cosine.rb +1 -1
  61. data/samples/processing_app/basics/math/sine_wave.rb +1 -1
  62. data/samples/processing_app/basics/objects/inheritance.rb +2 -0
  63. data/samples/processing_app/basics/objects/inheritance_two.rb +88 -0
  64. data/samples/processing_app/basics/objects/module.rb +89 -0
  65. data/samples/processing_app/{library/vecmath/drawolver.rb → basics/objects/module_two.rb} +1 -1
  66. data/samples/processing_app/basics/objects/multiple_constructors.rb +5 -0
  67. data/samples/processing_app/basics/objects/struct.rb +38 -0
  68. data/samples/processing_app/basics/structure/recursion2.rb +1 -1
  69. data/samples/processing_app/basics/transform/birds.rb +7 -10
  70. data/samples/processing_app/basics/transform/library/bird/bird.rb +3 -3
  71. data/samples/processing_app/basics/transform/rotate.rb +1 -1
  72. data/samples/processing_app/basics/transform/rotate1.rb +1 -1
  73. data/samples/processing_app/basics/transform/rotate_x_y.rb +1 -1
  74. data/samples/processing_app/demos/graphics/bezier_patch.rb +1 -38
  75. data/samples/processing_app/demos/graphics/trefoil.rb +50 -40
  76. data/samples/processing_app/demos/graphics/wiggling.rb +36 -38
  77. data/samples/processing_app/demos/performance/cubic_grid_retained.rb +14 -14
  78. data/samples/processing_app/demos/performance/esfera.rb +27 -39
  79. data/samples/processing_app/demos/performance/text_rendering.rb +1 -1
  80. data/samples/processing_app/library/fastmath/clock.rb +44 -0
  81. data/samples/processing_app/library/pdf/complex_3D.rb +26 -24
  82. data/samples/processing_app/library/vecmath/{Rakefile → arcball/Rakefile} +6 -6
  83. data/samples/processing_app/library/vecmath/arcball/arcball_box.rb +23 -0
  84. data/samples/processing_app/library/vecmath/arcball/arcball_radius.rb +23 -0
  85. data/samples/processing_app/library/vecmath/arcball/arcball_shape.rb +29 -0
  86. data/samples/processing_app/library/vecmath/{README.txt → vec2d/README.txt} +0 -0
  87. data/samples/processing_app/library/vecmath/vec2d/Rakefile +30 -0
  88. data/samples/processing_app/library/vecmath/{acceleration_with_vectors.rb → vec2d/acceleration_with_vectors.rb} +4 -5
  89. data/samples/processing_app/library/vecmath/{bouncing_ball.rb → vec2d/bouncing_ball.rb} +9 -15
  90. data/samples/processing_app/library/vecmath/{circle_collision.rb → vec2d/circle_collision.rb} +46 -51
  91. data/samples/processing_app/library/vecmath/{data → vec2d/data}/java_args.txt +0 -0
  92. data/samples/processing_app/library/vecmath/{data → vec2d/data}/sprite.png +0 -0
  93. data/samples/processing_app/library/vecmath/{data → vec2d/data}/texture.png +0 -0
  94. data/samples/processing_app/library/vecmath/{flocking.rb → vec2d/flocking.rb} +3 -6
  95. data/samples/processing_app/library/vecmath/{library → vec2d/library}/flock/flock.rb +47 -67
  96. data/samples/processing_app/library/vecmath/{library → vec2d/library}/particle/particle_system.rb +5 -5
  97. data/samples/processing_app/library/vecmath/vec2d/library/tile/tile.rb +85 -0
  98. data/samples/processing_app/library/vecmath/{morph.rb → vec2d/morph.rb} +17 -16
  99. data/samples/processing_app/library/vecmath/{multiple_particle_systems.rb → vec2d/multiple_particle_systems.rb} +11 -28
  100. data/samples/processing_app/library/vecmath/{particle_system_pshape.rb → vec2d/particle_system_pshape.rb} +4 -6
  101. data/samples/processing_app/library/vecmath/vec2d/penrose.rb +71 -0
  102. data/samples/processing_app/library/vecmath/{reflection1.rb → vec2d/reflection1.rb} +6 -6
  103. data/samples/processing_app/library/vecmath/{seeking_neural.rb → vec2d/seeking_neural.rb} +12 -16
  104. data/samples/processing_app/library/vecmath/{simple_particle_system.rb → vec2d/simple_particle_system.rb} +8 -12
  105. data/samples/processing_app/library/vecmath/{smoke_particle_system.rb → vec2d/smoke_particle_system.rb} +8 -13
  106. data/samples/processing_app/library/vecmath/{vector_math.rb → vec2d/vector_math.rb} +0 -0
  107. data/samples/processing_app/library/vecmath/{library/wiggler/wiggler.rb → vec2d/wiggle_pshape.rb} +28 -4
  108. data/samples/processing_app/library/vecmath/vec3d/Rakefile +30 -0
  109. data/samples/processing_app/library/vecmath/vec3d/drawolver.rb +86 -0
  110. data/samples/processing_app/library/vecmath/vec3d/frame_of_reference.rb +103 -0
  111. data/samples/processing_app/library/vecmath/{hilbert_fractal.rb → vec3d/hilbert_fractal.rb} +5 -33
  112. data/samples/processing_app/library/vecmath/vec3d/library/geometry/geometry.rb +3 -0
  113. data/samples/processing_app/library/vecmath/vec3d/library/geometry/lib/cylinder.rb +44 -0
  114. data/samples/processing_app/library/vecmath/vec3d/library/geometry/lib/mat4.rb +28 -0
  115. data/samples/processing_app/library/vecmath/vec3d/library/geometry/lib/plane.rb +60 -0
  116. data/samples/processing_app/library/vecmath/{library → vec3d/library}/hilbert/hilbert.rb +14 -17
  117. data/samples/processing_app/library/vecmath/{retained_menger.rb → vec3d/retained_menger.rb} +20 -55
  118. data/samples/processing_app/topics/advanced_data/Rakefile +6 -6
  119. data/samples/processing_app/topics/advanced_data/counting_words.rb +7 -7
  120. data/samples/processing_app/topics/advanced_data/data/data.xml +0 -15
  121. data/samples/processing_app/topics/advanced_data/data/struct_data.yml +5 -0
  122. data/samples/processing_app/topics/advanced_data/library/bubble/bubble.rb +8 -8
  123. data/samples/processing_app/topics/advanced_data/load_save_XML.rb +41 -42
  124. data/samples/processing_app/topics/advanced_data/load_save_json.rb +11 -11
  125. data/samples/processing_app/topics/advanced_data/load_save_struct_yaml.rb +22 -23
  126. data/samples/processing_app/topics/advanced_data/load_save_table.rb +12 -12
  127. data/samples/processing_app/topics/advanced_data/load_save_yaml.rb +10 -12
  128. data/samples/processing_app/topics/advanced_data/regex.rb +5 -6
  129. data/samples/processing_app/topics/advanced_data/threads.rb +27 -27
  130. data/samples/processing_app/topics/advanced_data/threads_two.rb +3 -2
  131. data/samples/processing_app/topics/advanced_data/word_frequency.rb +18 -16
  132. data/samples/processing_app/topics/advanced_data/yahoo_weather.rb +6 -5
  133. data/samples/processing_app/topics/animation/animated_sprite.rb +9 -7
  134. data/samples/processing_app/topics/animation/sequential.rb +19 -19
  135. data/samples/processing_app/topics/cellular_automata/library/ca/ca.rb +1 -1
  136. data/samples/processing_app/topics/cellular_automata/wolfram.rb +1 -1
  137. data/samples/processing_app/topics/create_shapes/begin_end_contour.rb +1 -1
  138. data/samples/processing_app/topics/create_shapes/library/wiggler/wiggler.rb +4 -4
  139. data/samples/processing_app/topics/create_shapes/particle_system_pshape.rb +2 -2
  140. data/samples/processing_app/topics/create_shapes/path_pshape.rb +1 -1
  141. data/samples/processing_app/topics/create_shapes/polygon_pshape_oo3.rb +1 -1
  142. data/samples/processing_app/topics/create_shapes/polygon_shape.rb +3 -3
  143. data/samples/processing_app/topics/file_io/load_file1.rb +1 -1
  144. data/samples/processing_app/topics/file_io/save_frames.rb +5 -5
  145. data/samples/processing_app/topics/file_io/save_one_image.rb +2 -2
  146. data/samples/processing_app/topics/file_io/tile_images.rb +1 -1
  147. data/samples/processing_app/topics/gui/scrollbar.rb +3 -3
  148. data/samples/processing_app/topics/image_processing/blending.rb +13 -13
  149. data/samples/processing_app/topics/image_processing/blur.rb +1 -1
  150. data/samples/processing_app/topics/image_processing/brightness.rb +1 -1
  151. data/samples/processing_app/topics/image_processing/convolution.rb +1 -1
  152. data/samples/processing_app/topics/image_processing/edge_detection.rb +4 -4
  153. data/samples/processing_app/topics/image_processing/explode.rb +1 -1
  154. data/samples/processing_app/topics/image_processing/extrusion.rb +1 -1
  155. data/samples/processing_app/topics/image_processing/histogram.rb +1 -1
  156. data/samples/processing_app/topics/image_processing/linear_image.rb +1 -1
  157. data/samples/processing_app/topics/image_processing/pixel_array.rb +1 -1
  158. data/samples/processing_app/topics/image_processing/zoom.rb +2 -2
  159. data/samples/processing_app/topics/lsystems/Rakefile +6 -6
  160. data/samples/processing_app/topics/lsystems/chequer.rb +4 -10
  161. data/samples/processing_app/topics/lsystems/csplant.rb +25 -25
  162. data/samples/processing_app/topics/lsystems/cstest.rb +9 -4
  163. data/samples/processing_app/topics/lsystems/david_tour.rb +14 -16
  164. data/samples/processing_app/topics/lsystems/koch.rb +8 -18
  165. data/samples/processing_app/topics/lsystems/library/cs_grammar/cs_grammar.rb +18 -24
  166. data/samples/processing_app/topics/lsystems/library/grammar/grammar.rb +7 -9
  167. data/samples/processing_app/topics/lsystems/library/koch/koch_fractal.rb +75 -94
  168. data/samples/processing_app/topics/lsystems/library/stochastic_grammar/stochastic_grammar.rb +11 -13
  169. data/samples/processing_app/topics/lsystems/mpeano.rb +29 -32
  170. data/samples/processing_app/topics/lsystems/peano.rb +19 -21
  171. data/samples/processing_app/topics/lsystems/penrose.rb +31 -37
  172. data/samples/processing_app/topics/lsystems/penrose_snowflake.rb +10 -15
  173. data/samples/processing_app/topics/lsystems/pentagonal.rb +20 -23
  174. data/samples/processing_app/topics/lsystems/snake_kolam.rb +13 -13
  175. data/samples/processing_app/topics/lsystems/stochastic_test.rb +25 -28
  176. data/samples/processing_app/topics/lsystems/three_d_tree.rb +25 -24
  177. data/samples/processing_app/topics/motion/bouncy_bubbles.rb +17 -17
  178. data/samples/processing_app/topics/motion/cubes_in_cube.rb +1 -3
  179. data/samples/processing_app/topics/motion/library/cube/cube.rb +2 -2
  180. data/samples/processing_app/topics/motion/reflection2.rb +1 -1
  181. data/samples/processing_app/topics/shaders/blur_filter.rb +3 -3
  182. data/samples/processing_app/topics/shaders/bw_shader.rb +3 -3
  183. data/samples/processing_app/topics/shaders/conway.rb +5 -5
  184. data/samples/processing_app/topics/shaders/deform.rb +5 -5
  185. data/samples/processing_app/topics/shaders/edge_detect.rb +3 -5
  186. data/samples/processing_app/topics/shaders/glossy_fish_eye.rb +15 -21
  187. data/samples/processing_app/topics/shaders/glsl_heightmap_noise.rb +21 -19
  188. data/samples/processing_app/topics/shaders/image_mask.rb +6 -6
  189. data/samples/processing_app/topics/shaders/landscape.rb +4 -4
  190. data/samples/processing_app/topics/shaders/monjori.rb +15 -15
  191. data/samples/processing_app/topics/shaders/nebula.rb +3 -3
  192. data/samples/processing_app/topics/shaders/sep_blur.rb +15 -15
  193. data/samples/processing_app/topics/shaders/toon_shading.rb +2 -2
  194. data/samples/processing_app/topics/simulate/chain.rb +16 -14
  195. data/samples/processing_app/topics/simulate/smoke_particle_system.rb +3 -3
  196. data/samples/processing_app/topics/vectors/acceleration_with_vectors.rb +3 -2
  197. data/samples/processing_app/topics/vectors/bouncing_ball.rb +1 -0
  198. data/samples/processing_app/topics/vectors/vector_math.rb +2 -1
  199. data/vendors/Rakefile +15 -3
  200. metadata +99 -86
  201. data/.gitignore +0 -13
  202. data/.travis.yml +0 -6
  203. data/.yardopts +0 -5
  204. data/CHANGELOG +0 -316
  205. data/CONTRIBUTING.md +0 -35
  206. data/Gemfile +0 -6
  207. data/LICENSE.md +0 -39
  208. data/README.md +0 -119
  209. data/Rakefile +0 -37
  210. data/bin/install_jruby_complete +0 -13
  211. data/lib/ruby-processing/exporters/exporters.rb +0 -7
  212. data/library/vecmath/lib/arcball.rb +0 -64
  213. data/library/vecmath/lib/quaternion.rb +0 -62
  214. data/library/vecmath/lib/vec.rb +0 -232
  215. data/ruby-processing.gemspec +0 -54
  216. data/samples/processing_app/library/pdf/.gitignore +0 -1
  217. data/samples/processing_app/library/vecmath/retained_test.rb +0 -65
  218. data/samples/processing_app/library/vecmath/retained_test2.rb +0 -65
  219. data/samples/processing_app/library/vecmath/wiggle_pshape.rb +0 -22
  220. data/test/README.md +0 -6
  221. data/test/basic.rb +0 -14
  222. data/test/draw_ex.rb +0 -12
  223. data/test/graphics.rb +0 -7
  224. data/test/p2d.rb +0 -14
  225. data/test/p3d.rb +0 -14
  226. data/test/rp5_test.rb +0 -86
  227. data/test/setup_ex.rb +0 -12
@@ -0,0 +1,3 @@
1
+ require_relative 'lib/plane.rb'
2
+ require_relative 'lib/mat4.rb'
3
+ require_relative 'lib/cylinder.rb'
@@ -0,0 +1,44 @@
1
+ class Cylinder
2
+ include Processing::Proxy
3
+ attr_accessor :vecs
4
+ attr_reader :detail, :dim
5
+
6
+ def initialize(dim, detail)
7
+ @dim = dim
8
+ @detail = detail
9
+ init
10
+ end
11
+
12
+ def init
13
+ # created around x-axis
14
+ # y = Math.cos
15
+ # z = Math.sin
16
+ veca = []
17
+ vecb = []
18
+ (0 ... 360).step(360 / detail) do |theta|
19
+ cost = DegLut.cos(theta)
20
+ sint = DegLut.sin(theta)
21
+ veca << Vec3D.new(0, cost * dim.y, sint * dim.z)
22
+ vecb << Vec3D.new(dim.x, cost * dim.y, sint * dim.z)
23
+ end
24
+ @vecs = veca.concat(vecb)
25
+ end
26
+
27
+ def display(renderer)
28
+ begin_shape(QUADS)
29
+ detail.times do |i|
30
+ if i < (detail - 1)
31
+ vecs[i].to_vertex(renderer)
32
+ vecs[i + 1].to_vertex(renderer)
33
+ vecs[detail + i + 1].to_vertex(renderer)
34
+ vecs[detail + i].to_vertex(renderer)
35
+ else
36
+ vecs[i].to_vertex(renderer)
37
+ vecs[0].to_vertex(renderer)
38
+ vecs[detail].to_vertex(renderer)
39
+ vecs[detail + i].to_vertex(renderer)
40
+ end
41
+ end
42
+ end_shape
43
+ end
44
+ end
@@ -0,0 +1,28 @@
1
+ # uber simple Homogeneous 4 x 4 matrix
2
+
3
+ class Mat4
4
+ attr_reader :mat
5
+
6
+ def initialize(axisX, axisY, axisZ, trans)
7
+ @mat = [
8
+ [axisX.x, axisY.x, axisZ.x, trans.x],
9
+ [axisX.y, axisY.y, axisZ.y, trans.y],
10
+ [axisX.z, axisY.z, axisZ.z, trans.z],
11
+ [0, 0, 0, 1]
12
+ ]
13
+ end
14
+
15
+ # The processing version changes the input 'array', here we return
16
+ # a new array with transformed values (which we then assign to the input)
17
+ # see line 89 Frame_of_Reference.rb
18
+
19
+ def mult(array)
20
+ array.map { |arr|
21
+ xt = mat[0][0] * arr.x + mat[0][1] * arr.y + mat[0][2] * arr.z + mat[0][3] * 1
22
+ yt = mat[1][0] * arr.x + mat[1][1] * arr.y + mat[1][2] * arr.z + mat[1][3] * 1
23
+ zt = mat[2][0] * arr.x + mat[2][1] * arr.y + mat[2][2] * arr.z + mat[2][3] * 1
24
+ Vec3D.new(xt, yt, zt)
25
+ }
26
+ end
27
+ end
28
+
@@ -0,0 +1,60 @@
1
+ NORM_LEN = 225.0
2
+
3
+ class Plane
4
+ include Processing::Proxy
5
+
6
+ attr_reader :vecs, :c, :n
7
+
8
+
9
+ def initialize(vecs)
10
+ @vecs = vecs
11
+ init
12
+ end
13
+
14
+ def init
15
+ v1 = vecs[1] - vecs[0]
16
+ v2 = vecs[2] - vecs[0]
17
+
18
+ @c = Vec3D.new(
19
+ (vecs[0].x + vecs[1].x + vecs[2].x) / 3,
20
+ (vecs[0].y + vecs[1].y + vecs[2].y) / 3,
21
+ (vecs[0].z + vecs[1].z + vecs[2].z) / 3
22
+ )
23
+
24
+ @n = v1.cross(v2)
25
+ n.normalize!
26
+ end
27
+
28
+ def display(renderer)
29
+ begin_shape(TRIANGLES)
30
+ vecs.map { |vec| vec.to_vertex(renderer) }
31
+ end_shape
32
+
33
+ #normal
34
+ stroke(200, 160, 30)
35
+ begin_shape(LINES)
36
+ c.to_vertex(renderer)
37
+ (c + n * NORM_LEN).to_vertex(renderer)
38
+ end_shape
39
+
40
+ #binormal
41
+ stroke(160, 200, 30)
42
+ begin_shape(LINES)
43
+ c.to_vertex(renderer)
44
+ # tangent
45
+ v = vecs[1].copy
46
+ #v.set(vecs[1])
47
+ v -= vecs[0]
48
+ v.normalize!
49
+ (c + v * NORM_LEN).to_vertex(renderer)
50
+ end_shape
51
+
52
+ stroke(30, 200, 160)
53
+ begin_shape(LINES)
54
+ c.to_vertex(renderer)
55
+ b = v.cross(n)
56
+ (c + b * NORM_LEN).to_vertex(renderer)
57
+ end_shape
58
+ stroke(0, 75)
59
+ end
60
+ end
@@ -39,20 +39,18 @@ class Hilbert
39
39
  :theta, :distance, :phi, :gen, :adj_array
40
40
 
41
41
  def initialize(size: 1.0, gen: 1)
42
- @axiom = "X" # AXIOM
43
- @rule = {"X" => "^<XF^<XFX-F^>>XFX&F+>>XFX-F>X->"} # RULE
42
+ @axiom = 'X' # AXIOM
43
+ @rule = {'X' => '^<XF^<XFX-F^>>XFX&F+>>XFX-F>X->'} # RULE
44
44
  @gen = gen
45
45
  @grammar = Grammar.new(axiom, rule)
46
46
  @production = grammar.generate gen
47
47
  @distance = size / (gen**2 - 1)
48
48
  @theta = radians 90
49
49
  @phi = radians 90
50
- @adj_array = [0, 0.5, 1.5, 3.5, 7.5, 15].map{|x| Vec3D.new(x * -1, x, x * -1)}
51
-
50
+ @adj_array = [0, 0.5, 1.5, 3.5, 7.5, 15].map { |x| Vec3D.new(x * -1, x, x * -1) }
52
51
  end
53
52
 
54
- def render()
55
- #translate( -distance * ADJUSTMENT[gen], distance * ADJUSTMENT[gen], -distance * ADJUSTMENT[gen])
53
+ def draw
56
54
  adj = adj_array[gen] * distance
57
55
  translate(adj.x, adj.y, adj.z)
58
56
  fill(0, 75, 152)
@@ -61,27 +59,26 @@ class Hilbert
61
59
  shininess(1.0)
62
60
  production.each do |ch|
63
61
  case(ch)
64
- when "F"
65
- translate(0, distance/-2, 0)
62
+ when 'F'
63
+ translate(0, distance / -2, 0)
66
64
  box(distance/9 , distance, distance/9)
67
- translate(0, distance/-2, 0)
68
- when "+"
65
+ translate(0, distance / -2, 0)
66
+ when '+'
69
67
  rotateX(-theta)
70
- when "-"
68
+ when '-'
71
69
  rotateX(theta)
72
- when ">"
70
+ when '>'
73
71
  rotateY(theta)
74
- when "<"
72
+ when '<'
75
73
  rotateY(-theta)
76
- when "&"
74
+ when '&'
77
75
  rotateZ(-phi)
78
- when "^"
76
+ when '^'
79
77
  rotateZ(phi)
80
- when "X"
78
+ when 'X'
81
79
  else
82
80
  puts("character '#{ch}' not in grammar")
83
81
  end
84
82
  end
85
83
  end
86
-
87
84
  end
@@ -5,22 +5,16 @@
5
5
  ##########################
6
6
 
7
7
  load_library 'vecmath'
8
- import "vecmath"
9
8
 
10
9
  PTS = [-1, 0, 1]
11
10
  MIN_SIZE = 20
12
- X = 0
13
- Y = 1
14
- Z = 2
15
11
 
16
- attr_reader :arcball, :menger
12
+ attr_reader :menger
17
13
 
18
14
  def setup
19
15
  size(640, 480, P3D)
20
16
  smooth(8)
21
- camera
22
- camera(width/2.0, height/2.0, (height/2.0) / tan(PI*30.0 / 180.0), 0, 0, 0, 0, 1, 0)
23
- @arcball = ArcBall.new(0, 0, min(width - 20, height - 20) * 0.8)
17
+ ArcBall.init(self)
24
18
  @menger = create_shape(GROUP)
25
19
  create_menger(0, 0, 0, height * 0.8)
26
20
  end
@@ -29,28 +23,27 @@ def draw
29
23
  background(20, 20, 200)
30
24
  no_stroke
31
25
  lights
32
- update
33
- define_lights
26
+ define_light
34
27
  render
35
- end
28
+ end
36
29
 
37
30
  def render
38
31
  menger.set_fill(color(224, 223, 219))
39
- menger.set_ambient(50)
40
- menger.set_specular(150)
32
+ menger.set_ambient(50)
33
+ menger.set_specular(150)
41
34
  shape(menger)
42
35
  end
43
36
 
44
37
  def create_menger(xx, yy, zz, sz)
45
38
  u = sz / 3.0
46
- if (sz < MIN_SIZE) # recursion limited by minimum cube size
39
+ if sz < MIN_SIZE # recursion limited by minimum cube size
47
40
  no_stroke
48
- menger.add_child(create_cube(xx, yy, zz, sz)) # create and add a cube
41
+ menger.add_child(create_cube(xx, yy, zz, sz)) # create and add a cube
49
42
  else
50
43
  PTS.each do |i|
51
44
  PTS.each do |j|
52
45
  PTS.each do |k|
53
- if ((i.abs + j.abs + k.abs) > 1)
46
+ if (i.abs + j.abs + k.abs) > 1
54
47
  create_menger(xx + (i * u), yy + (j * u), zz + (k * u), u)
55
48
  end
56
49
  end
@@ -70,41 +63,41 @@ def create_cube(xx, yy, zz, sz)
70
63
  cube.vertex(+dim + xx, -dim + yy, -dim + zz)
71
64
  cube.vertex(+dim + xx, +dim + yy, -dim + zz)
72
65
  cube.vertex(-dim + xx, +dim + yy, -dim + zz)
73
-
66
+
74
67
  # Back face
75
-
68
+
76
69
  cube.normal(0, 0, -1)
77
70
  cube.vertex(-dim + xx, -dim + yy, +dim + zz)
78
71
  cube.vertex(+dim + xx, -dim + yy, +dim + zz)
79
72
  cube.vertex(+dim + xx, +dim + yy, +dim + zz)
80
73
  cube.vertex(-dim + xx, +dim + yy, +dim + zz)
81
-
74
+
82
75
  # Left face
83
-
76
+
84
77
  cube.normal(1, 0, 0)
85
78
  cube.vertex(-dim + xx, -dim + yy, -dim + zz)
86
79
  cube.vertex(-dim + xx, -dim + yy, +dim + zz)
87
80
  cube.vertex(-dim + xx, +dim + yy, +dim + zz)
88
81
  cube.vertex(-dim + xx, +dim + yy, -dim + zz)
89
-
82
+
90
83
  # Right face
91
-
84
+
92
85
  cube.normal(-1, 0, 0)
93
86
  cube.vertex(+dim + xx, -dim + yy, -dim + zz)
94
87
  cube.vertex(+dim + xx, -dim + yy, +dim + zz)
95
88
  cube.vertex(+dim + xx, +dim + yy, +dim + zz)
96
89
  cube.vertex(+dim + xx, +dim + yy, -dim + zz)
97
-
90
+
98
91
  # Top face
99
-
92
+
100
93
  cube.normal(0, 1, 0)
101
94
  cube.vertex(-dim + xx, -dim + yy, -dim + zz)
102
95
  cube.vertex(+dim + xx, -dim + yy, -dim + zz)
103
96
  cube.vertex(+dim + xx, -dim + yy, +dim + zz)
104
97
  cube.vertex(-dim + xx, -dim + yy, +dim + zz)
105
-
98
+
106
99
  # Bottom face
107
-
100
+
108
101
  cube.normal(0, -1, 0)
109
102
  cube.vertex(-dim + xx, +dim + yy, -dim + zz)
110
103
  cube.vertex(+dim + xx, +dim + yy, -dim + zz)
@@ -112,19 +105,6 @@ def create_cube(xx, yy, zz, sz)
112
105
  cube.vertex(-dim + xx, +dim + yy, +dim + zz)
113
106
  cube.end_shape
114
107
  return cube
115
- end
116
-
117
- def update
118
- theta, x, y, z = arcball.update
119
- rotate(theta, x, y, z)
120
- end
121
-
122
- def mouse_pressed
123
- arcball.mouse_pressed(mouse_x, mouse_y)
124
- end
125
-
126
- def mouse_dragged
127
- arcball.mouse_dragged(mouse_x, mouse_y)
128
108
  end
129
109
 
130
110
  def define_lights
@@ -132,19 +112,4 @@ def define_lights
132
112
  point_light(30, 30, 30, 200, 240, 0)
133
113
  directional_light(50, 50, 50, 1, 0, 0)
134
114
  spot_light(30, 30, 30, 0, 40, 200, 0, -0.5, -0.5, PI / 2, 2)
135
- end
136
-
137
- def key_pressed
138
- case(key)
139
- when 'x'
140
- arcball.select_axis(X)
141
- when 'y'
142
- arcball.select_axis(Y)
143
- when 'z'
144
- arcball.select_axis(Z)
145
- end
146
- end
147
-
148
- def key_released
149
- arcball.select_axis(-1)
150
- end
115
+ 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 :default => [:demo]
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("*.rb").each do |file|
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 --nojruby run #{sample_name}", "r") do |io|
25
+ open("|rp5 --nojruby 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
@@ -15,8 +15,8 @@ end
15
15
  ################################
16
16
  # This sketch is translated from a vanilla processing sketch by Daniel Schiffman
17
17
  # that was designed to demonstrate the use IntHash class in vanilla processing.
18
- # Similar results can easily be obtained using more idiomatic ruby. Here IntHash
19
- # has been replaced by a String => Word hash (as used in a Schiffman prototype).
18
+ # Similar results can easily be obtained using more idiomatic ruby. Here IntHash
19
+ # has been replaced by a String => Word hash (as used in a Schiffman prototype).
20
20
  # Read about concordance here:-
21
21
  # http://en.wikipedia.org/wiki/Concordance_(publishing)
22
22
  ################################
@@ -28,15 +28,15 @@ def setup
28
28
  @counter = 0
29
29
  @concordance = {}
30
30
  # Open a file, read its contents, and 'scan' for words using a regex.
31
- # Include words with apostrophe eg Harker's
32
- @tokens = File.read(data_path("dracula.txt")).scan(/[\w'-]+/)
33
- text_font(create_font("Georgia", 24))
31
+ # Include words with apostrophe eg Harker's
32
+ @tokens = File.read(data_path('dracula.txt')).scan(/[\w'-]+/)
33
+ text_font(create_font('Georgia', 24))
34
34
  end
35
35
 
36
36
  def draw
37
37
  background 51
38
38
  fill 255
39
- s = (tokens[counter] == "I")? tokens[counter] : tokens[counter].downcase
39
+ s = (tokens[counter] == 'I')? tokens[counter] : tokens[counter].downcase
40
40
  @counter = (counter + 1) % tokens.length
41
41
  if (concordance.has_key?(s))
42
42
  # Get the word object and increase the count
@@ -44,7 +44,7 @@ def draw
44
44
  w = concordance[s]
45
45
  w.increment # increment word count
46
46
  else
47
- # Otherwise make a new Word instance and add it to
47
+ # Otherwise make a new Word instance and add it to
48
48
  # the Hash using the word String as the key
49
49
  concordance[s] = Word.new(s)
50
50
  end
@@ -20,19 +20,4 @@
20
20
  <diameter>44.758068</diameter>
21
21
  <label>Melancholy</label>
22
22
  </bubble>
23
- <bubble>
24
- <position x="556" y="224"/>
25
- <diameter>46.89752406647077</diameter>
26
- <label>New label</label>
27
- </bubble>
28
- <bubble>
29
- <position x="433" y="239"/>
30
- <diameter>47.570771727260535</diameter>
31
- <label>New label</label>
32
- </bubble>
33
- <bubble>
34
- <position x="479" y="91"/>
35
- <diameter>65.08462326872998</diameter>
36
- <label>New label</label>
37
- </bubble>
38
23
  </bubbles>