ruby-processing 2.5.0 → 2.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rpextras.jar +0 -0
  3. data/lib/ruby-processing/app.rb +26 -26
  4. data/lib/ruby-processing/exporters/base_exporter.rb +7 -5
  5. data/lib/ruby-processing/helper_methods.rb +78 -3
  6. data/lib/ruby-processing/version.rb +1 -1
  7. data/lib/templates/application/run.erb +4 -4
  8. data/samples/contributed/elegant_ball.rb +47 -37
  9. data/samples/contributed/tree.rb +1 -5
  10. data/samples/external_library/java_processing/custom/README.md +6 -5
  11. data/samples/external_library/java_processing/custom/Rakefile +17 -23
  12. data/samples/external_library/java_processing/custom/{src → ext}/nn/Connection.java +0 -0
  13. data/samples/external_library/java_processing/custom/{src → ext}/nn/HiddenNeuron.java +0 -0
  14. data/samples/external_library/java_processing/custom/{src → ext}/nn/InputNeuron.java +0 -0
  15. data/samples/external_library/java_processing/custom/{src → ext}/nn/Network.java +0 -0
  16. data/samples/external_library/java_processing/custom/{src → ext}/nn/Neuron.java +0 -0
  17. data/samples/external_library/java_processing/custom/{src → ext}/nn/OutputNeuron.java +0 -0
  18. data/samples/external_library/java_processing/custom/xor.rb +1 -1
  19. data/samples/external_library/ruby_gem/draw_test.rb +1 -1
  20. data/samples/processing_app/basics/arrays/array.rb +11 -11
  21. data/samples/processing_app/basics/color/blend_color.rb +17 -0
  22. data/samples/processing_app/basics/color/reading/reading.rb +20 -29
  23. data/samples/processing_app/basics/form/brick_tower.rb +11 -10
  24. data/samples/processing_app/basics/form/pie_chart.rb +4 -4
  25. data/samples/processing_app/basics/form/shape_transform.rb +17 -22
  26. data/samples/processing_app/basics/form/toroid.rb +16 -21
  27. data/samples/processing_app/basics/input/clock.rb +11 -10
  28. data/samples/processing_app/basics/math/sine_cosine.rb +6 -6
  29. data/samples/processing_app/basics/transform/bird.rb +9 -9
  30. data/samples/processing_app/basics/transform/birds.rb +1 -1
  31. data/samples/processing_app/basics/transform/library/bird/bird.rb +12 -12
  32. data/samples/processing_app/basics/transform/rotate.rb +10 -5
  33. data/samples/processing_app/basics/transform/triangle_flower.rb +3 -3
  34. data/samples/processing_app/library/fastmath/clock.rb +9 -7
  35. data/samples/processing_app/library/net/HTTPClient.rb +4 -2
  36. data/samples/processing_app/library/vecmath/arcball/arcball_box.rb +1 -1
  37. data/samples/processing_app/library/vecmath/arcball/arcball_radius.rb +1 -1
  38. data/samples/processing_app/library/vecmath/arcball/arcball_shape.rb +1 -1
  39. data/samples/processing_app/library/vecmath/vec2d/multiple_particle_systems.rb +1 -1
  40. data/samples/processing_app/library/vecmath/vec3d/retained_menger.rb +2 -2
  41. data/samples/processing_app/topics/create_shapes/particle_system_pshape.rb +1 -1
  42. data/samples/processing_app/topics/drawing/pulses.rb +3 -3
  43. data/samples/processing_app/topics/image_processing/linear_image.rb +1 -1
  44. data/samples/processing_app/topics/lsystems/csplant.rb +3 -3
  45. data/samples/processing_app/topics/motion/puff.rb +4 -4
  46. data/samples/processing_app/topics/shaders/glsl_heightmap_noise.rb +1 -1
  47. data/samples/processing_app/topics/shaders/landscape.rb +1 -1
  48. metadata +10 -9
@@ -22,14 +22,14 @@ end
22
22
  def draw
23
23
  background(0)
24
24
 
25
- ang1 = radians(angle1)
26
- ang2 = radians(angle2)
25
+ ang1 = angle1.radians
26
+ ang2 = angle2.radians
27
27
 
28
- x1 = width/2 + (SCALAR * cos(ang1))
29
- x2 = width/2 + (SCALAR * cos(ang2))
28
+ x1 = width / 2 + (SCALAR * cos(ang1))
29
+ x2 = width / 2 + (SCALAR * cos(ang2))
30
30
 
31
- y1 = height/2 + (SCALAR * sin(ang1))
32
- y2 = height/2 + (SCALAR * sin(ang2))
31
+ y1 = height / 2 + (SCALAR * sin(ang1))
32
+ y2 = height / 2 + (SCALAR * sin(ang2))
33
33
 
34
34
  fill(255)
35
35
  rect(width * 0.5, height * 0.5, 140, 140)
@@ -21,33 +21,33 @@ def draw
21
21
  background 0
22
22
  lights
23
23
 
24
- px = sin( ang3.radians ) * 170
25
- py = cos( ang3.radians ) * 300
26
- pz = sin( ang4.radians ) * 500
24
+ px = sin(ang3.radians) * 170
25
+ py = cos(ang3.radians) * 300
26
+ pz = sin(ang4.radians) * 500
27
27
 
28
28
  translate width/2 + px, height/2 + py, -700 + pz
29
29
 
30
- rotate_x sin( ang2.radians ) * 120
31
- rotate_y sin( ang2.radians ) * 50
32
- rotate_z sin( ang2.radians ) * 65
30
+ rotate_x sin(ang2.radians) * 120
31
+ rotate_y sin(ang2.radians) * 50
32
+ rotate_z sin(ang2.radians) * 65
33
33
 
34
34
  fill 153
35
35
  box 20, 100, 20
36
36
 
37
37
  fill 204
38
38
  push_matrix
39
- rotate_y sin( ang.radians ) * -20
39
+ rotate_y sin(ang.radians) * -20
40
40
  rect -75, -50, 75, 100
41
41
  pop_matrix
42
42
 
43
43
  push_matrix
44
- rotate_y sin( ang.radians ) * 20
44
+ rotate_y sin(ang.radians) * 20
45
45
  rect 0, -50, 75, 100
46
46
  pop_matrix
47
47
 
48
48
  @ang += flap_speed
49
49
 
50
- @flap_speed *= -1 if abs(ang) > PI
50
+ @flap_speed *= -1 if ang.abs > PI
51
51
 
52
52
  @ang2 += 0.01
53
53
  @ang3 += 2.0
@@ -24,6 +24,6 @@ end
24
24
  def draw
25
25
  background 0
26
26
  translate width/2, height/2, -700
27
- @birds.map {|b| b.fly}
27
+ @birds.map { |b| b.fly }
28
28
  end
29
29
 
@@ -11,7 +11,7 @@ class Bird
11
11
  attr_accessor :flap_speed
12
12
  attr_accessor :rot_speed
13
13
 
14
- def initialize ( offset_x, offset_y, offset_z, w, h )
14
+ def initialize(offset_x, offset_y, offset_z, w, h)
15
15
 
16
16
  defaults
17
17
  @offset_x, @offset_y, @offset_z = offset_x, offset_y, offset_z
@@ -27,18 +27,18 @@ class Bird
27
27
  @radius_x, @radius_y, @radius_z = 120.0, 200.0, 700.0
28
28
  end
29
29
 
30
- def set_flight ( radius_x, radius_y, radius_z, rot_x, rot_y, rot_z )
30
+ def set_flight(radius_x, radius_y, radius_z, rot_x, rot_y, rot_z)
31
31
  @radius_x, @radius_y, @radius_z = radius_x, radius_y, radius_z
32
32
  @rot_x, @rot_y, @rot_z = rot_x, rot_y, rot_z
33
33
  return self # return self means we can chain methods
34
34
  end
35
35
 
36
- def set_wing_speed ( flap_speed )
36
+ def set_wing_speed(flap_speed)
37
37
  @flap_speed = flap_speed
38
38
  return self # return self means we can chain methods
39
39
  end
40
40
 
41
- def set_rot_speed ( rot_speed )
41
+ def set_rot_speed(rot_speed)
42
42
  @rot_speed = rot_speed
43
43
  return self # return self means we can chain methods
44
44
  end
@@ -47,17 +47,17 @@ class Bird
47
47
 
48
48
  push_matrix
49
49
 
50
- px = sin( radians @ang3 ) * @radius_x
51
- py = cos( radians @ang3 ) * @radius_y
52
- pz = sin( radians @ang4 ) * @radius_z
50
+ px = sin(@ang3.radians) * @radius_x
51
+ py = cos(@ang3.radians) * @radius_y
52
+ pz = sin(@ang4.radians) * @radius_z
53
53
 
54
54
  translate @offset_x + px,
55
55
  @offset_y + py,
56
56
  @offset_z + pz
57
57
 
58
- rotate_x sin( radians @ang2 ) * @rot_x
59
- rotate_y sin( radians @ang2 ) * @rot_y
60
- rotate_z sin( radians @ang2 ) * @rot_z
58
+ rotate_x sin(@ang2.radians) * @rot_x
59
+ rotate_y sin(@ang2.radians) * @rot_y
60
+ rotate_z sin(@ang2.radians) * @rot_z
61
61
 
62
62
  fill @body_fill
63
63
  box @w/5, @h, @w/5
@@ -65,12 +65,12 @@ class Bird
65
65
  fill @wing_fill
66
66
 
67
67
  push_matrix
68
- rotate_y sin( radians @ang ) * 20
68
+ rotate_y sin(@ang.radians) * 20
69
69
  rect 0, -@h/2, @w, @h
70
70
  pop_matrix
71
71
 
72
72
  push_matrix
73
- rotate_y sin( radians @ang ) * -20
73
+ rotate_y sin(@ang.radians) * -20
74
74
  rect -@w, -@h/2, @w, @h
75
75
  pop_matrix
76
76
 
@@ -3,9 +3,14 @@
3
3
  # Rotating a square around the Z axis. To get the results
4
4
  # you expect, send the rotate function angle parameters that are
5
5
  # values between 0 and PI*2 (TAU which is roughly 6.28). If you prefer to
6
- # think about angles as degrees (0-360), you can use the radians()
7
- # method to convert your values. For example: scale(radians(90))
8
- # is identical to the statement scale(PI/2).
6
+ # think about angles as degrees (0-360), you can use the radians
7
+ # method to convert your values. For example: scale(90.radians)
8
+ # is identical to the statement scale(PI/2).
9
+
10
+
11
+ # Notice in ruby everything is an object, so we can chain stuff
12
+ # check it out using irb to see what you get with Time.now
13
+ # Time.now.sec and finally Time.now.sec.even? isn't ruby just wonderful
9
14
 
10
15
 
11
16
  def setup
@@ -21,9 +26,9 @@ end
21
26
 
22
27
  def draw
23
28
  background 51
24
- @jitter = rand(-0.1 .. 0.1) if second % 2 == 0
29
+ @jitter = rand(-0.1 .. 0.1) if Time.now.sec.even?
25
30
  @angle += @jitter
26
- translate width/2, height/2
31
+ translate width / 2, height / 2
27
32
  rotate cos(@angle)
28
33
  rect 0, 0, 180, 180
29
34
  end
@@ -2,7 +2,7 @@
2
2
  # by Ira Greenberg.
3
3
  #
4
4
  # Using rotate() and triangle() functions generate a pretty
5
- # flower. Uncomment the line "# rotate(rot+=radians(spin));"
5
+ # flower. Uncomment the line "# rotate(rot+=spin.radians);"
6
6
  # in the triBlur() function for a nice variation.
7
7
 
8
8
  attr_reader :pt, :shift, :spin, :fade
@@ -31,8 +31,8 @@ def tri_blur
31
31
  @fill_color += fade
32
32
  rotate spin
33
33
  # try these lines also ..
34
- #@rot += radians spin
35
- #rotate @rot
34
+ # @rot += spin.radians
35
+ # rotate @rot
36
36
  pt[0].x += shift
37
37
  pt[0].y -= shift / 2
38
38
  pt[1].x -= shift
@@ -1,4 +1,5 @@
1
- # The current time can be read with the second(), minute(), and hour()
1
+ # The current local time can be read with the Time.now
2
+ # the seconds Time.now.sec, minutes Time.now.min etc...
2
3
  # functions. In this example, DegLut.sin() and DegLut.cos() values are used to
3
4
  # set the position of the hands, perfect for degree precision Lookup Table.
4
5
  load_library :fastmath
@@ -13,7 +14,7 @@ def draw
13
14
  background 0
14
15
  fill 80
15
16
  no_stroke
16
- # adj factor to map 0-60 to 0-360 (seconds/minutes) & 0-12 to 0-360 (hours)
17
+ # adj factor to map 0-60 to 0-360 (sec/min) & 0-12 to 0-360 (hours)
17
18
  # since angles for DegLut.sin() and DegLut.cos() start at 3 o'clock we
18
19
  # subtract 90 degrees to make them start at the top.
19
20
  clock_x = lambda do |val, adj, length|
@@ -25,14 +26,15 @@ def draw
25
26
  ellipse 100, 100, 160, 160
26
27
  stroke 220
27
28
  stroke_weight 6
28
- line(100, 100, clock_x.call(hour % 12 + (minute / 60.0), 30, 50),
29
- clock_y.call(hour % 12 + (minute / 60.0), 30, 50))
29
+ t = Time.now
30
+ line(100, 100, clock_x.call(t.hour % 12 + (t.min / 60.0), 30, 50),
31
+ clock_y.call(t.hour % 12 + (t.min / 60.0), 30, 50))
30
32
  stroke_weight 3
31
- line(100, 100, clock_x.call(minute + (second / 60.0), 6, 60),
32
- clock_y.call(minute + (second / 60.0), 6, 60))
33
+ line(100, 100, clock_x.call(t.min + (t.sec / 60.0), 6, 60),
34
+ clock_y.call(t.min + (t.sec / 60.0), 6, 60))
33
35
  stroke 255, 0, 0
34
36
  stroke_weight 1
35
- line(100, 100, clock_x.call(second, 6, 72), clock_y.call(second, 6, 72))
37
+ line(100, 100, clock_x.call(t.sec, 6, 72), clock_y.call(t.sec, 6, 72))
36
38
  # Draw the minute ticks
37
39
  stroke_weight 2
38
40
  stroke 255
@@ -3,7 +3,7 @@
3
3
  # Starts a network client that connects to a server on port 80,
4
4
  # sends an HTTP 1.0 GET request, and prints the results.
5
5
  # Note that this code is not necessary for simple HTTP GET request:
6
- # Simply calling loadStrings("http://www.processing.org") would do
6
+ # Simply calling load_strings("http://www.processing.org") would do
7
7
  # the same thing as (and more efficiently than) this example.
8
8
  # This example is for people who might want to do something more
9
9
  # complicated later.
@@ -25,7 +25,9 @@ end
25
25
  def draw
26
26
  if (client.available() > 0) # If there's incoming data from the client...
27
27
  data = client.read_string() # ...then grab it and print it
28
- println(data)
28
+ puts data
29
29
  end
30
30
  end
31
31
 
32
+ #@todo replace with a pure ruby alternative
33
+
@@ -9,7 +9,7 @@ load_library :vecmath
9
9
 
10
10
  def setup
11
11
  size(600, 600, P3D)
12
- smooth(16)
12
+ smooth(8)
13
13
  ArcBall.init(self, 300, 300)
14
14
  fill 180
15
15
  end
@@ -9,7 +9,7 @@ load_library :vecmath
9
9
 
10
10
  def setup
11
11
  size(600, 600, P3D)
12
- smooth(16)
12
+ smooth(8)
13
13
  ArcBall.init(self, 300, 300, 250)
14
14
  fill 180
15
15
  end
@@ -4,7 +4,7 @@ attr_reader :my_cube
4
4
 
5
5
  def setup
6
6
  size(600, 600, P3D)
7
- smooth(16)
7
+ smooth(8)
8
8
  ArcBall.init(self)
9
9
  @my_cube = create_shape(BOX, 400, 400, 400)
10
10
  my_cube.set_fill(color(100, 10, 100))
@@ -41,7 +41,7 @@ def setup
41
41
  color_mode(RGB, 255, 255, 255, 100)
42
42
  ellipse_mode(CENTER)
43
43
  origin = rand(5 .. 16)
44
- start_pos = Vec2D.new(width / start2, height / 2)
44
+ start_pos = Vec2D.new(width / 2, height / 2)
45
45
  @particle_systems = ParticleSystem.new(origin, start_pos)
46
46
  end
47
47
 
@@ -4,7 +4,7 @@
4
4
  # author Martin Prout
5
5
  ##########################
6
6
 
7
- load_library 'vecmath'
7
+ load_library :vecmath
8
8
 
9
9
  PTS = [-1, 0, 1]
10
10
  MIN_SIZE = 20
@@ -23,7 +23,7 @@ def draw
23
23
  background(20, 20, 200)
24
24
  no_stroke
25
25
  lights
26
- define_light
26
+ define_lights
27
27
  render
28
28
  end
29
29
 
@@ -32,7 +32,7 @@ def draw
32
32
  # Display frame rate
33
33
  fill(255, 0, 255)
34
34
  text_size(16)
35
- text('Frame rate: #{format('%.2f', frame_rate)}', 10, 20)
35
+ text("Frame rate: #{format('%0.2f', frame_rate)}", 10, 20)
36
36
 
37
37
  end
38
38
 
@@ -20,10 +20,10 @@ def draw
20
20
  # Draw only when mouse is pressed
21
21
  if mouse_pressed?
22
22
  @angle += 5
23
- val = cos(radians(angle)) * 12.0
23
+ val = cos(angle.radians) * 12.0
24
24
  (0 ... 360).step(75) do |a|
25
- xoff = cos(radians(a)) * val
26
- yoff = sin(radians(a)) * val
25
+ xoff = cos(a.radians) * val
26
+ yoff = sin(a.radians) * val
27
27
  fill(0)
28
28
  ellipse(mouse_x + xoff, mouse_y + yoff, val, val)
29
29
  end
@@ -26,7 +26,7 @@ def draw
26
26
  @direction = direction * -1
27
27
  end
28
28
  if mouse_pressed?
29
- @signal = abs(mouse_y % img.height)
29
+ @signal = (mouse_y % img.height).abs
30
30
  else
31
31
  @signal += (0.3*direction)
32
32
  end
@@ -6,7 +6,7 @@
6
6
  # Hold down 'y' key and drag mouse to rotate about y axis
7
7
  ########################################################
8
8
 
9
- load_libraries :cs_grammar, :vecmath
9
+ load_libraries :cs_grammar, :vecmath, :fastmath
10
10
  attr_reader :csplant
11
11
 
12
12
  def setup
@@ -47,8 +47,8 @@ class CSPlant
47
47
  )
48
48
  @production = axiom
49
49
  @len = len
50
- @theta = radians 25
51
- @phi = radians 25
50
+ @theta = 25.radians
51
+ @phi = 25.radians
52
52
  no_stroke
53
53
  end
54
54
 
@@ -39,11 +39,11 @@ def draw
39
39
  # Follow the leader
40
40
  (0 ... CELLS).each do |i|
41
41
  if (i == 0)
42
- px[i] = head_x + sin(radians(angle[i]))*radii_x[i]
43
- py[i] = head_y + cos(radians(angle[i]))*radii_y[i]
42
+ px[i] = head_x + sin(angle[i].radians)*radii_x[i]
43
+ py[i] = head_y + cos(angle[i].radians)*radii_y[i]
44
44
  else
45
- px[i] = px[i-1] + cos(radians(angle[i]))*radii_x[i]
46
- py[i] = py[i-1] + sin(radians(angle[i]))*radii_y[i]
45
+ px[i] = px[i-1] + cos(angle[i].radians)*radii_x[i]
46
+ py[i] = py[i-1] + sin(angle[i].radians)*radii_y[i]
47
47
 
48
48
  # Check collision of body
49
49
  if ((px[i] >= width-cell_radius[i] / 2) || (px[i] <= cell_radius[i] / 2))
@@ -49,7 +49,7 @@ def draw
49
49
  # required for texLight shader
50
50
  pointLight(255, 255, 255, 2 * (mouse_x - width / 2), 2 * (mouse_y - height / 2), 500)
51
51
  translate(width / 2, height / 2) # translate to center of the screen
52
- rotate_x(radians(60)) # fixed rotation of 60 degrees over the X axis
52
+ rotate_x(60.radians) # fixed rotation of 60 degrees over the X axis
53
53
  rotate_z(frame_count * 0.005) # dynamic frameCount-based rotation over the Z axis
54
54
 
55
55
  background(0) # black background
@@ -27,6 +27,6 @@ def draw
27
27
  shader(landscape)
28
28
  rect(0, 0, width, height)
29
29
 
30
- frame.set_title 'frame: #{frame_count} - fps: #{format('%.2f', frame_rate)}'
30
+ frame.set_title "frame: #{frame_count} - fps: #{format('%0.2f', frame_rate)}"
31
31
  end
32
32
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-processing
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Ashkenas
@@ -18,7 +18,7 @@ authors:
18
18
  autorequire:
19
19
  bindir: bin
20
20
  cert_chain: []
21
- date: 2014-07-28 00:00:00.000000000 Z
21
+ date: 2014-08-04 00:00:00.000000000 Z
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
24
24
  name: bundler
@@ -170,13 +170,13 @@ files:
170
170
  - samples/external_library/java_processing/box2d_processing/polygons.rb
171
171
  - samples/external_library/java_processing/custom/README.md
172
172
  - samples/external_library/java_processing/custom/Rakefile
173
+ - samples/external_library/java_processing/custom/ext/nn/Connection.java
174
+ - samples/external_library/java_processing/custom/ext/nn/HiddenNeuron.java
175
+ - samples/external_library/java_processing/custom/ext/nn/InputNeuron.java
176
+ - samples/external_library/java_processing/custom/ext/nn/Network.java
177
+ - samples/external_library/java_processing/custom/ext/nn/Neuron.java
178
+ - samples/external_library/java_processing/custom/ext/nn/OutputNeuron.java
173
179
  - samples/external_library/java_processing/custom/landscape.rb
174
- - samples/external_library/java_processing/custom/src/nn/Connection.java
175
- - samples/external_library/java_processing/custom/src/nn/HiddenNeuron.java
176
- - samples/external_library/java_processing/custom/src/nn/InputNeuron.java
177
- - samples/external_library/java_processing/custom/src/nn/Network.java
178
- - samples/external_library/java_processing/custom/src/nn/Neuron.java
179
- - samples/external_library/java_processing/custom/src/nn/OutputNeuron.java
180
180
  - samples/external_library/java_processing/custom/xor.rb
181
181
  - samples/external_library/java_processing/fisica/README
182
182
  - samples/external_library/java_processing/fisica/bubbles.rb
@@ -232,6 +232,7 @@ files:
232
232
  - samples/processing_app/basics/arrays/array_objects.rb
233
233
  - samples/processing_app/basics/camera/move_eye.rb
234
234
  - samples/processing_app/basics/camera/perspective.rb
235
+ - samples/processing_app/basics/color/blend_color.rb
235
236
  - samples/processing_app/basics/color/brightness.rb
236
237
  - samples/processing_app/basics/color/color_wheel.rb
237
238
  - samples/processing_app/basics/color/creating.rb
@@ -890,7 +891,7 @@ requirements:
890
891
  - java runtime >= 1.7+
891
892
  - processing = 2.2.1+
892
893
  rubyforge_project:
893
- rubygems_version: 2.2.2
894
+ rubygems_version: 2.4.1
894
895
  signing_key:
895
896
  specification_version: 4
896
897
  summary: Code as Art, Art as Code. Processing and Ruby are meant for each other.