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.
- checksums.yaml +4 -4
- data/lib/rpextras.jar +0 -0
- data/lib/ruby-processing/app.rb +26 -26
- data/lib/ruby-processing/exporters/base_exporter.rb +7 -5
- data/lib/ruby-processing/helper_methods.rb +78 -3
- data/lib/ruby-processing/version.rb +1 -1
- data/lib/templates/application/run.erb +4 -4
- data/samples/contributed/elegant_ball.rb +47 -37
- data/samples/contributed/tree.rb +1 -5
- data/samples/external_library/java_processing/custom/README.md +6 -5
- data/samples/external_library/java_processing/custom/Rakefile +17 -23
- data/samples/external_library/java_processing/custom/{src → ext}/nn/Connection.java +0 -0
- data/samples/external_library/java_processing/custom/{src → ext}/nn/HiddenNeuron.java +0 -0
- data/samples/external_library/java_processing/custom/{src → ext}/nn/InputNeuron.java +0 -0
- data/samples/external_library/java_processing/custom/{src → ext}/nn/Network.java +0 -0
- data/samples/external_library/java_processing/custom/{src → ext}/nn/Neuron.java +0 -0
- data/samples/external_library/java_processing/custom/{src → ext}/nn/OutputNeuron.java +0 -0
- data/samples/external_library/java_processing/custom/xor.rb +1 -1
- data/samples/external_library/ruby_gem/draw_test.rb +1 -1
- data/samples/processing_app/basics/arrays/array.rb +11 -11
- data/samples/processing_app/basics/color/blend_color.rb +17 -0
- data/samples/processing_app/basics/color/reading/reading.rb +20 -29
- data/samples/processing_app/basics/form/brick_tower.rb +11 -10
- data/samples/processing_app/basics/form/pie_chart.rb +4 -4
- data/samples/processing_app/basics/form/shape_transform.rb +17 -22
- data/samples/processing_app/basics/form/toroid.rb +16 -21
- data/samples/processing_app/basics/input/clock.rb +11 -10
- data/samples/processing_app/basics/math/sine_cosine.rb +6 -6
- data/samples/processing_app/basics/transform/bird.rb +9 -9
- data/samples/processing_app/basics/transform/birds.rb +1 -1
- data/samples/processing_app/basics/transform/library/bird/bird.rb +12 -12
- data/samples/processing_app/basics/transform/rotate.rb +10 -5
- data/samples/processing_app/basics/transform/triangle_flower.rb +3 -3
- data/samples/processing_app/library/fastmath/clock.rb +9 -7
- data/samples/processing_app/library/net/HTTPClient.rb +4 -2
- data/samples/processing_app/library/vecmath/arcball/arcball_box.rb +1 -1
- data/samples/processing_app/library/vecmath/arcball/arcball_radius.rb +1 -1
- data/samples/processing_app/library/vecmath/arcball/arcball_shape.rb +1 -1
- data/samples/processing_app/library/vecmath/vec2d/multiple_particle_systems.rb +1 -1
- data/samples/processing_app/library/vecmath/vec3d/retained_menger.rb +2 -2
- data/samples/processing_app/topics/create_shapes/particle_system_pshape.rb +1 -1
- data/samples/processing_app/topics/drawing/pulses.rb +3 -3
- data/samples/processing_app/topics/image_processing/linear_image.rb +1 -1
- data/samples/processing_app/topics/lsystems/csplant.rb +3 -3
- data/samples/processing_app/topics/motion/puff.rb +4 -4
- data/samples/processing_app/topics/shaders/glsl_heightmap_noise.rb +1 -1
- data/samples/processing_app/topics/shaders/landscape.rb +1 -1
- metadata +10 -9
@@ -22,14 +22,14 @@ end
|
|
22
22
|
def draw
|
23
23
|
background(0)
|
24
24
|
|
25
|
-
ang1 = radians
|
26
|
-
ang2 = radians
|
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(
|
25
|
-
py = cos(
|
26
|
-
pz = sin(
|
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(
|
31
|
-
rotate_y sin(
|
32
|
-
rotate_z sin(
|
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(
|
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(
|
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
|
50
|
+
@flap_speed *= -1 if ang.abs > PI
|
51
51
|
|
52
52
|
@ang2 += 0.01
|
53
53
|
@ang3 += 2.0
|
@@ -11,7 +11,7 @@ class Bird
|
|
11
11
|
attr_accessor :flap_speed
|
12
12
|
attr_accessor :rot_speed
|
13
13
|
|
14
|
-
def initialize
|
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
|
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
|
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
|
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(
|
51
|
-
py = cos(
|
52
|
-
pz = sin(
|
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(
|
59
|
-
rotate_y sin(
|
60
|
-
rotate_z sin(
|
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(
|
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(
|
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
|
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
|
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
|
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
|
-
|
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
|
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 (
|
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
|
-
|
29
|
-
|
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(
|
32
|
-
clock_y.call(
|
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(
|
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
|
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
|
-
|
28
|
+
puts data
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
+
#@todo replace with a pure ruby alternative
|
33
|
+
|
@@ -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 /
|
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
|
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
|
-
|
26
|
+
define_lights
|
27
27
|
render
|
28
28
|
end
|
29
29
|
|
@@ -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
|
23
|
+
val = cos(angle.radians) * 12.0
|
24
24
|
(0 ... 360).step(75) do |a|
|
25
|
-
xoff = cos(radians
|
26
|
-
yoff = sin(radians
|
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
|
@@ -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
|
51
|
-
@phi = radians
|
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(
|
43
|
-
py[i] = head_y + cos(
|
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(
|
46
|
-
py[i] = py[i-1] + sin(
|
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
|
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
|
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.
|
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-
|
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.
|
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.
|