ruby-processing 2.6.2 → 2.6.3

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 (129) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rpextras.jar +0 -0
  3. data/lib/ruby-processing.rb +5 -8
  4. data/lib/ruby-processing/app.rb +26 -27
  5. data/lib/ruby-processing/config.rb +0 -2
  6. data/lib/ruby-processing/exporters/application_exporter.rb +1 -1
  7. data/lib/ruby-processing/exporters/base_exporter.rb +1 -1
  8. data/lib/ruby-processing/exporters/creator.rb +11 -11
  9. data/lib/ruby-processing/helper_methods.rb +33 -31
  10. data/lib/ruby-processing/helpers/numeric.rb +1 -1
  11. data/lib/ruby-processing/helpers/range.rb +11 -0
  12. data/lib/ruby-processing/library_loader.rb +11 -16
  13. data/lib/ruby-processing/runner.rb +22 -24
  14. data/lib/ruby-processing/runners/watch.rb +1 -1
  15. data/lib/ruby-processing/version.rb +1 -1
  16. data/library/boids/boids.rb +39 -70
  17. data/library/control_panel/control_panel.rb +3 -3
  18. data/samples/contributed/circle_collision.rb +3 -3
  19. data/samples/contributed/fern.rb +7 -10
  20. data/samples/contributed/fibonacci_sphere.rb +2 -2
  21. data/samples/contributed/full_screen.rb +23 -22
  22. data/samples/contributed/grapher.rb +3 -3
  23. data/samples/contributed/gravity.rb +1 -1
  24. data/samples/contributed/mandelbrot.rb +10 -13
  25. data/samples/external_library/java_processing/box2d_processing/bumpy_surface_noise.rb +1 -1
  26. data/samples/external_library/java_processing/box2d_processing/library/custom_shape/custom_shape.rb +2 -2
  27. data/samples/external_library/java_processing/box2d_processing/library/particle_system/particle_system.rb +1 -1
  28. data/samples/external_library/java_processing/box2d_processing/library/surface/surface.rb +2 -2
  29. data/samples/external_library/java_processing/box2d_processing/liquidy.rb +1 -1
  30. data/samples/external_library/java_processing/fisica/bubbles.rb +2 -2
  31. data/samples/external_library/java_processing/fisica/joints.rb +4 -4
  32. data/samples/external_library/java_processing/generative_design/node_spring_attractor.rb +2 -2
  33. data/samples/external_library/java_processing/geomerative/hello_world_rotate_firstletter.rb +7 -7
  34. data/samples/external_library/java_processing/hemesh/twin_iso.rb +3 -3
  35. data/samples/external_library/java_processing/pbox2d/bumpy_surface_noise.rb +1 -1
  36. data/samples/external_library/java_processing/pbox2d/library/custom_shape/custom_shape.rb +2 -2
  37. data/samples/external_library/java_processing/pbox2d/library/particle_system/particle_system.rb +1 -1
  38. data/samples/external_library/java_processing/pbox2d/library/surface/surface.rb +2 -2
  39. data/samples/external_library/java_processing/pbox2d/liquidy.rb +1 -1
  40. data/samples/external_library/java_processing/peasy_cam/library/hilbert/hilbert.rb +4 -4
  41. data/samples/external_library/ruby_gem/draw_test.rb +2 -2
  42. data/samples/external_library/ruby_gem/game_of_life.rb +3 -3
  43. data/samples/processing_app/basics/arrays/array_objects.rb +2 -2
  44. data/samples/processing_app/basics/color/hue.rb +1 -1
  45. data/samples/processing_app/basics/control/conditionals1.rb +5 -24
  46. data/samples/processing_app/basics/control/conditionals2.rb +1 -1
  47. data/samples/processing_app/basics/form/bezier_ellipse.rb +1 -1
  48. data/samples/processing_app/basics/form/brick_tower.rb +4 -8
  49. data/samples/processing_app/basics/form/regular_polygon.rb +1 -1
  50. data/samples/processing_app/basics/form/star.rb +1 -1
  51. data/samples/processing_app/basics/form/triangle_strip.rb +1 -1
  52. data/samples/processing_app/basics/input/storing_input.rb +1 -1
  53. data/samples/processing_app/basics/lights/spot.rb +1 -1
  54. data/samples/processing_app/basics/math/additive_wave.rb +2 -2
  55. data/samples/processing_app/basics/math/double_random.rb +2 -2
  56. data/samples/processing_app/basics/math/noise_wave.rb +1 -1
  57. data/samples/processing_app/basics/math/random.rb +1 -1
  58. data/samples/processing_app/basics/objects/module.rb +1 -1
  59. data/samples/processing_app/basics/objects/struct.rb +1 -1
  60. data/samples/processing_app/basics/structure/loop.rb +19 -14
  61. data/samples/processing_app/basics/structure/recursion2.rb +2 -2
  62. data/samples/processing_app/basics/textures/texture3.rb +13 -33
  63. data/samples/processing_app/basics/transform/birds.rb +5 -5
  64. data/samples/processing_app/basics/transform/cubes_in_cube.rb +3 -3
  65. data/samples/processing_app/basics/transform/rotate.rb +1 -1
  66. data/samples/processing_app/basics/typography/kinetic_type.rb +1 -1
  67. data/samples/processing_app/demos/graphics/bezier_patch.rb +34 -34
  68. data/samples/processing_app/demos/graphics/trefoil.rb +1 -1
  69. data/samples/processing_app/demos/graphics/wiggling.rb +5 -5
  70. data/samples/processing_app/demos/performance/esfera.rb +4 -4
  71. data/samples/processing_app/demos/performance/text_rendering.rb +1 -1
  72. data/samples/processing_app/library/dxf/simple_export.rb +3 -3
  73. data/samples/processing_app/library/pdf/complex_3D.rb +11 -11
  74. data/samples/processing_app/library/vecmath/vec2d/bouncing_ball.rb +1 -1
  75. data/samples/processing_app/library/vecmath/vec2d/circle_collision.rb +3 -3
  76. data/samples/processing_app/library/vecmath/vec2d/library/flock/flock.rb +5 -5
  77. data/samples/processing_app/library/vecmath/vec2d/library/particle/{particle_system.rb → particle.rb} +28 -21
  78. data/samples/processing_app/library/vecmath/vec2d/morph.rb +3 -3
  79. data/samples/processing_app/library/vecmath/vec2d/particle_system_pshape.rb +3 -3
  80. data/samples/processing_app/library/vecmath/vec2d/reflection1.rb +2 -2
  81. data/samples/processing_app/library/vecmath/vec2d/seeking_neural.rb +3 -2
  82. data/samples/processing_app/library/vecmath/vec2d/simple_particle_system.rb +1 -1
  83. data/samples/processing_app/library/vecmath/vec3d/frame_of_reference.rb +4 -4
  84. data/samples/processing_app/topics/advanced_data/library/word/word.rb +1 -1
  85. data/samples/processing_app/topics/advanced_data/load_save_XML.rb +1 -1
  86. data/samples/processing_app/topics/advanced_data/load_save_json.rb +1 -1
  87. data/samples/processing_app/topics/advanced_data/load_save_struct_yaml.rb +1 -1
  88. data/samples/processing_app/topics/advanced_data/load_save_yaml.rb +1 -1
  89. data/samples/processing_app/topics/advanced_data/threads_two.rb +1 -2
  90. data/samples/processing_app/topics/cellular_automata/game_of_life.rb +3 -3
  91. data/samples/processing_app/topics/cellular_automata/library/ca/ca.rb +2 -2
  92. data/samples/processing_app/topics/cellular_automata/library/cell/cell.rb +4 -4
  93. data/samples/processing_app/topics/cellular_automata/library/simple_cell/simple_cell.rb +1 -1
  94. data/samples/processing_app/topics/cellular_automata/spore1.rb +1 -1
  95. data/samples/processing_app/topics/cellular_automata/spore2.rb +1 -1
  96. data/samples/processing_app/topics/create_shapes/group_pshape.rb +2 -2
  97. data/samples/processing_app/topics/create_shapes/library/particle/particle_system.rb +3 -3
  98. data/samples/processing_app/topics/create_shapes/library/polygon/polygon.rb +2 -2
  99. data/samples/processing_app/topics/create_shapes/library/star/star.rb +3 -3
  100. data/samples/processing_app/topics/create_shapes/particle_system_pshape.rb +1 -1
  101. data/samples/processing_app/topics/create_shapes/path_pshape.rb +1 -1
  102. data/samples/processing_app/topics/drawing/scribble_plotter.rb +2 -2
  103. data/samples/processing_app/topics/gui/button.rb +16 -16
  104. data/samples/processing_app/topics/gui/rollover.rb +13 -13
  105. data/samples/processing_app/topics/image_processing/blur.rb +2 -2
  106. data/samples/processing_app/topics/image_processing/edge_detection.rb +2 -2
  107. data/samples/processing_app/topics/lsystems/cstest.rb +1 -1
  108. data/samples/processing_app/topics/lsystems/library/stochastic_grammar/stochastic_grammar.rb +1 -1
  109. data/samples/processing_app/topics/motion/bouncy_bubbles.rb +1 -1
  110. data/samples/processing_app/topics/motion/brownian.rb +2 -2
  111. data/samples/processing_app/topics/motion/circle_collision.rb +1 -1
  112. data/samples/processing_app/topics/motion/cubes_in_cube.rb +1 -1
  113. data/samples/processing_app/topics/motion/library/cube/cube.rb +2 -2
  114. data/samples/processing_app/topics/motion/morph.rb +11 -11
  115. data/samples/processing_app/topics/motion/moving_on_curves.rb +4 -4
  116. data/samples/processing_app/topics/motion/puff.rb +4 -4
  117. data/samples/processing_app/topics/motion/reflection1.rb +3 -3
  118. data/samples/processing_app/topics/motion/reflection2.rb +1 -1
  119. data/samples/processing_app/topics/shaders/bw_shader.rb +1 -1
  120. data/samples/processing_app/topics/shaders/glsl_heightmap_noise.rb +2 -2
  121. data/samples/processing_app/topics/simulate/flocking.rb +6 -6
  122. data/samples/processing_app/topics/simulate/library/flock/flock.rb +33 -41
  123. data/samples/processing_app/topics/simulate/multiple_particle_systems.rb +34 -60
  124. data/samples/processing_app/topics/simulate/simple_particle_system.rb +20 -32
  125. data/samples/processing_app/topics/simulate/smoke_particle_system.rb +45 -57
  126. data/samples/processing_app/topics/simulate/springs.rb +40 -44
  127. metadata +4 -5
  128. data/samples/processing_app/library/vecmath/vec2d/multiple_particle_systems.rb +0 -141
  129. data/samples/processing_app/library/vecmath/vec2d/smoke_particle_system.rb +0 -133
@@ -10,7 +10,7 @@ class Ball
10
10
  @position = Vec2D.new(x, y)
11
11
  @r = r
12
12
  @m = r * 0.1
13
- @velocity = Vec2D.new(rand(-3.0 .. 3), rand(-3.0 .. 3))
13
+ @velocity = Vec2D.new(rand(-3.0..3), rand(-3.0..3))
14
14
  end
15
15
 
16
16
  def update
@@ -18,10 +18,10 @@ class Ball
18
18
  end
19
19
 
20
20
  def check_boundary width, height
21
- if !(r .. width - r).include?(position.x)
21
+ if !(r..width - r).include?(position.x)
22
22
  (position.x > width - r)? position.x = width - r : position.x = r
23
23
  velocity.x *= -1
24
- elsif !(r .. height - r).include?(position.y)
24
+ elsif !(r..height - r).include?(position.y)
25
25
  (position.y > height - r)? position.y = height - r : position.y = r
26
26
  velocity.y *= -1
27
27
  end
@@ -2,7 +2,7 @@
2
2
  # by Luis Correia
3
3
 
4
4
  attr_reader :boundary
5
-
5
+
6
6
  def setup
7
7
  size 500, 500
8
8
  @boundary = Boundary.new(0, width )
@@ -16,10 +16,9 @@ def draw
16
16
  x0, y0 = 0.0, 0.0
17
17
  x, y, r = 0.0, 0.0, 0.0
18
18
  i, j = 0, 0
19
- max_iterations = 200000
20
-
19
+ max_iterations = 200_000
21
20
  max_iterations.times do
22
- r = rand(0 .. 100.0)
21
+ r = rand(0..100.0)
23
22
  if r <= 1
24
23
  x = 0.0
25
24
  y = 0.16 * y0
@@ -29,26 +28,24 @@ def draw
29
28
  elsif r <= 14
30
29
  x = -0.15 * x0 + 0.28 * y0
31
30
  y = 0.26 * x0 + 0.24 * y0
32
- else
31
+ else
33
32
  x = 0.85 * x0 + 0.04 * y0
34
33
  y = -0.004 * x0 + 0.85 * y0 + 1.6
35
34
  end
36
-
37
35
  i = height - (y * 45).to_i
38
36
  j = width / 2 + (x * 45).to_i
39
- pixels[i * height + j] += 2560 if (boundary.include?(i) && boundary.include?(j))
37
+ pixels[i * height + j] += 2_560 if (boundary.include?(i) && boundary.include?(j))
40
38
  x0, y0 = x, y
41
39
  end
42
-
43
40
  update_pixels
44
41
  end
45
42
 
46
43
  # Abstract boundary checking to this
47
44
  # lightweight class
48
45
  #
49
-
46
+
50
47
  Boundary = Struct.new(:lower, :upper) do
51
48
  def include? x
52
- (lower ... upper).cover? x
49
+ (lower...upper).cover? x
53
50
  end
54
51
  end
@@ -52,7 +52,7 @@ end
52
52
 
53
53
  def render_globe
54
54
  push_matrix
55
- (0 .. [nbr_points, pts.length].min).each do |i|
55
+ (0..[nbr_points, pts.length].min).each do |i|
56
56
  lat = pts[i].lat
57
57
  lon = pts[i].lon
58
58
  push_matrix
@@ -73,7 +73,7 @@ end
73
73
  SpherePoint = Struct.new(:lat, :lon)
74
74
 
75
75
  def init_sphere(num)
76
- (0 .. num).each do |i|
76
+ (0..num).each do |i|
77
77
  lon = GA * i
78
78
  lon /= TAU
79
79
  lon -= lon.floor
@@ -2,27 +2,28 @@
2
2
  # This is a full-screen demo
3
3
  # Since processing-2.0 it is opengl
4
4
 
5
- full_screen
6
-
7
-
8
- def setup
9
- size displayWidth, displayHeight, P3D
10
- no_stroke
11
- end
12
-
13
- def draw
14
- lights
15
- background 0
16
- fill 120, 160, 220
17
- (width/100).times do |x|
18
- (height/100).times do |y|
19
- new_x, new_y = x * 100, y * 100
20
- push_matrix
21
- translate new_x + 50, new_y + 50
22
- rotate_y(((mouse_x.to_f + new_x) / width) * Math::PI)
23
- rotate_x(((mouse_y.to_f + new_y) / height) * Math::PI)
24
- box 90
25
- pop_matrix
26
- end
5
+ class FullScreen < Processing::App
6
+ def setup
7
+ size displayWidth, displayHeight, P3D
8
+ no_stroke
27
9
  end
10
+
11
+ def draw
12
+ lights
13
+ background 0
14
+ fill 120, 160, 220
15
+ (width/100).times do |x|
16
+ (height/100).times do |y|
17
+ new_x, new_y = x * 100, y * 100
18
+ push_matrix
19
+ translate new_x + 50, new_y + 50
20
+ rotate_y(((mouse_x.to_f + new_x) / width) * Math::PI)
21
+ rotate_x(((mouse_y.to_f + new_y) / height) * Math::PI)
22
+ box 90
23
+ pop_matrix
24
+ end
25
+ end
26
+ end
28
27
  end
28
+ # Full screen should now be set at runtime, now there is only one way to do it!
29
+ FullScreen.new(full_screen: true)
@@ -15,12 +15,12 @@ def setup
15
15
  no_stroke
16
16
  color_mode(HSB, 1.0)
17
17
  background(0)
18
- frame_rate(4000)
18
+ frame_rate(4_000)
19
19
  end
20
20
 
21
21
  def draw
22
22
  translate(width / 2, height / 2)
23
- dot(rand(-180 .. 180), rand(-180 .. 180), rand(CMIN .. CMAX)) unless frame_count > 200_000
23
+ dot(rand(-180..180), rand(-180..180), rand(CMIN..CMAX)) unless frame_count > 200_000
24
24
  end
25
25
 
26
26
  def dot(px, py, c)
@@ -31,6 +31,6 @@ def dot(px, py, c)
31
31
  fill(((CMIN - c) / (CMIN - CMAX)), 1, 1)
32
32
  ellipse px * width / 360, py * height / 360, SZ, SZ
33
33
  else
34
- dot(rand(-180 .. 180), rand(-180 .. 180), rand(CMIN .. CMAX))
34
+ dot(rand(-180..180), rand(-180..180), rand(CMIN..CMAX))
35
35
  end
36
36
  end
@@ -23,7 +23,7 @@ end
23
23
  def mouse_pressed
24
24
  return if mouse_x == 0 || mouse_y == 0
25
25
  return if particle_grab
26
- particles << Particle.new(mouse_x, mouse_y, rand(0.1 .. 8))
26
+ particles << Particle.new(mouse_x, mouse_y, rand(0.1..8))
27
27
  end
28
28
 
29
29
  def mouse_released
@@ -1,26 +1,27 @@
1
1
  # Mandelbrot Set example
2
2
  # by Jordan Scales (http://jordanscales.com)
3
- # 27 Dec 2012
4
-
5
-
3
+ # Modified to use map1d (instead of map), and somewhat
4
+ # optimized (update_pixels instead of set, and hypot for abs)
6
5
  # default size 900x600
7
6
  # no need to loop
7
+
8
8
  def setup
9
9
  size 900, 600
10
+ load_pixels
10
11
  no_loop
11
12
  end
12
13
 
13
14
  # main drawing method
14
15
  def draw
15
- (0..900).each do |x|
16
- (0..600).each do |y|
17
- c = Complex.new(map(x, 0, 900, -3, 1.5), map(y, 0, 600, -1.5, 1.5))
18
-
16
+ (0...900).each do |x|
17
+ (0...600).each do |y|
18
+ c = Complex.new(map1d(x, (0...900), (-3..1.5)), map1d(y, (0...600), (-1.5..1.5)))
19
19
  # mandel will return 0 to 20 (20 is strong)
20
20
  # map this to 0, 255 (and flip it)
21
- set(x, y, color(255 - map(mandel(c,20), 0, 20, 0, 255).to_i))
21
+ pixels[x + y * 900] = color(255 - map1d(mandel(c, 20), (0..20), (0..255)).to_i)
22
22
  end
23
23
  end
24
+ update_pixels
24
25
  end
25
26
 
26
27
  # calculates the "accuracy" of a given point in the mandelbrot set
@@ -33,14 +34,11 @@ def mandel(z, max = 10)
33
34
  z.square
34
35
  z.add c
35
36
  break if z.abs > 2
36
-
37
37
  score += 1
38
38
  end
39
-
40
39
  score
41
40
  end
42
41
 
43
-
44
42
  # rolled my own Complex class
45
43
  # stripped of all functionality, except for what I needed (abs, square, add, to_s)
46
44
  #
@@ -72,11 +70,10 @@ class Complex
72
70
 
73
71
  # computes the magnitude
74
72
  def abs
75
- sqrt(real * real + imag * imag)
73
+ hypot(real, imag)
76
74
  end
77
75
 
78
76
  def to_s
79
77
  "#{real} + #{imag}i"
80
78
  end
81
-
82
79
  end
@@ -38,7 +38,7 @@ def draw
38
38
  # Draw the surface
39
39
  surface.display
40
40
  # NB question mark is reqd to call mouse_pressed value, else method gets called.
41
- particles << Particle.new(box2d, mouse_x, mouse_y, rand(2.0 .. 6)) if mouse_pressed?
41
+ particles << Particle.new(box2d, mouse_x, mouse_y, rand(2.0..6)) if mouse_pressed?
42
42
  # Draw all particles
43
43
  particles.each do |p|
44
44
  p.display
@@ -91,8 +91,8 @@ module B2D
91
91
 
92
92
 
93
93
  # Give it some initial random velocity
94
- body.set_linear_velocity(Vec2.new(rand(-5 .. 5), rand(2 .. 5)))
95
- body.set_angular_velocity(rand(-5 .. 5))
94
+ body.set_linear_velocity(Vec2.new(rand(-5..5), rand(2..5)))
95
+ body.set_angular_velocity(rand(-5..5))
96
96
  end
97
97
  end
98
98
 
@@ -122,7 +122,7 @@ module PS
122
122
  @body = box2d.create_body(bd)
123
123
 
124
124
  # Give it some initial random velocity
125
- body.set_linear_velocity(PS::Vec2.new(rand(-1 .. 1), rand(-1 .. 1)))
125
+ body.set_linear_velocity(PS::Vec2.new(rand(-1..1), rand(-1..1)))
126
126
 
127
127
  # Make the body's shape a circle
128
128
  cs = PS::CircleShape.new
@@ -144,8 +144,8 @@ module SB
144
144
  # Attach fixture to body
145
145
  body.create_fixture(fd)
146
146
  # Give it a random initial velocity (and angular velocity)
147
- body.set_linear_velocity(SB::Vec2.new(rand(-10 .. 10), rand(5 .. 10)))
148
- body.set_angular_velocity(rand(-10 .. 10))
147
+ body.set_linear_velocity(SB::Vec2.new(rand(-10..10), rand(5..10)))
148
+ body.set_angular_velocity(rand(-10..10))
149
149
  end
150
150
  end
151
151
  end
@@ -37,7 +37,7 @@ def draw
37
37
  if systems.size > 0
38
38
  systems.each do |system|
39
39
  system.run
40
- system.add_particles(box2d, rand(0 .. 2))
40
+ system.add_particles(box2d, rand(0..2))
41
41
  end
42
42
  end
43
43
  # Display all the boundaries
@@ -56,9 +56,9 @@ def draw
56
56
  fill(0)
57
57
  if ((frame_count % 40) == 1)
58
58
  b = FBlob.new
59
- s = rand(30 .. 40)
59
+ s = rand(30..40)
60
60
  space = (width - SIDE_MARGIN * 2-s)
61
- @x_pos = (x_pos + rand(s .. space/2.0)) % space
61
+ @x_pos = (x_pos + rand(s..space/2.0)) % space
62
62
  b.set_as_circle(SIDE_MARGIN + x_pos + s / 2, height - rand(100), s, 20)
63
63
  b.set_stroke(0)
64
64
  b.set_stroke_weight(2)
@@ -62,11 +62,11 @@ def key_pressed
62
62
  end
63
63
 
64
64
  def create_spider
65
- pos_x = rand(MAIN_SIZE/2 .. width-MAIN_SIZE/2)
66
- pos_y = rand(MAIN_SIZE/2 .. height-MAIN_SIZE/2)
65
+ pos_x = rand(MAIN_SIZE/2..width-MAIN_SIZE/2)
66
+ pos_y = rand(MAIN_SIZE/2..height-MAIN_SIZE/2)
67
67
  main = Fis::FCircle.new(MAIN_SIZE)
68
68
  main.set_position(pos_x, pos_y)
69
- main.set_velocity(rand(-20 .. 20), rand(-20 .. 20))
69
+ main.set_velocity(rand(-20..20), rand(-20..20))
70
70
  main.set_fill_color(body_color)
71
71
  main.set_no_stroke
72
72
  main.set_group_index(2)
@@ -78,7 +78,7 @@ def create_spider
78
78
  y = LEG_SIZE * sin(i * TAU/3) + pos_y
79
79
  leg = Fis::FCircle.new(MAIN_SIZE/2)
80
80
  leg.set_position(pos_x, pos_y)
81
- leg.set_velocity(rand(-20 .. 20), rand(-20 ..20))
81
+ leg.set_velocity(rand(-20..20), rand(-20 ..20))
82
82
  leg.set_fill_color(body_color)
83
83
  leg.set_no_stroke
84
84
  world.add(leg)
@@ -17,8 +17,8 @@ def setup
17
17
  lights
18
18
  smooth(8)
19
19
  fill(0)
20
- @nodeA = GD::Node.new(rand * width, rand * height, rand(-200 .. 200))
21
- @nodeB = GD::Node.new(rand * width, rand * height, rand(-200 .. 200))
20
+ @nodeA = GD::Node.new(rand * width, rand * height, rand(-200..200))
21
+ @nodeB = GD::Node.new(rand * width, rand * height, rand(-200..200))
22
22
  nodeA.setStrength(-2)
23
23
  nodeB.setStrength(-2)
24
24
  nodeA.setDamping(0.1)
@@ -20,8 +20,8 @@ def setup
20
20
 
21
21
  fill(255,102,0)
22
22
  stroke(0)
23
-
24
- # Load the font file we want to use (the file must be in the data folder in the sketch floder),
23
+
24
+ # Load the font file we want to use (the file must be in the data folder in the sketch floder),
25
25
  # with the size 72 and the alignment CENTER
26
26
  @grp = RG::get_text("Hola Mundo!", "FreeSans.ttf", 72, CENTER)
27
27
  smooth 4
@@ -30,14 +30,14 @@ end
30
30
  def draw
31
31
  # Clean frame
32
32
  background(255)
33
-
33
+
34
34
  # Set the origin to draw in the middle of the sketch
35
35
  translate width / 2, height / 2
36
-
37
- # Transform at each frame the first letter with a PI/20 radians
36
+
37
+ # Transform at each frame the first letter with a PI/20 radians
38
38
  # rotation around the center of the first letter's center
39
- grp.children[0].rotate(PI/20, grp.children[0].get_center)
40
-
39
+ grp.children[0].rotate(PI / 20, grp.children[0].get_center)
40
+
41
41
  # Draw the group of shapes representing "Hola Mundo!" on the PGraphics canvas g (which is the default canvas of the sketch)
42
42
  grp.draw
43
43
  end
@@ -11,11 +11,11 @@ def setup
11
11
  ArcBall.init(self)
12
12
  smooth(8)
13
13
  values = [] # build a multi-dimensional array in ruby
14
- (0 .. RES).each do |i| # the inclusive range is intentional here
14
+ (0..RES).each do |i| # the inclusive range is intentional here
15
15
  valu = []
16
- (0 .. RES).each do |j|
16
+ (0..RES).each do |j|
17
17
  val = []
18
- (0 .. RES).each do |k|
18
+ (0..RES).each do |k|
19
19
  val << 2.1 * noise(0.35 * i, 0.35 * j, 0.35 * k)
20
20
  end
21
21
  valu << val
@@ -39,7 +39,7 @@ def draw
39
39
  # Draw the surface
40
40
  surface.display
41
41
  # NB question mark is reqd to call mouse_pressed value, else method gets called.
42
- particles << Particle.new(box2d, mouse_x, mouse_y, rand(2.0 .. 6)) if mouse_pressed?
42
+ particles << Particle.new(box2d, mouse_x, mouse_y, rand(2.0..6)) if mouse_pressed?
43
43
  # Draw all particles
44
44
  particles.each do |p|
45
45
  p.display
@@ -91,8 +91,8 @@ module B2D
91
91
 
92
92
 
93
93
  # Give it some initial random velocity
94
- body.set_linear_velocity(Vec2.new(rand(-5 .. 5), rand(2 .. 5)))
95
- body.set_angular_velocity(rand(-5 .. 5))
94
+ body.set_linear_velocity(Vec2.new(rand(-5..5), rand(2..5)))
95
+ body.set_angular_velocity(rand(-5..5))
96
96
  end
97
97
  end
98
98
 
@@ -125,7 +125,7 @@ module PS
125
125
  @body = box2d.create_body(bd)
126
126
 
127
127
  # Give it some initial random velocity
128
- body.set_linear_velocity(PS::Vec2.new(rand(-1 .. 1), rand(-1 .. 1)))
128
+ body.set_linear_velocity(PS::Vec2.new(rand(-1..1), rand(-1..1)))
129
129
 
130
130
  # Make the body's shape a circle
131
131
  cs = PS::CircleShape.new
@@ -144,8 +144,8 @@ module SB
144
144
  # Attach fixture to body
145
145
  body.create_fixture(fd)
146
146
  # Give it a random initial velocity (and angular velocity)
147
- body.set_linear_velocity(SB::Vec2.new(rand(-10 .. 10), rand(5 .. 10)))
148
- body.set_angular_velocity(rand(-10 .. 10))
147
+ body.set_linear_velocity(SB::Vec2.new(rand(-10..10), rand(5..10)))
148
+ body.set_angular_velocity(rand(-10..10))
149
149
  end
150
150
  end
151
151
  end
@@ -37,7 +37,7 @@ def draw
37
37
  if systems.size > 0
38
38
  systems.each do |system|
39
39
  system.run
40
- system.add_particles(box2d, rand(0 .. 2))
40
+ system.add_particles(box2d, rand(0..2))
41
41
  end
42
42
  end
43
43
  # Display all the boundaries
@@ -51,11 +51,11 @@ class Hilbert
51
51
  @rule = "^<XF^<XFX-F^>>XFX&F+>>XFX-F>X->"
52
52
  @distance = len
53
53
  @theta = Math::PI/180 * 90
54
- @phi = Math::PI/180 * 90
54
+ @phi = Math::PI/180 * 90
55
55
  grammar.add_rule(premis, rule)
56
56
  end
57
57
 
58
- def render()
58
+ def render()
59
59
  translate( -distance * ADJUSTMENT[gen], distance * ADJUSTMENT[gen], -distance * ADJUSTMENT[gen])
60
60
  fill(0, 75, 152)
61
61
  light_specular(204, 204, 204)
@@ -92,9 +92,9 @@ class Hilbert
92
92
 
93
93
  def create_grammar(gen)
94
94
  @gen = gen # required for depth adjustment
95
- @distance *= 1/(pow(2, gen) - 1)
95
+ @distance *= 1/(2**gen) - 1)
96
96
  @production = @grammar.generate gen
97
97
  end
98
-
98
+
99
99
 
100
100
  end