ruby-processing 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -0,0 +1,49 @@
|
|
1
|
+
def setup
|
2
|
+
size 320, 320
|
3
|
+
rect_mode CENTER
|
4
|
+
smooth
|
5
|
+
@r = 100 # The radius of a circle
|
6
|
+
@w, @h = 40, 40 # The width and height of the boxes
|
7
|
+
end
|
8
|
+
|
9
|
+
def draw
|
10
|
+
background 255
|
11
|
+
|
12
|
+
# Start in the center and draw the circle
|
13
|
+
translate width/2, height/2
|
14
|
+
no_fill
|
15
|
+
stroke 0
|
16
|
+
|
17
|
+
# Our curve is a circle with radius r in the center of the window.
|
18
|
+
ellipse 0, 0, @r*2, @r*2
|
19
|
+
|
20
|
+
# 10 boxes along the curve
|
21
|
+
total_boxes = 10
|
22
|
+
|
23
|
+
# @we must keep track of our position along the curve
|
24
|
+
arc_length = 0
|
25
|
+
|
26
|
+
# For every box
|
27
|
+
total_boxes.times do |i|
|
28
|
+
# Each box is centered so we move half the width
|
29
|
+
arc_length += @w / 2.0
|
30
|
+
|
31
|
+
# Angle in radians is the arclength divided by the radius
|
32
|
+
theta = arc_length / @r
|
33
|
+
|
34
|
+
push_matrix
|
35
|
+
# Polar to cartesian coordinate conversion
|
36
|
+
translate @r * cos(theta), @r * sin(theta)
|
37
|
+
|
38
|
+
# @rotate the box
|
39
|
+
rotate theta
|
40
|
+
|
41
|
+
# Display the box
|
42
|
+
fill 0, 100
|
43
|
+
rect 0, 0, @w, @h
|
44
|
+
pop_matrix
|
45
|
+
|
46
|
+
# Move halfway again
|
47
|
+
arc_length += @w / 2
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
def setup
|
2
|
+
size 320, 320
|
3
|
+
@message = "text along a curve" # The message to be displayed
|
4
|
+
@r = 100 # The radius of a circle
|
5
|
+
text_font create_font("Georgia", 40, true)
|
6
|
+
text_align CENTER # The text must be centered!
|
7
|
+
smooth
|
8
|
+
end
|
9
|
+
|
10
|
+
def draw
|
11
|
+
background 255
|
12
|
+
|
13
|
+
# Start in the center and draw the circle
|
14
|
+
translate width/2, height/2
|
15
|
+
no_fill
|
16
|
+
ellipse 0, 0, @r*2, @r*2
|
17
|
+
|
18
|
+
# We must keep track of our position along the curve
|
19
|
+
arc_length = 0
|
20
|
+
|
21
|
+
# For every box
|
22
|
+
@message.each_byte do |char|
|
23
|
+
# Instead of a constant width, we check the width of each character.
|
24
|
+
w = text_width(char.chr)
|
25
|
+
|
26
|
+
# Each box is centered so we move half the width
|
27
|
+
arc_length += w / 2
|
28
|
+
|
29
|
+
# Angle in radians is the arc_length divided by the radius
|
30
|
+
# Starting on the left side of the circle by adding PI
|
31
|
+
theta = PI + arc_length / @r
|
32
|
+
|
33
|
+
push_matrix
|
34
|
+
|
35
|
+
# Polar to Cartesian conversion allows us to find the point along the curve.
|
36
|
+
# See Chapter 13 for a review of this concept.
|
37
|
+
translate @r * cos(theta), @r * sin(theta)
|
38
|
+
|
39
|
+
# Rotate the box (rotation is offset by 90 degrees)
|
40
|
+
rotate theta + PI / 2
|
41
|
+
|
42
|
+
# Display the character
|
43
|
+
fill 0
|
44
|
+
text char, 0, 0
|
45
|
+
|
46
|
+
pop_matrix
|
47
|
+
|
48
|
+
# Move halfway again
|
49
|
+
arc_length += w / 2
|
50
|
+
end
|
51
|
+
end
|
Binary file
|
Binary file
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Example 18-1: User input
|
2
|
+
require 'ruby-processing'
|
3
|
+
|
4
|
+
class UserInput < Processing::App
|
5
|
+
|
6
|
+
def setup
|
7
|
+
size 300, 200
|
8
|
+
@typing = ""
|
9
|
+
@saved = ""
|
10
|
+
textFont createFont "Arial", 16, true # set the font for text
|
11
|
+
end
|
12
|
+
|
13
|
+
def draw
|
14
|
+
background 255
|
15
|
+
indent = 25
|
16
|
+
fill 0 # Set the fill for text
|
17
|
+
|
18
|
+
# Display everything
|
19
|
+
text "Click in this applet and type. \nHit return to save what you typed. ", indent, 40
|
20
|
+
text @typing, indent, 90
|
21
|
+
text @saved, indent, 130
|
22
|
+
end
|
23
|
+
|
24
|
+
def keyPressed
|
25
|
+
# If the return key is pressed, save the String and clear it
|
26
|
+
if key == "\n"
|
27
|
+
@saved = @typing
|
28
|
+
@typing = "" # A String can be cleared by setting it equal to ""
|
29
|
+
else
|
30
|
+
# Otherwise, concatenate the String
|
31
|
+
# Each character typed by the user is added to the
|
32
|
+
# end of the String variable.
|
33
|
+
@typing = @typing + key
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
UserInput.new :title => "01 User Input"
|
data/samples/learning_processing/chapter_18/02_graphing_comma_separated_numbers_from_a_text_file.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# Example 18-2: Graphing comma separated numbers from a text file
|
2
|
+
require 'ruby-processing'
|
3
|
+
|
4
|
+
class GraphingCommaSeparatedNumbersFromATextFile < Processing::App
|
5
|
+
|
6
|
+
def setup
|
7
|
+
size 200, 200
|
8
|
+
# The text from the file is loaded into an array.
|
9
|
+
stuff = loadStrings("data-1.txt")
|
10
|
+
|
11
|
+
# This array has one element because the file only has one line.
|
12
|
+
# Convert String into an array of integers using ',' as a delimiter
|
13
|
+
@data = stuff[0].split(",").collect{ |n| n.to_i } # XXX: int(split(stuff[0], ","))
|
14
|
+
end
|
15
|
+
|
16
|
+
def draw
|
17
|
+
background 255
|
18
|
+
stroke 0
|
19
|
+
@data.each_with_index do |data, i|
|
20
|
+
# The array of ints is used to set the color and height of each rectangle.
|
21
|
+
fill data
|
22
|
+
rect i * 20, 0, 20, data
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
GraphingCommaSeparatedNumbersFromATextFile.new :title => "02 Graphing Comma Separated Numbers From A Text File"
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# Example 18-3: Creating objects from a text file
|
2
|
+
require 'ruby-processing'
|
3
|
+
|
4
|
+
class CreatingObjectFromATextFile < Processing::App
|
5
|
+
|
6
|
+
def setup
|
7
|
+
size 200, 200
|
8
|
+
smooth
|
9
|
+
|
10
|
+
# Load text file as an array of Strings
|
11
|
+
data = loadStrings("data-2.txt")
|
12
|
+
|
13
|
+
# The size of the array of Bubble objects is determined by the
|
14
|
+
# total number of lines in the text file.
|
15
|
+
@bubbles = []
|
16
|
+
data.each do |datum|
|
17
|
+
# Each line is split into an array of floating point numbers.
|
18
|
+
values = datum.split(",").collect{ |n| n.to_f } # XXX: float[] values = float(split(datum, "," ))
|
19
|
+
# The values in the array are passed into the Bubble class constructor.
|
20
|
+
@bubbles << Bubble.new(*values)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def draw
|
25
|
+
background 255
|
26
|
+
# Display and move all bubbles
|
27
|
+
@bubbles.each do |bubble|
|
28
|
+
bubble.display
|
29
|
+
bubble.drift
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
# A Class to describe a "Bubble"
|
36
|
+
class Bubble
|
37
|
+
# The constructor initializes color and size
|
38
|
+
# Location is filled randomly
|
39
|
+
def initialize(r, g, diameter)
|
40
|
+
@x = $app.random($app.width)
|
41
|
+
@y = $app.height
|
42
|
+
@r = r
|
43
|
+
@g = g
|
44
|
+
@diameter = diameter
|
45
|
+
end
|
46
|
+
|
47
|
+
# Display the Bubble
|
48
|
+
def display
|
49
|
+
$app.stroke 0
|
50
|
+
$app.fill @r, @g, 255, 150
|
51
|
+
$app.ellipse @x, @y, @diameter, @diameter
|
52
|
+
end
|
53
|
+
|
54
|
+
# Move the bubble
|
55
|
+
def drift
|
56
|
+
@y += $app.random(-3, -0.1)
|
57
|
+
@x += $app.random(-1, 1)
|
58
|
+
if @y < -@diameter * 2
|
59
|
+
@y = $app.height + @diameter * 2
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
CreatingObjectFromATextFile.new :title => " Creating Object From A Text File"
|
@@ -0,0 +1 @@
|
|
1
|
+
102,75,192,178,78,23,144,181,125,55
|
data/samples/orbit.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# Ported from http://nodebox.net/code/index.php/Graphics_State
|
2
|
+
|
3
|
+
# This sketch demonstrates how to use the frame rate as orbital state,
|
4
|
+
# as well as how to use system fonts in Ruby-Processing.
|
5
|
+
|
6
|
+
require 'ruby-processing'
|
7
|
+
|
8
|
+
class Orbit < Processing::App
|
9
|
+
def setup
|
10
|
+
frame_rate 30
|
11
|
+
smooth
|
12
|
+
fill 0
|
13
|
+
@font = create_font('Helvetica', 40)
|
14
|
+
end
|
15
|
+
|
16
|
+
def draw
|
17
|
+
background 255
|
18
|
+
translate 225, 225
|
19
|
+
|
20
|
+
text_font @font
|
21
|
+
ellipse 0, 0, 10, 10
|
22
|
+
text 'sun', 10, 0
|
23
|
+
|
24
|
+
3.times do |i|
|
25
|
+
push_matrix
|
26
|
+
|
27
|
+
rotate frame_count / -180.0 * PI + i * PI / -1.5
|
28
|
+
line 0, 0, 120, 0
|
29
|
+
|
30
|
+
translate 120, 0
|
31
|
+
ellipse 0, 0, 10, 10
|
32
|
+
text_font @font, 22
|
33
|
+
text 'planet', 10, 0
|
34
|
+
|
35
|
+
rotate frame_count / -30.0 * PI
|
36
|
+
line 0, 0, 30, 0
|
37
|
+
text_font @font, 15
|
38
|
+
text 'moon', 32, 0
|
39
|
+
|
40
|
+
pop_matrix
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
Orbit.new :width => 450, :height => 450, :title => 'Orbit'
|
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: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Ashkenas
|
@@ -12,15 +12,16 @@ authors:
|
|
12
12
|
- Peter Krenn
|
13
13
|
- Florian Jenett
|
14
14
|
- Andreas Haller
|
15
|
+
- Juris Galang
|
15
16
|
autorequire:
|
16
17
|
bindir: bin
|
17
18
|
cert_chain: []
|
18
19
|
|
19
|
-
date: 2009-03-
|
20
|
+
date: 2009-03-26 00:00:00 -04:00
|
20
21
|
default_executable: rp5
|
21
22
|
dependencies: []
|
22
23
|
|
23
|
-
description: "Ruby-Processing is a Ruby wrapper for the Processing code art framework. It's this thin little shim that squeezes between Processing and JRuby, passing along some neat goodies like: * Applet and Application exporting of your sketches. Hand them out to your party guests, ready-to-run. * Live Coding via JRuby's IRB. Loads in your sketch so you can futz with variables and remake methods on the fly. * A \"Control Panel\" library, so that you can easily create sliders, buttons, checkboxes and drop-down menus, and hook them into your sketch's instance variables. * \"Watch\" mode, where Ruby-Processing keeps an eye on your sketch and reloads it from scratch every time you make a change. A pretty nice REPL-ish way to work on your Processing sketches."
|
24
|
+
description: "Ruby-Processing is a Ruby wrapper for the Processing code art framework. It's this thin little shim that squeezes between Processing and JRuby, passing along some neat goodies like: * Applet and Application exporting of your sketches. Hand them out to your party guests, ready-to-run. * Live Coding via JRuby's IRB. Loads in your sketch so you can futz with variables and remake methods on the fly. * Bare sketches. Write your Ruby-Processing sketches without having to define a class. Without defining methods, even. * A \"Control Panel\" library, so that you can easily create sliders, buttons, checkboxes and drop-down menus, and hook them into your sketch's instance variables. * \"Watch\" mode, where Ruby-Processing keeps an eye on your sketch and reloads it from scratch every time you make a change. A pretty nice REPL-ish way to work on your Processing sketches."
|
24
25
|
email: jeremy@ashkenas.com
|
25
26
|
executables:
|
26
27
|
- rp5
|
@@ -35,6 +36,10 @@ files:
|
|
35
36
|
- lib/core
|
36
37
|
- lib/core/core.jar
|
37
38
|
- lib/core/jruby-complete.jar
|
39
|
+
- lib/patches
|
40
|
+
- lib/patches/JRubyApplet.diff
|
41
|
+
- lib/patches/PApplet.diff
|
42
|
+
- lib/patches/PATCHES.txt
|
38
43
|
- lib/ruby-processing
|
39
44
|
- lib/ruby-processing/app.rb
|
40
45
|
- lib/ruby-processing/exporters
|
@@ -77,6 +82,7 @@ files:
|
|
77
82
|
- lib/templates/application/run.erb
|
78
83
|
- lib/templates/application/run.exe
|
79
84
|
- lib/templates/create
|
85
|
+
- lib/templates/create/bare_sketch.rb.erb
|
80
86
|
- lib/templates/create/blank_sketch.rb.erb
|
81
87
|
- library/boids
|
82
88
|
- library/boids/boids.rb
|
@@ -114,12 +120,6 @@ files:
|
|
114
120
|
- library/net/library
|
115
121
|
- library/net/library/net.jar
|
116
122
|
- library/opengl
|
117
|
-
- library/opengl/bin
|
118
|
-
- library/opengl/bin/processing
|
119
|
-
- library/opengl/bin/processing/opengl
|
120
|
-
- library/opengl/bin/processing/opengl/PGraphicsOpenGL$ImageCache.class
|
121
|
-
- library/opengl/bin/processing/opengl/PGraphicsOpenGL$TessCallback.class
|
122
|
-
- library/opengl/bin/processing/opengl/PGraphicsOpenGL.class
|
123
123
|
- library/opengl/library
|
124
124
|
- library/opengl/library/export.txt
|
125
125
|
- library/opengl/library/gluegen-rt-natives-linux-amd64.jar
|
@@ -152,10 +152,6 @@ files:
|
|
152
152
|
- library/opengl/library/libjogl_cg.so
|
153
153
|
- library/opengl/library/opengl.jar
|
154
154
|
- library/pdf
|
155
|
-
- library/pdf/bin
|
156
|
-
- library/pdf/bin/processing
|
157
|
-
- library/pdf/bin/processing/pdf
|
158
|
-
- library/pdf/bin/processing/pdf/PGraphicsPDF.class
|
159
155
|
- library/pdf/library
|
160
156
|
- library/pdf/library/itext.jar
|
161
157
|
- library/pdf/library/pdf.jar
|
@@ -312,6 +308,27 @@ files:
|
|
312
308
|
- samples/learning_processing/chapter_16
|
313
309
|
- samples/learning_processing/chapter_16/01_display_video.rb
|
314
310
|
- samples/learning_processing/chapter_16/02_manipulate_video_image.rb
|
311
|
+
- samples/learning_processing/chapter_16/03_adjust_video_brightness.rb
|
312
|
+
- samples/learning_processing/chapter_17
|
313
|
+
- samples/learning_processing/chapter_17/01_simple_displaying_text.rb
|
314
|
+
- samples/learning_processing/chapter_17/02_text_align.rb
|
315
|
+
- samples/learning_processing/chapter_17/03_scrolling_headlines.rb
|
316
|
+
- samples/learning_processing/chapter_17/04_text_mirror.rb
|
317
|
+
- samples/learning_processing/chapter_17/05_rotating_text.rb
|
318
|
+
- samples/learning_processing/chapter_17/06_text_breaking_up.rb
|
319
|
+
- samples/learning_processing/chapter_17/07_boxes_along_a_curve.rb
|
320
|
+
- samples/learning_processing/chapter_17/08_characters_along_a_curve.rb
|
321
|
+
- samples/learning_processing/chapter_17/data
|
322
|
+
- samples/learning_processing/chapter_17/data/ArialMT-16.vlw
|
323
|
+
- samples/learning_processing/chapter_17/data/Courier-Bold-20.vlw
|
324
|
+
- samples/learning_processing/chapter_18
|
325
|
+
- samples/learning_processing/chapter_18/01_user_input.rb
|
326
|
+
- samples/learning_processing/chapter_18/02_graphing_comma_separated_numbers_from_a_text_file.rb
|
327
|
+
- samples/learning_processing/chapter_18/03_creating_object_from_a_text_file.rb
|
328
|
+
- samples/learning_processing/chapter_18/data
|
329
|
+
- samples/learning_processing/chapter_18/data/data-1.txt
|
330
|
+
- samples/learning_processing/chapter_18/data/data-2.txt
|
331
|
+
- samples/orbit.rb
|
315
332
|
- samples/processing_app
|
316
333
|
- samples/processing_app/3D
|
317
334
|
- samples/processing_app/3D/camera
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|