ruby-processing 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +137 -0
- data/LICENSE +37 -0
- data/README +61 -0
- data/bin/rp5 +4 -0
- data/lib/core/core.jar +0 -0
- data/lib/core/jruby-complete.jar +0 -0
- data/lib/ruby-processing.rb +27 -0
- data/lib/ruby-processing/app.rb +358 -0
- data/lib/ruby-processing/exporters/applet_exporter.rb +75 -0
- data/lib/ruby-processing/exporters/application_exporter.rb +87 -0
- data/lib/ruby-processing/exporters/base_exporter.rb +133 -0
- data/lib/ruby-processing/exporters/creator.rb +46 -0
- data/lib/ruby-processing/helpers/string.rb +27 -0
- data/lib/ruby-processing/runner.rb +143 -0
- data/lib/ruby-processing/runners/base.rb +5 -0
- data/lib/ruby-processing/runners/live.rb +11 -0
- data/lib/ruby-processing/runners/run.rb +5 -0
- data/lib/ruby-processing/runners/watch.rb +42 -0
- data/lib/templates/applet/images/built_with.jpg +0 -0
- data/lib/templates/applet/images/ruby.jpg +0 -0
- data/lib/templates/applet/images/top.png +0 -0
- data/lib/templates/applet/index.html.erb +111 -0
- data/lib/templates/applet/library/library.txt +1 -0
- data/lib/templates/application/Contents/Info.plist.erb +58 -0
- data/lib/templates/application/Contents/MacOS/JavaApplicationStub +0 -0
- data/lib/templates/application/Contents/PkgInfo +1 -0
- data/lib/templates/application/Contents/Resources/sketch.icns +0 -0
- data/lib/templates/application/lib/MANIFEST.MF +3 -0
- data/lib/templates/application/lib/args.txt.erb +3 -0
- data/lib/templates/application/lib/library/library.txt +1 -0
- data/lib/templates/application/run.erb +4 -0
- data/lib/templates/application/run.exe +0 -0
- data/lib/templates/create/blank_sketch.rb.erb +15 -0
- data/library/boids/boids.rb +222 -0
- data/library/control_panel/control_panel.rb +149 -0
- data/library/dxf/bin/processing/dxf/RawDXF.class +0 -0
- data/library/dxf/dxfviewer.jar +0 -0
- data/library/dxf/library/dxf.jar +0 -0
- data/library/javascript/library/export.txt +6 -0
- data/library/javascript/library/javascript.jar +0 -0
- data/library/minim/library/jl1.0.jar +0 -0
- data/library/minim/library/jsminim.jar +0 -0
- data/library/minim/library/minim-spi.jar +0 -0
- data/library/minim/library/minim.jar +0 -0
- data/library/minim/library/mp3spi1.9.4.jar +0 -0
- data/library/minim/library/tritonus_aos.jar +0 -0
- data/library/minim/library/tritonus_share.jar +0 -0
- data/library/minim/license.txt +339 -0
- data/library/minim/version.txt +1 -0
- data/library/net/bin/processing/net/Client.class +0 -0
- data/library/net/bin/processing/net/Server.class +0 -0
- data/library/net/library/net.jar +0 -0
- 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/opengl/library/export.txt +13 -0
- data/library/opengl/library/gluegen-rt-natives-linux-amd64.jar +0 -0
- data/library/opengl/library/gluegen-rt-natives-linux-i586.jar +0 -0
- data/library/opengl/library/gluegen-rt-natives-macosx-ppc.jar +0 -0
- data/library/opengl/library/gluegen-rt-natives-macosx-universal.jar +0 -0
- data/library/opengl/library/gluegen-rt-natives-windows-amd64.jar +0 -0
- data/library/opengl/library/gluegen-rt-natives-windows-i586.jar +0 -0
- data/library/opengl/library/gluegen-rt.dll +0 -0
- data/library/opengl/library/gluegen-rt.jar +0 -0
- data/library/opengl/library/gluegen-rt.jar.pack.gz +0 -0
- data/library/opengl/library/jogl-natives-linux-amd64.jar +0 -0
- data/library/opengl/library/jogl-natives-linux-i586.jar +0 -0
- data/library/opengl/library/jogl-natives-macosx-ppc.jar +0 -0
- data/library/opengl/library/jogl-natives-macosx-universal.jar +0 -0
- data/library/opengl/library/jogl-natives-windows-amd64.jar +0 -0
- data/library/opengl/library/jogl-natives-windows-i586.jar +0 -0
- data/library/opengl/library/jogl.dll +0 -0
- data/library/opengl/library/jogl.jar +0 -0
- data/library/opengl/library/jogl.jar.pack.gz +0 -0
- data/library/opengl/library/jogl_awt.dll +0 -0
- data/library/opengl/library/jogl_cg.dll +0 -0
- data/library/opengl/library/libgluegen-rt.jnilib +0 -0
- data/library/opengl/library/libgluegen-rt.so +0 -0
- data/library/opengl/library/libjogl.jnilib +0 -0
- data/library/opengl/library/libjogl.so +0 -0
- data/library/opengl/library/libjogl_awt.jnilib +0 -0
- data/library/opengl/library/libjogl_awt.so +0 -0
- data/library/opengl/library/libjogl_cg.jnilib +0 -0
- data/library/opengl/library/libjogl_cg.so +0 -0
- data/library/opengl/library/opengl.jar +0 -0
- data/library/pdf/bin/processing/pdf/PGraphicsPDF.class +0 -0
- data/library/pdf/library/itext.jar +0 -0
- data/library/pdf/library/pdf.jar +0 -0
- data/library/pdf/notes.txt +9 -0
- data/library/serial/bin/processing/serial/Serial.class +0 -0
- data/library/serial/library/RXTXcomm.jar +0 -0
- data/library/serial/library/export.txt +3 -0
- data/library/serial/library/librxtxSerial.jnilib +0 -0
- data/library/serial/library/librxtxSerial.so +0 -0
- data/library/serial/library/rxtxSerial.dll +0 -0
- data/library/serial/library/serial.jar +0 -0
- data/library/video/bin/processing/video/Capture.class +0 -0
- data/library/video/bin/processing/video/Movie.class +0 -0
- data/library/video/bin/processing/video/MovieMaker.class +0 -0
- data/library/video/library/video.jar +0 -0
- data/samples/animator.rb +47 -0
- data/samples/circle_collision.rb +213 -0
- data/samples/fern.rb +49 -0
- data/samples/flight_patterns.rb +64 -0
- data/samples/full_screen.rb +35 -0
- data/samples/getting_started.rb +43 -0
- data/samples/jwishy.rb +85 -0
- data/samples/kinetic_type.rb +100 -0
- data/samples/learning_processing/ABOUT +11 -0
- data/samples/learning_processing/chapter_01/1_stroke_and_fill.rb +34 -0
- data/samples/learning_processing/chapter_01/2_nofill.rb +25 -0
- data/samples/learning_processing/chapter_01/3_rgb_color.rb +31 -0
- data/samples/learning_processing/chapter_01/4_alpha_transparency.rb +36 -0
- data/samples/learning_processing/chapter_01/5_zoog.rb +37 -0
- data/samples/learning_processing/chapter_02/1_zoog_again.rb +39 -0
- data/samples/learning_processing/chapter_03/1_zoog_as_dynamic_sketch.rb +44 -0
- data/samples/learning_processing/chapter_03/2_mouse_x_and_mouse_y.rb +26 -0
- data/samples/learning_processing/chapter_03/3_zoog_as_dynamic_sketch_with_variation.rb +41 -0
- data/samples/learning_processing/chapter_03/4_drawing_a_continuous_line.rb +18 -0
- data/samples/learning_processing/chapter_03/5_mouse_pressed_and_key_pressed.rb +29 -0
- data/samples/learning_processing/chapter_03/6_interactive_zoog.rb +50 -0
- data/samples/learning_processing/chapter_04/1_variable_declaration.rb +24 -0
- data/samples/learning_processing/chapter_04/2_using_variables.rb +27 -0
- data/samples/learning_processing/chapter_04/3_varying_variables.rb +27 -0
- data/samples/learning_processing/chapter_04/4_many_variables.rb +38 -0
- data/samples/learning_processing/chapter_04/5_using_system_variables.rb +28 -0
- data/samples/learning_processing/chapter_04/6_ellipse_with_variables.rb +24 -0
- data/samples/learning_processing/chapter_04/7_filling_variables_with_random_values.rb +27 -0
- data/samples/learning_processing/chapter_04/8_variable_zoog.rb +50 -0
- data/samples/learning_processing/chapter_05/01_conditionals.rb +31 -0
- data/samples/learning_processing/chapter_05/02_more_conditionals.rb +38 -0
- data/samples/learning_processing/chapter_05/03_rollovers.rb +34 -0
- data/samples/learning_processing/chapter_05/04_hold_down_the_button.rb +33 -0
- data/samples/learning_processing/chapter_05/05_button_as_switch.rb +39 -0
- data/samples/learning_processing/chapter_05/06_bouncing_ball.rb +33 -0
- data/samples/learning_processing/chapter_05/07_bouncing_color.rb +37 -0
- data/samples/learning_processing/chapter_05/08_square_following_edge.rb +59 -0
- data/samples/learning_processing/chapter_05/09_simple_gravity.rb +43 -0
- data/samples/learning_processing/chapter_05/10_zoog_and_conditionals.rb +53 -0
- data/samples/learning_processing/chapter_06/01_many_lines.rb +29 -0
- data/samples/learning_processing/chapter_06/02_many_lines_with_variables.rb +53 -0
- data/samples/learning_processing/chapter_06/03_while_loop.rb +30 -0
- data/samples/learning_processing/chapter_06/04_infinite_loop.rb +25 -0
- data/samples/learning_processing/chapter_06/05_another_infinite_loop.rb +33 -0
- data/samples/learning_processing/chapter_06/06_legs_with_a_for_loop.rb +41 -0
- data/samples/learning_processing/chapter_06/07_local_variables.rb +39 -0
- data/samples/learning_processing/chapter_06/08_lines_one_at_a_time.rb +30 -0
- data/samples/learning_processing/chapter_06/09_simple_while_loop_with_interactivity.rb +41 -0
- data/samples/learning_processing/chapter_06/10_zoog_with_arms.rb +56 -0
- data/samples/learning_processing/chapter_06/11_multiple_zoogs.rb +46 -0
- data/samples/learning_processing/chapter_07/01_defining_a_function.rb +22 -0
- data/samples/learning_processing/chapter_07/02_calling_a_function.rb +22 -0
- data/samples/learning_processing/chapter_07/03_bouncing_ball_with_functions.rb +49 -0
- data/samples/learning_processing/chapter_07/04_function_returns_distance.rb +48 -0
- data/samples/learning_processing/chapter_07/05_zoog_with_functions.rb +71 -0
- data/samples/learning_processing/chapter_08/01_car_class_and_car_variable.rb +45 -0
- data/samples/learning_processing/chapter_08/02_two_car_objects.rb +60 -0
- data/samples/learning_processing/chapter_08/03_object_oriented_zoog.rb +81 -0
- data/samples/learning_processing/chapter_10/01_catcher.rb +35 -0
- data/samples/learning_processing/chapter_10/02_bouncing_ball.rb +44 -0
- data/samples/learning_processing/chapter_10/03_bouncing_balls_with_intersection.rb +69 -0
- data/samples/learning_processing/chapter_10/04_a_timer.rb +24 -0
- data/samples/learning_processing/chapter_10/05_object_oriented_timer.rb +42 -0
- data/samples/learning_processing/chapter_10/06_simple_raindrop.rb +23 -0
- data/samples/learning_processing/chapter_10/07_drops_one_at_a_time.rb +63 -0
- data/samples/learning_processing/chapter_13/02_random_number_distribution.rb +24 -0
- data/samples/learning_processing/chapter_13/03_probabilities.rb +33 -0
- data/samples/learning_processing/chapter_13/04_perlin_noise.rb +22 -0
- data/samples/learning_processing/chapter_13/06_oscillation.rb +29 -0
- data/samples/learning_processing/chapter_13/07_wave.rb +31 -0
- data/samples/learning_processing/chapter_13/08_recursion.rb +30 -0
- data/samples/learning_processing/chapter_13/09_two_dimensional_array.rb +21 -0
- data/samples/learning_processing/chapter_13/10_two_dimensional_array_with_objects.rb +54 -0
- data/samples/learning_processing/chapter_14/01_growing_rectangle.rb +26 -0
- data/samples/learning_processing/chapter_14/02_multiple_translations.rb +37 -0
- data/samples/learning_processing/chapter_14/03_depth_rectangle.rb +29 -0
- data/samples/learning_processing/chapter_14/04_pyramid_using_beingshape.rb +55 -0
- data/samples/learning_processing/chapter_14/05_rotate_rectangle_around_center.rb +28 -0
- data/samples/learning_processing/chapter_14/06_rotate_z.rb +24 -0
- data/samples/learning_processing/chapter_14/07_rotate_x.rb +24 -0
- data/samples/learning_processing/chapter_14/08_rotate_y.rb +24 -0
- data/samples/learning_processing/chapter_14/09_rotate_all.rb +24 -0
- data/samples/learning_processing/chapter_14/10_draw_pyramid.rb +59 -0
- data/samples/learning_processing/chapter_14/12_rotating_one_square.rb +25 -0
- data/samples/learning_processing/chapter_14/13_rotating_another_square.rb +25 -0
- data/samples/learning_processing/chapter_14/14_rotating_both_squares.rb +43 -0
- data/samples/learning_processing/chapter_14/15_rotating_many_things.rb +56 -0
- data/samples/learning_processing/chapter_14/16_simple_solar_system.rb +53 -0
- data/samples/learning_processing/chapter_14/17_nested_push_and_pop.rb +50 -0
- data/samples/learning_processing/chapter_14/18_object_oriented_solar_system.rb +69 -0
- data/samples/learning_processing/chapter_15/01_hello_world_image.rb +20 -0
- data/samples/learning_processing/chapter_15/02_image_sprite.rb +29 -0
- data/samples/learning_processing/chapter_15/03_swapping_images.rb +25 -0
- data/samples/learning_processing/chapter_15/04_image_sequence.rb +22 -0
- data/samples/learning_processing/chapter_15/05_setting_pixels.rb +19 -0
- data/samples/learning_processing/chapter_15/06_pixels_2d.rb +29 -0
- data/samples/learning_processing/chapter_15/07_image_pixels.rb +40 -0
- data/samples/learning_processing/chapter_15/08_image_brightness.rb +29 -0
- data/samples/learning_processing/chapter_15/09_flashlight_effect.rb +42 -0
- data/samples/learning_processing/chapter_15/10_brightness_threshold.rb +33 -0
- data/samples/learning_processing/chapter_15/11_brightness_threshold_with_filter.rb +20 -0
- data/samples/learning_processing/chapter_15/12_pixel_neighbour_differences.rb +43 -0
- data/samples/learning_processing/chapter_15/14_pointillism.rb +34 -0
- data/samples/learning_processing/chapter_15/15_2d_image_mapped_to_3d.rb +43 -0
- data/samples/learning_processing/chapter_15/data/animal0.jpg +0 -0
- data/samples/learning_processing/chapter_15/data/animal1.jpg +0 -0
- data/samples/learning_processing/chapter_15/data/animal2.jpg +0 -0
- data/samples/learning_processing/chapter_15/data/animal3.jpg +0 -0
- data/samples/learning_processing/chapter_15/data/animal4.jpg +0 -0
- data/samples/learning_processing/chapter_15/data/animal5.jpg +0 -0
- data/samples/learning_processing/chapter_15/data/animal6.jpg +0 -0
- data/samples/learning_processing/chapter_15/data/face.jpg +0 -0
- data/samples/learning_processing/chapter_15/data/mysummervacation.jpg +0 -0
- data/samples/learning_processing/chapter_15/data/sunflower.jpg +0 -0
- data/samples/learning_processing/chapter_16/01_display_video.rb +25 -0
- data/samples/learning_processing/chapter_16/02_manipulate_video_image.rb +24 -0
- data/samples/reflection.rb +26 -0
- data/samples/simple_buffer.rb +49 -0
- data/samples/tree.rb +83 -0
- metadata +348 -0
@@ -0,0 +1,11 @@
|
|
1
|
+
# An IRB shell for live coding.
|
2
|
+
# This flavor will either load up empty Ruby-Processing,
|
3
|
+
# or will start with your sketch.
|
4
|
+
|
5
|
+
require "#{File.dirname(__FILE__)}/base.rb"
|
6
|
+
|
7
|
+
require 'irb'
|
8
|
+
ARGV[0] = nil # To keep IRB from trying to run it multiple times.
|
9
|
+
require Processing::SKETCH_PATH
|
10
|
+
IRB.setup(__FILE__)
|
11
|
+
IRB.start()
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require "#{File.dirname(__FILE__)}/base.rb"
|
2
|
+
|
3
|
+
module Processing
|
4
|
+
|
5
|
+
# A sketch loader, observer, and reloader, to tighten
|
6
|
+
# the feedback between code and effect.
|
7
|
+
class Watcher
|
8
|
+
|
9
|
+
# Sic a new Processing::Watcher on a given sketch.
|
10
|
+
def initialize(sketch)
|
11
|
+
@file = sketch
|
12
|
+
@time = Time.now
|
13
|
+
load @file
|
14
|
+
start_watching
|
15
|
+
end
|
16
|
+
|
17
|
+
# Kicks off a thread to watch the sketch, reloading Ruby-Processing
|
18
|
+
# and restarting the sketch whenever it changes.
|
19
|
+
def start_watching
|
20
|
+
thread = Thread.start do
|
21
|
+
loop do
|
22
|
+
file_mtime = File.stat(@file).mtime
|
23
|
+
if file_mtime > @time
|
24
|
+
@time = file_mtime
|
25
|
+
Processing::App.wipe_out_current_app!
|
26
|
+
GC.start
|
27
|
+
begin
|
28
|
+
load @file
|
29
|
+
rescue SyntaxError
|
30
|
+
print "Syntax Error in your sketch: ", $!, "\n"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
sleep 0.1
|
34
|
+
end
|
35
|
+
end
|
36
|
+
thread.join
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
Processing::Watcher.new(Processing::SKETCH_PATH)
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,111 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
|
5
|
+
<head>
|
6
|
+
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
7
|
+
<title><%= @title %></title>
|
8
|
+
<style type="text/css">
|
9
|
+
body {
|
10
|
+
background: #000000;
|
11
|
+
font-family: Arial;
|
12
|
+
font-size: 12px;
|
13
|
+
color: #bbb;
|
14
|
+
text-align: center;
|
15
|
+
line-height: 16px;
|
16
|
+
}
|
17
|
+
a {
|
18
|
+
color: #bbb;
|
19
|
+
margin: 0; padding: 0;
|
20
|
+
}
|
21
|
+
a img {
|
22
|
+
border: 0;
|
23
|
+
margin: 0;
|
24
|
+
padding: 0;
|
25
|
+
}
|
26
|
+
#container {
|
27
|
+
width: <%= @width_plus_14 %>px;
|
28
|
+
margin: 0 auto;
|
29
|
+
margin-top: 20px;
|
30
|
+
}
|
31
|
+
#the_applet {
|
32
|
+
padding: 6px;
|
33
|
+
padding-top: 7px; padding-bottom: 2px;
|
34
|
+
background: #262626 url(images/top.png) top left repeat-x;
|
35
|
+
border: 1px solid #363636; border-top: 0;
|
36
|
+
}
|
37
|
+
#built_with {
|
38
|
+
width: 150px;
|
39
|
+
margin: 0 auto;
|
40
|
+
margin-top: 30px;
|
41
|
+
padding: 0;
|
42
|
+
}
|
43
|
+
#description {
|
44
|
+
font-size: 12px;
|
45
|
+
width: <%= @width %>px;
|
46
|
+
padding: 7px;
|
47
|
+
background: #111;
|
48
|
+
text-align: justify;
|
49
|
+
margin: 0 auto;
|
50
|
+
margin-top: 30px; margin-bottom: 10px;
|
51
|
+
border: 1px solid #363636;
|
52
|
+
}
|
53
|
+
#description h1 {
|
54
|
+
font-size: 18px;
|
55
|
+
font-weight: normal;
|
56
|
+
color: #999;
|
57
|
+
font-variant: small-caps;
|
58
|
+
text-align: center;
|
59
|
+
}
|
60
|
+
</style>
|
61
|
+
</head>
|
62
|
+
|
63
|
+
<body>
|
64
|
+
<div id="container">
|
65
|
+
|
66
|
+
<div id="the_applet">
|
67
|
+
<object
|
68
|
+
type="application/x-java-applet"
|
69
|
+
code="<%= @starting_class %>"
|
70
|
+
codebase="."
|
71
|
+
style="margin: 0; padding: 0;"
|
72
|
+
width="<%= @width %>" height="<%= @height %>">
|
73
|
+
|
74
|
+
<param name="archive" value="<%= @file_list %>" />
|
75
|
+
<param name="jruby.script" value="<%= @main_file %>" />
|
76
|
+
<param name="image" value="images/ruby.jpg" />
|
77
|
+
<param name="boxbgcolor" value="#000000" />
|
78
|
+
<param name="lang" value="en" />
|
79
|
+
<param name="mayscript" value="true" />
|
80
|
+
<param name="scriptable" value="true" />
|
81
|
+
<param name="progressbar" value="true" />
|
82
|
+
|
83
|
+
<% if @opengl %>
|
84
|
+
<param name="codebase_lookup" value="false" />
|
85
|
+
<param name="subapplet.classname" value="org.jruby.JRubyApplet" />
|
86
|
+
<param name="subapplet.displayname" value="<%= @title %>" />
|
87
|
+
<% end %>
|
88
|
+
|
89
|
+
<!-- And if you don't have java. -->
|
90
|
+
To view this content, you need to install Java from <a href="http://java.com">java.com</a>
|
91
|
+
</object>
|
92
|
+
</div>
|
93
|
+
|
94
|
+
<div id="built_with">
|
95
|
+
<a href="http://the-shoebox.org/apps/44/">
|
96
|
+
<img src="images/built_with.jpg" alt="Ruby-Processing" />
|
97
|
+
</a>
|
98
|
+
Via <a href="http://jruby.codehaus.org/">JRuby</a> and <a href="http://processing.org/">Processing</a><br />
|
99
|
+
Source: <a href="<%= @main_file %>"><%= @main_file %></a>
|
100
|
+
</div>
|
101
|
+
|
102
|
+
<% unless @description.empty? %>
|
103
|
+
<div id="description">
|
104
|
+
<h1><%= @title %></h1>
|
105
|
+
<p><%= @description %></p>
|
106
|
+
</div>
|
107
|
+
<% end %>
|
108
|
+
|
109
|
+
</div>
|
110
|
+
</body>
|
111
|
+
</html>
|
@@ -0,0 +1 @@
|
|
1
|
+
All of your included libraries will be safely tucked away in here.
|
@@ -0,0 +1,58 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
+
<plist version="1.0">
|
4
|
+
<dict>
|
5
|
+
<key>CFBundleName</key>
|
6
|
+
<string><%= @title %></string>
|
7
|
+
<key>CFBundleVersion</key>
|
8
|
+
<string>1.0</string>
|
9
|
+
<key>CFBundleAllowMixedLocalizations</key>
|
10
|
+
<string>true</string>
|
11
|
+
<key>CFBundleExecutable</key>
|
12
|
+
<string>JavaApplicationStub</string>
|
13
|
+
<key>CFBundleDevelopmentRegion</key>
|
14
|
+
<string>English</string>
|
15
|
+
<key>CFBundlePackageType</key>
|
16
|
+
<string>APPL</string>
|
17
|
+
<key>CFBundleSignature</key>
|
18
|
+
<string>????</string>
|
19
|
+
<key>CFBundleInfoDictionaryVersion</key>
|
20
|
+
<string>6.0</string>
|
21
|
+
<key>CFBundleIconFile</key>
|
22
|
+
<string>sketch.icns</string>
|
23
|
+
<key>CFBundleIdentifier</key>
|
24
|
+
<string>org.ruby-processing.<%= @class_name %></string>
|
25
|
+
<key>Java</key>
|
26
|
+
<dict>
|
27
|
+
<key>VMOptions</key>
|
28
|
+
<string>-Xms128M -Xmx256M</string>
|
29
|
+
<key>MainClass</key>
|
30
|
+
<string>org.jruby.Main</string>
|
31
|
+
<key>WorkingDirectory</key>
|
32
|
+
<string>$JAVAROOT</string>
|
33
|
+
<key>Arguments</key>
|
34
|
+
<string>ruby-processing/runners/run.rb <%= @main_file %></string>
|
35
|
+
<key>JVMVersion</key>
|
36
|
+
<string>1.3+</string>
|
37
|
+
<key>ClassPath</key>
|
38
|
+
<string><%= @class_path %></string>
|
39
|
+
<key>Properties</key>
|
40
|
+
<dict>
|
41
|
+
<key>apple.laf.useScreenMenuBar</key>
|
42
|
+
<string>true</string>
|
43
|
+
<key>apple.awt.showGrowBox</key>
|
44
|
+
<string>false</string>
|
45
|
+
<key>com.apple.smallTabs</key>
|
46
|
+
<string>true</string>
|
47
|
+
<key>apple.awt.Antialiasing</key>
|
48
|
+
<string>false</string>
|
49
|
+
<key>apple.awt.TextAntialiasing</key>
|
50
|
+
<string>true</string>
|
51
|
+
<key>com.apple.hwaccel</key>
|
52
|
+
<string>true</string>
|
53
|
+
<key>apple.awt.use-file-dialog-packages</key>
|
54
|
+
<string>false</string>
|
55
|
+
</dict>
|
56
|
+
</dict>
|
57
|
+
</dict>
|
58
|
+
</plist>
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
APPL????
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
All of your included libraries will be safely tucked away in here.
|
Binary file
|
@@ -0,0 +1,222 @@
|
|
1
|
+
# Boids -- after Tom de Smedt.
|
2
|
+
# See his Python version: http://nodebox.net/code/index.php/Boids
|
3
|
+
# This is an example of how a pure-Ruby library can work.
|
4
|
+
# -- omygawshkenas
|
5
|
+
|
6
|
+
class Boid
|
7
|
+
attr_accessor :boids, :x, :y, :z, :vx, :vy, :vz, :is_perching, :perch_time
|
8
|
+
|
9
|
+
def initialize(boids, x, y, z)
|
10
|
+
@boids, @flock = boids, boids
|
11
|
+
@x, @y, @z = x, y, z
|
12
|
+
@vx, @vy, @vz = 0.0, 0.0, 0.0
|
13
|
+
@is_perching = false
|
14
|
+
@perch_time = 0.0
|
15
|
+
end
|
16
|
+
|
17
|
+
def cohesion(d = 100.0)
|
18
|
+
# Boids gravitate towards the center of the flock,
|
19
|
+
# Which is the averaged position of the rest of the boids.
|
20
|
+
vx = vy = vz = 0.0
|
21
|
+
@boids.each do |boid|
|
22
|
+
vx, vy, vz = vx+boid.x, vy+boid.y, vz+boid.z unless boid == self
|
23
|
+
end
|
24
|
+
count = @boids.length - 1.0
|
25
|
+
vx, vy, vz = vx/count, vy/count, vz/count
|
26
|
+
return (vx - @x)/d, (vy - @y)/d, (vz - @z)/d
|
27
|
+
end
|
28
|
+
|
29
|
+
def separation(radius = 10.0)
|
30
|
+
# Boids don't like to cuddle.
|
31
|
+
vx = vy = vz = 0.0
|
32
|
+
@boids.each do |boid|
|
33
|
+
if boid != self
|
34
|
+
dvx, dvy, dvz = @x - boid.x, @y - boid.y, @z - boid.z
|
35
|
+
vx += dvx if dvx.abs < radius
|
36
|
+
vy += dvy if dvy.abs < radius
|
37
|
+
vz += dvz if dvz.abs < radius
|
38
|
+
end
|
39
|
+
end
|
40
|
+
return vx, vy, vz
|
41
|
+
end
|
42
|
+
|
43
|
+
def alignment(d = 5.0)
|
44
|
+
# Boids like to fly at the speed of traffic.
|
45
|
+
vx = vy = vz = 0.0
|
46
|
+
@boids.each do |boid|
|
47
|
+
if boid != self
|
48
|
+
vx, vy, vz = vx+boid.vx, vy+boid.vy, vz+boid.vz
|
49
|
+
end
|
50
|
+
end
|
51
|
+
count = @boids.length - 1.0
|
52
|
+
vx, vy, vz = vx/count, vy/count, vz/count
|
53
|
+
return (vx - @vx)/d, (vy - @vy)/d, (vz - @vz)/d
|
54
|
+
end
|
55
|
+
|
56
|
+
def limit(max=30.0)
|
57
|
+
# Tweet, Tweet! The boid police will bust you for breaking the speed limit.
|
58
|
+
@vx = (@vx/@vx.abs) * max if @vx.abs > max
|
59
|
+
@vy = (@vy/@vy.abs) * max if @vy.abs > max
|
60
|
+
@vz = (@vz/@vz.abs) * max if @vz.abs > max
|
61
|
+
end
|
62
|
+
|
63
|
+
def angle
|
64
|
+
a = (Math.atan(@vy / @vx) * (180.0 / Math::PI)) + 360.0
|
65
|
+
a += 180.0 if @vx < 0.0
|
66
|
+
return a
|
67
|
+
end
|
68
|
+
|
69
|
+
def goal(x, y, z, d = 50.0)
|
70
|
+
# Them boids is hungry.
|
71
|
+
return (x - @x)/d, (y - @y)/d, (z - @z)/d
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
class Boids < Array
|
78
|
+
attr_accessor :boids, :x, :y, :w, :h,
|
79
|
+
:scattered, :has_goal, :flee
|
80
|
+
|
81
|
+
attr_reader :scatter, :scatter_time, :scatter_i,
|
82
|
+
:perch, :perch_y, :perch_t,
|
83
|
+
:goal_x, :goal_y, :goal_z
|
84
|
+
|
85
|
+
def self.flock(n, x, y, w, h)
|
86
|
+
return Boids.new.setup(n, x, y, w, h)
|
87
|
+
end
|
88
|
+
|
89
|
+
def setup(n, x, y, w, h)
|
90
|
+
n.times do |i|
|
91
|
+
dx, dy = rand(w), rand(h)
|
92
|
+
z = rand(200.0)
|
93
|
+
self << Boid.new(self, x + dx, y + dy, z)
|
94
|
+
end
|
95
|
+
@x, @y, @w, @h = x, y, w, h
|
96
|
+
@scattered = false
|
97
|
+
@scatter = 0.005
|
98
|
+
@scatter_time = 50.0
|
99
|
+
@scatter_i = 0.0
|
100
|
+
@perch = 1.0 # Lower this number to divebomb.
|
101
|
+
@perch_y = @h
|
102
|
+
@perch_time = lambda {25.0 + rand(50.0)}
|
103
|
+
@has_goal = false
|
104
|
+
@flee = false
|
105
|
+
@goal_x = @goal_y = @goal_z = 0.0
|
106
|
+
return self
|
107
|
+
end
|
108
|
+
|
109
|
+
def scatter(chance = 0.005, frames = 50.0)
|
110
|
+
@scatter = chance
|
111
|
+
@scatter_time = frames
|
112
|
+
end
|
113
|
+
|
114
|
+
def no_scatter
|
115
|
+
@scatter = 0.0
|
116
|
+
end
|
117
|
+
|
118
|
+
def perch(ground = nil, chance = 1.0, frames = nil)
|
119
|
+
frames ||= lambda {25.0 + rand(50.0)}
|
120
|
+
ground ||= @h
|
121
|
+
@perch, @perch_y, @perch_time = chance, ground, frames
|
122
|
+
end
|
123
|
+
|
124
|
+
def no_perch
|
125
|
+
@perch = 0.0
|
126
|
+
end
|
127
|
+
|
128
|
+
def goal(x, y, z, flee = false)
|
129
|
+
@has_goal = true
|
130
|
+
@flee = flee
|
131
|
+
@goal_x, @goal_y, @goal_z = x, y, z
|
132
|
+
end
|
133
|
+
|
134
|
+
def no_goal
|
135
|
+
@has_goal = false
|
136
|
+
end
|
137
|
+
|
138
|
+
def constrain
|
139
|
+
# Put them boids in a cage.
|
140
|
+
dx, dy = @w * 0.1, @h * 0.1
|
141
|
+
self.each do |b|
|
142
|
+
b.vx += rand(dx) if b.x < @x - dx
|
143
|
+
b.vx += rand(dy) if b.y < @y - dy
|
144
|
+
b.vx -= rand(dx) if b.x > @x + @w + dx
|
145
|
+
b.vy -= rand(dy) if b.y > @y + @h + dy
|
146
|
+
b.vz += 10.0 if b.z < 0.0
|
147
|
+
b.vz -= 10.0 if b.z > 100.0
|
148
|
+
|
149
|
+
if b.y > @perch_y && rand < @perch
|
150
|
+
b.y = @perch_y
|
151
|
+
b.vy = -(b.vy.abs) * 0.2
|
152
|
+
b.is_perching = true
|
153
|
+
@perch_time.respond_to?(:call) ? b.perch_time = @perch_time.call : b.perch_time = @perch_time
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
def shuffle
|
159
|
+
self.sort! { rand }
|
160
|
+
end
|
161
|
+
|
162
|
+
def update(opts={})
|
163
|
+
# Just flutter, little boids ... just flutter away.
|
164
|
+
# Shuffling keeps things flowing smooth.
|
165
|
+
options = {:shuffled => true,
|
166
|
+
:cohesion => 100.0,
|
167
|
+
:separation => 10.0,
|
168
|
+
:alignment => 5.0,
|
169
|
+
:goal => 20.0,
|
170
|
+
:limit => 30.0}
|
171
|
+
options.merge! opts
|
172
|
+
|
173
|
+
self.shuffle if options[:shuffled]
|
174
|
+
m1 = 1.0 # cohesion
|
175
|
+
m2 = 1.0 # separation
|
176
|
+
m3 = 1.0 # alignment
|
177
|
+
m4 = 1.0 # goal
|
178
|
+
|
179
|
+
@scattered = true if !(@scattered) && rand < @scatter
|
180
|
+
if @scattered
|
181
|
+
m1 = -m1
|
182
|
+
m3 *= 0.25
|
183
|
+
@scatter_i += 1.0
|
184
|
+
end
|
185
|
+
if @scatter_i >= @scatter_time
|
186
|
+
@scattered = false
|
187
|
+
@scatter_i = 0.0
|
188
|
+
end
|
189
|
+
|
190
|
+
m4 = 0.0 unless @has_goal
|
191
|
+
m4 = -m4 if @flee
|
192
|
+
|
193
|
+
self.each do |b|
|
194
|
+
if b.is_perching
|
195
|
+
if b.perch_time > 0.0
|
196
|
+
b.perch_time -= 1.0
|
197
|
+
next
|
198
|
+
else
|
199
|
+
b.is_perching = false
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
vx1, vy1, vz1 = b.cohesion(options[:cohesion])
|
204
|
+
vx2, vy2, vz2 = b.separation(options[:separation])
|
205
|
+
vx3, vy3, vz3 = b.alignment(options[:alignment])
|
206
|
+
vx4, vy4, vz4 = b.goal(@goal_x, @goal_y, @goal_z, options[:goal])
|
207
|
+
|
208
|
+
b.vx += m1*vx1 + m2*vx2 + m3*vx3 + m4*vx4
|
209
|
+
b.vy += m1*vy1 + m2*vy2 + m3*vy3 + m4*vy4
|
210
|
+
b.vz += m1*vz1 + m2*vz2 + m3*vz3 + m4*vz4
|
211
|
+
|
212
|
+
b.limit(options[:limit])
|
213
|
+
|
214
|
+
b.x += b.vx
|
215
|
+
b.y += b.vy
|
216
|
+
b.z += b.vz
|
217
|
+
end
|
218
|
+
self.constrain
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
|