ruby-processing 1.0.3 → 1.0.4
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.
- data/CHANGELOG +12 -0
- data/README +3 -0
- data/lib/core/core.jar +0 -0
- data/lib/core/jruby-complete.jar +0 -0
- data/lib/patches/JRubyApplet.diff +24 -0
- data/lib/patches/PATCHES.txt +3 -0
- data/lib/patches/PApplet.diff +27 -0
- data/lib/ruby-processing.rb +4 -1
- data/lib/ruby-processing/app.rb +121 -75
- data/lib/ruby-processing/exporters/applet_exporter.rb +1 -1
- data/lib/ruby-processing/exporters/base_exporter.rb +21 -16
- data/lib/ruby-processing/exporters/creator.rb +12 -6
- data/lib/ruby-processing/runner.rb +2 -2
- data/lib/ruby-processing/runners/base.rb +59 -0
- data/lib/ruby-processing/runners/live.rb +2 -2
- data/lib/ruby-processing/runners/run.rb +2 -1
- data/lib/ruby-processing/runners/watch.rb +47 -11
- data/lib/templates/applet/index.html.erb +6 -6
- data/lib/templates/create/bare_sketch.rb.erb +7 -0
- data/lib/templates/create/blank_sketch.rb.erb +2 -2
- data/library/control_panel/control_panel.rb +6 -2
- data/library/opengl/library/export.txt +0 -0
- data/library/opengl/library/opengl.jar +0 -0
- data/library/pdf/library/itext.jar +0 -0
- data/library/pdf/library/pdf.jar +0 -0
- data/library/pdf/notes.txt +3 -4
- data/samples/animator.rb +35 -39
- data/samples/bezier_playground.rb +2 -4
- data/samples/fern.rb +34 -42
- data/samples/flight_patterns.rb +48 -54
- data/samples/full_screen.rb +20 -25
- data/samples/getting_started.rb +19 -39
- data/samples/learning_processing/chapter_01/1_stroke_and_fill.rb +14 -30
- data/samples/learning_processing/chapter_01/2_nofill.rb +18 -23
- data/samples/learning_processing/chapter_01/3_rgb_color.rb +16 -28
- data/samples/learning_processing/chapter_01/4_alpha_transparency.rb +7 -1
- data/samples/learning_processing/chapter_01/5_zoog.rb +20 -33
- data/samples/learning_processing/chapter_02/1_zoog_again.rb +3 -1
- data/samples/learning_processing/chapter_03/6_interactive_zoog.rb +34 -42
- data/samples/learning_processing/chapter_16/03_adjust_video_brightness.rb +49 -0
- data/samples/learning_processing/chapter_17/01_simple_displaying_text.rb +14 -0
- data/samples/learning_processing/chapter_17/02_text_align.rb +21 -0
- data/samples/learning_processing/chapter_17/03_scrolling_headlines.rb +35 -0
- data/samples/learning_processing/chapter_17/04_text_mirror.rb +68 -0
- data/samples/learning_processing/chapter_17/05_rotating_text.rb +22 -0
- data/samples/learning_processing/chapter_17/06_text_breaking_up.rb +73 -0
- data/samples/learning_processing/chapter_17/07_boxes_along_a_curve.rb +49 -0
- data/samples/learning_processing/chapter_17/08_characters_along_a_curve.rb +51 -0
- data/samples/learning_processing/chapter_17/data/ArialMT-16.vlw +0 -0
- data/samples/learning_processing/chapter_17/data/Courier-Bold-20.vlw +0 -0
- data/samples/learning_processing/chapter_18/01_user_input.rb +39 -0
- data/samples/learning_processing/chapter_18/02_graphing_comma_separated_numbers_from_a_text_file.rb +28 -0
- data/samples/learning_processing/chapter_18/03_creating_object_from_a_text_file.rb +64 -0
- data/samples/learning_processing/chapter_18/data/data-1.txt +1 -0
- data/samples/learning_processing/chapter_18/data/data-2.txt +10 -0
- data/samples/orbit.rb +45 -0
- data/samples/processing_app/basics/image/pointillism.rb +1 -1
- data/samples/processing_app/topics/effects/lens.rb +1 -0
- metadata +30 -13
- data/library/opengl/bin/processing/opengl/PGraphicsOpenGL$ImageCache.class +0 -0
- data/library/opengl/bin/processing/opengl/PGraphicsOpenGL$TessCallback.class +0 -0
- data/library/opengl/bin/processing/opengl/PGraphicsOpenGL.class +0 -0
- data/library/pdf/bin/processing/pdf/PGraphicsPDF.class +0 -0
@@ -1,10 +1,7 @@
|
|
1
|
-
require 'ruby-processing'
|
2
|
-
|
3
1
|
# A Bezier playground. Click to shape the curve. Drag to move it.
|
4
2
|
# Arrows toggle between curves, delete removes them.
|
5
3
|
# You can print out the parametric equations for t = 0..1
|
6
4
|
|
7
|
-
|
8
5
|
module Math
|
9
6
|
|
10
7
|
def self.overlaps(x, y, point_x, point_y)
|
@@ -75,6 +72,7 @@ class Bezier < Processing::App
|
|
75
72
|
load_library :control_panel
|
76
73
|
|
77
74
|
def setup
|
75
|
+
size 700, 700
|
78
76
|
smooth
|
79
77
|
@curves = []
|
80
78
|
|
@@ -240,4 +238,4 @@ class Bezier < Processing::App
|
|
240
238
|
|
241
239
|
end
|
242
240
|
|
243
|
-
Bezier.new
|
241
|
+
Bezier.new
|
data/samples/fern.rb
CHANGED
@@ -1,49 +1,41 @@
|
|
1
1
|
# The Fern Fractal
|
2
2
|
# by Luis Correia
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
|
4
|
+
def setup
|
5
|
+
size 500, 500
|
6
|
+
no_loop
|
7
|
+
puts "Be patient. This takes about 10 seconds to render."
|
8
|
+
end
|
7
9
|
|
8
|
-
|
10
|
+
def draw
|
11
|
+
background 0
|
12
|
+
load_pixels
|
13
|
+
x0, y0 = 0.0, 0.0
|
14
|
+
x, y, r = 0.0, 0.0, 0.0
|
15
|
+
i, j = 0, 0
|
16
|
+
max_iterations = 200000
|
9
17
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
r = rand * 100
|
25
|
-
if r <= 1
|
26
|
-
x = 0.0
|
27
|
-
y = 0.16 * y0
|
28
|
-
elsif r <= 7
|
29
|
-
x = 0.2 * x0 - 0.26 * y0
|
30
|
-
y = 0.23 * x0 + 0.22 * y0
|
31
|
-
elsif r <= 14
|
32
|
-
x = -0.15 * x0 + 0.28 * y0
|
33
|
-
y = 0.26 * x0 + 0.24 * y0
|
34
|
-
else
|
35
|
-
x = 0.85 * x0 + 0.04 * y0
|
36
|
-
y = -0.004 * x0 + 0.85 * y0 + 1.6
|
37
|
-
end
|
38
|
-
|
39
|
-
i = height - (y * 45).to_i
|
40
|
-
j = width / 2 + (x * 45).to_i
|
41
|
-
pixels[i * height + j] += 2560 if (i >=0 && i < height && j >= 0 && j < width)
|
42
|
-
x0, y0 = x, y
|
18
|
+
max_iterations.times do
|
19
|
+
r = rand * 100
|
20
|
+
if r <= 1
|
21
|
+
x = 0.0
|
22
|
+
y = 0.16 * y0
|
23
|
+
elsif r <= 7
|
24
|
+
x = 0.2 * x0 - 0.26 * y0
|
25
|
+
y = 0.23 * x0 + 0.22 * y0
|
26
|
+
elsif r <= 14
|
27
|
+
x = -0.15 * x0 + 0.28 * y0
|
28
|
+
y = 0.26 * x0 + 0.24 * y0
|
29
|
+
else
|
30
|
+
x = 0.85 * x0 + 0.04 * y0
|
31
|
+
y = -0.004 * x0 + 0.85 * y0 + 1.6
|
43
32
|
end
|
44
33
|
|
45
|
-
|
34
|
+
i = height - (y * 45).to_i
|
35
|
+
j = width / 2 + (x * 45).to_i
|
36
|
+
pixels[i * height + j] += 2560 if (i >=0 && i < height && j >= 0 && j < width)
|
37
|
+
x0, y0 = x, y
|
46
38
|
end
|
47
|
-
|
48
|
-
|
49
|
-
|
39
|
+
|
40
|
+
update_pixels
|
41
|
+
end
|
data/samples/flight_patterns.rb
CHANGED
@@ -1,64 +1,58 @@
|
|
1
1
|
# Description:
|
2
2
|
# Flight Patterns is that ol' Euruko 2008 demo.
|
3
3
|
|
4
|
-
|
4
|
+
full_screen
|
5
|
+
load_libraries 'boids', 'opengl'
|
6
|
+
import "processing.opengl" if library_loaded? "opengl"
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
8
|
+
def setup
|
9
|
+
library_loaded?(:opengl) ? setup_opengl : render_mode(P3D)
|
10
|
+
sphere_detail 8
|
11
|
+
color_mode RGB, 1.0
|
12
|
+
no_stroke
|
13
|
+
frame_rate 30
|
14
|
+
shininess 1.0
|
15
|
+
specular 0.3, 0.1, 0.1
|
16
|
+
emissive 0.03, 0.03, 0.1
|
9
17
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
shininess 1.0
|
17
|
-
specular 0.3, 0.1, 0.1
|
18
|
-
emissive 0.03, 0.03, 0.1
|
19
|
-
|
20
|
-
@click = false
|
21
|
-
@flocks = []
|
22
|
-
3.times do |i|
|
23
|
-
flock = Boids.flock 20, 0, 0, width, height
|
24
|
-
flock.goal width/2, height/2, 0
|
25
|
-
@flocks << flock
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def setup_opengl
|
30
|
-
render_mode OPENGL
|
31
|
-
hint ENABLE_OPENGL_4X_SMOOTH
|
18
|
+
@click = false
|
19
|
+
@flocks = []
|
20
|
+
3.times do |i|
|
21
|
+
flock = Boids.flock 20, 0, 0, width, height
|
22
|
+
flock.goal width/2, height/2, 0
|
23
|
+
@flocks << flock
|
32
24
|
end
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
25
|
+
end
|
26
|
+
|
27
|
+
def setup_opengl
|
28
|
+
render_mode(OPENGL)
|
29
|
+
hint ENABLE_OPENGL_4X_SMOOTH
|
30
|
+
end
|
31
|
+
|
32
|
+
def mouse_pressed
|
33
|
+
@click = !@click
|
34
|
+
end
|
35
|
+
|
36
|
+
def draw
|
37
|
+
background 0.05
|
38
|
+
ambient_light 0.01, 0.01, 0.01
|
39
|
+
light_specular 0.4, 0.2, 0.2
|
40
|
+
point_light 1.0, 1.0, 1.0, mouse_x, mouse_y, 190
|
41
|
+
@flocks.each_with_index do |flock, i|
|
42
|
+
flock.goal mouse_x, mouse_y, 0, @flee
|
43
|
+
flock.update(:goal => 185, :limit => 13.5)
|
44
|
+
for boid in flock do
|
45
|
+
r = 20 + (boid.z * 0.15)
|
46
|
+
alpha = 0.5 + (boid.z * 0.01)
|
47
|
+
case i
|
48
|
+
when 0 then fill 0.55, 0.35, 0.35
|
49
|
+
when 1 then fill 0.35, 0.55, 0.35
|
50
|
+
when 2 then fill 0.35, 0.35, 0.55
|
58
51
|
end
|
52
|
+
push_matrix
|
53
|
+
translate boid.x-r/2, boid.y-r/2, boid.z-r/2
|
54
|
+
@click ? sphere(r/2) : oval(0, 0, r, r)
|
55
|
+
pop_matrix
|
59
56
|
end
|
60
57
|
end
|
61
|
-
|
62
58
|
end
|
63
|
-
|
64
|
-
FlightPatterns.new(:title => "Flight Patterns", :width => 1100, :height => 800, :full_screen => true)
|
data/samples/full_screen.rb
CHANGED
@@ -4,32 +4,27 @@
|
|
4
4
|
# have the OpenGL library installed, you'll get *much*
|
5
5
|
# smoother and faster drawing.
|
6
6
|
|
7
|
-
|
7
|
+
full_screen
|
8
|
+
load_library :opengl
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
rotate_x(((mouse_y.to_f + new_y) / height) * Math::PI)
|
28
|
-
box 90
|
29
|
-
pop_matrix
|
30
|
-
end
|
10
|
+
def setup
|
11
|
+
library_loaded?(:opengl) ? render_mode(OPENGL) : render_mode(P3D)
|
12
|
+
no_stroke
|
13
|
+
end
|
14
|
+
|
15
|
+
def draw
|
16
|
+
lights
|
17
|
+
background 0
|
18
|
+
fill 120, 160, 220
|
19
|
+
(width/100).times do |x|
|
20
|
+
(height/100).times do |y|
|
21
|
+
new_x, new_y = x * 100, y * 100
|
22
|
+
push_matrix
|
23
|
+
translate new_x + 50, new_y + 50
|
24
|
+
rotate_y(((mouse_x.to_f + new_x) / width) * Math::PI)
|
25
|
+
rotate_x(((mouse_y.to_f + new_y) / height) * Math::PI)
|
26
|
+
box 90
|
27
|
+
pop_matrix
|
31
28
|
end
|
32
29
|
end
|
33
30
|
end
|
34
|
-
|
35
|
-
FullScreen.new(:full_screen => true, :title => "Full Screen", :width => 600, :height => 600)
|
data/samples/getting_started.rb
CHANGED
@@ -1,43 +1,23 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
require 'ruby-processing'
|
10
|
-
|
11
|
-
# Here we begin to define the Sketch by making it a
|
12
|
-
# Processing App.
|
13
|
-
class SampleApplication < Processing::App
|
1
|
+
# Let's define a setup method, for code that gets
|
2
|
+
# run one time when the app is started.
|
3
|
+
def setup
|
4
|
+
background 0
|
5
|
+
no_stroke
|
6
|
+
smooth
|
7
|
+
@rotation = 0
|
8
|
+
end
|
14
9
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
smooth
|
21
|
-
@rotation = 0
|
22
|
-
end
|
10
|
+
# And the draw method which will be called repeatedly.
|
11
|
+
# Delete this if you don't need animation.
|
12
|
+
def draw
|
13
|
+
fill 0, 20
|
14
|
+
rect 0, 0, width, height
|
23
15
|
|
24
|
-
|
25
|
-
|
26
|
-
def draw
|
27
|
-
fill 0, 20
|
28
|
-
rect 0, 0, width, height
|
29
|
-
|
30
|
-
translate width/2, height/2
|
31
|
-
rotate @rotation
|
16
|
+
translate width/2, height/2
|
17
|
+
rotate @rotation
|
32
18
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
@rotation += 0.1
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
19
|
+
fill 255
|
20
|
+
ellipse 0, -60, 20, 20
|
40
21
|
|
41
|
-
|
42
|
-
|
43
|
-
SampleApplication.new(:width => 200, :height => 200, :title => "SampleApplication")
|
22
|
+
@rotation += 0.1
|
23
|
+
end
|
@@ -1,34 +1,18 @@
|
|
1
|
-
#
|
2
|
-
# that
|
3
|
-
# than in the Learning Processing example. Ruby-Processing
|
4
|
-
# doesn't perform any special munging or pre-processing,
|
5
|
-
# so what you see here is *just Ruby* taking advantage
|
6
|
-
# of the Processing library.
|
1
|
+
# This is the simplest form of a Ruby-Processing sketch. A simple sequence
|
2
|
+
# of instructions that are run a single time to paint a picture.
|
7
3
|
|
8
|
-
#
|
9
|
-
|
4
|
+
# Stretch the canvas to 200 pixels wide by 200 pixels tall.
|
5
|
+
size 200, 200
|
10
6
|
|
11
|
-
#
|
12
|
-
|
13
|
-
class StrokeAndFill < Processing::App
|
7
|
+
# Paint the background white.
|
8
|
+
background 255
|
14
9
|
|
15
|
-
|
16
|
-
|
17
|
-
def setup
|
18
|
-
background 255
|
19
|
-
stroke 0
|
20
|
-
fill 150
|
21
|
-
rect 50, 50, 75, 100
|
22
|
-
end
|
23
|
-
|
24
|
-
# And the draw method has nothing inside of it.
|
25
|
-
# If it did, the code inside would be run repeatedly.
|
26
|
-
def draw
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
10
|
+
# Set the color of strokes to black.
|
11
|
+
stroke 0
|
31
12
|
|
32
|
-
#
|
33
|
-
|
34
|
-
|
13
|
+
# Set the color of fills to middle gray.
|
14
|
+
fill 150
|
15
|
+
|
16
|
+
# Draw a rectangle 50 pixels over and 50 pixels down from the top left corner,
|
17
|
+
# with a width of 75 pixels and a height of 100.
|
18
|
+
rect 50, 50, 75, 100
|
@@ -1,25 +1,20 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
ellipse(60, 60, 100, 100);
|
16
|
-
end
|
17
|
-
|
18
|
-
def draw
|
19
|
-
|
20
|
-
end
|
21
|
-
|
1
|
+
# Here we introduce a slightly more sophisticated version of a Ruby-Processing
|
2
|
+
# sketch. The code inside of the setup is run a single time, at the beginning.
|
3
|
+
def setup
|
4
|
+
size 200, 200
|
5
|
+
smooth
|
6
|
+
background 255
|
7
|
+
# In Ruby, methods and variables are under_scored instead of camelCased
|
8
|
+
no_fill
|
9
|
+
stroke 0
|
10
|
+
# You might notice that there are no parenthesis or semicolons.
|
11
|
+
# That's because they're optional.
|
12
|
+
ellipse 60, 60, 100, 100
|
13
|
+
# This line works too:
|
14
|
+
ellipse(60, 60, 100, 100);
|
22
15
|
end
|
23
16
|
|
24
|
-
#
|
25
|
-
|
17
|
+
# And the code inside of draw, if there were any, would be drawn over and over.
|
18
|
+
def draw
|
19
|
+
|
20
|
+
end
|
@@ -1,31 +1,19 @@
|
|
1
|
-
require 'ruby-processing'
|
2
|
-
|
3
1
|
# RGB color is specified by intensity of red, then green, then blue.
|
4
|
-
class RgbColor < Processing::App
|
5
2
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
# Pink
|
21
|
-
fill 255, 200, 200
|
22
|
-
ellipse 60, 20, 16, 16
|
23
|
-
end
|
24
|
-
|
25
|
-
def draw
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
3
|
+
size 200, 200
|
4
|
+
smooth
|
5
|
+
|
6
|
+
background 255
|
7
|
+
no_stroke
|
8
|
+
|
9
|
+
# Bright red
|
10
|
+
fill 255, 0, 0
|
11
|
+
ellipse 20, 20, 16, 16
|
12
|
+
|
13
|
+
# Dark red
|
14
|
+
fill 127, 0, 0
|
15
|
+
ellipse 40, 20, 16, 16
|
30
16
|
|
31
|
-
|
17
|
+
# Pink
|
18
|
+
fill 255, 200, 200
|
19
|
+
ellipse 60, 20, 16, 16
|