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
data/CHANGELOG
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
v1.0.4 Bare is Beautiful...
|
2
|
+
* Ruby-Processing now supports "bare" sketches, which are sketches that
|
3
|
+
consist of only setup and draw methods, or sketches that contain no method
|
4
|
+
definitions at all (implicitly wrapping them in a 'setup'). This works
|
5
|
+
by pre-processing the code.
|
6
|
+
* Initialization heavily tweaked so that size() works as in Processing,
|
7
|
+
from within setup(), and so that you can call full_screen as a class method,
|
8
|
+
in your class definition, to avoid the need for explicit sketch instantiation.
|
9
|
+
* "rp5 create" has a "--bare" option.
|
10
|
+
* Many samples now use the bare style, and more "Learning Processing" examples
|
11
|
+
were contributed by Juris Galang.
|
12
|
+
|
1
13
|
v1.0.3 Tweaks and Tuneups...
|
2
14
|
* "rp5 watch" is now a bit more robust, and tries to reload every
|
3
15
|
* file, global, and constant that it thinks it needs to.
|
data/README
CHANGED
@@ -17,6 +17,9 @@
|
|
17
17
|
* Live Coding via JRuby's IRB. Loads in your sketch so you can futz with
|
18
18
|
variables and remake methods on the fly.
|
19
19
|
|
20
|
+
* Bare sketches. Write your Ruby-Processing sketches without having to define
|
21
|
+
a class. Without defining methods, even.
|
22
|
+
|
20
23
|
* A "Control Panel" library, so that you can easily create sliders, buttons,
|
21
24
|
checkboxes and drop-down menus, and hook them into your sketch's instance
|
22
25
|
variables.
|
data/lib/core/core.jar
CHANGED
Binary file
|
data/lib/core/jruby-complete.jar
CHANGED
Binary file
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Index: src/org/jruby/JRubyApplet.java
|
2
|
+
===================================================================
|
3
|
+
--- src/org/jruby/JRubyApplet.java (revision 9392)
|
4
|
+
+++ src/org/jruby/JRubyApplet.java (working copy)
|
5
|
+
@@ -257,6 +257,10 @@
|
6
|
+
}
|
7
|
+
}
|
8
|
+
|
9
|
+
+ public synchronized void eval(String code) {
|
10
|
+
+ this.runtime.evalScriptlet(code);
|
11
|
+
+ }
|
12
|
+
+
|
13
|
+
public synchronized void setBackgroundColor(Color color) {
|
14
|
+
backgroundColor = color;
|
15
|
+
repaint();
|
16
|
+
@@ -381,7 +385,7 @@
|
17
|
+
|
18
|
+
public ConsoleFacade(String bannerText) {
|
19
|
+
textPane = new JTextPane();
|
20
|
+
- textPane.setMargin(new Insets(4, 4, 0, 4));
|
21
|
+
+ textPane.setMargin(new Insets(4, 4, 0, 4));
|
22
|
+
textPane.setCaretColor(new Color(0xa4, 0x00, 0x00));
|
23
|
+
textPane.setBackground(new Color(0xf2, 0xf2, 0xf2));
|
24
|
+
textPane.setForeground(new Color(0xa4, 0x00, 0x00));
|
@@ -0,0 +1,27 @@
|
|
1
|
+
Index: core/src/processing/core/PApplet.java
|
2
|
+
===================================================================
|
3
|
+
--- core/src/processing/core/PApplet.java (revision 5371)
|
4
|
+
+++ core/src/processing/core/PApplet.java (working copy)
|
5
|
+
@@ -1386,7 +1386,22 @@
|
6
|
+
} catch (RendererChangeException e) {
|
7
|
+
// Give up, instead set the new renderer and re-attempt setup()
|
8
|
+
return;
|
9
|
+
+
|
10
|
+
+ // Catch a JRuby exception so that the RendererChangeExceptions
|
11
|
+
+ // that we're looking for don't get stuck in Ruby-space.
|
12
|
+
+ } catch (RuntimeException e) {
|
13
|
+
+ String message = e.getMessage();
|
14
|
+
+ String name = RendererChangeException.class.getName();
|
15
|
+
+ String regex = "(?s).*" + name + ".*";
|
16
|
+
+ regex = regex.replace("$", "\\$");
|
17
|
+
+ if (message != null && message.matches(regex)) {
|
18
|
+
+ // Give up, instead set the new renderer and re-attempt setup()
|
19
|
+
+ return;
|
20
|
+
+ } else {
|
21
|
+
+ throw e;
|
22
|
+
+ }
|
23
|
+
}
|
24
|
+
+
|
25
|
+
this.defaultSize = false;
|
26
|
+
|
27
|
+
} else { // frameCount > 0, meaning an actual draw()
|
data/lib/ruby-processing.rb
CHANGED
@@ -7,12 +7,14 @@ unless defined? RP5_ROOT
|
|
7
7
|
RP5_ROOT = File.expand_path(File.dirname(__FILE__) + "/../")
|
8
8
|
end
|
9
9
|
|
10
|
+
SKETCH_ROOT = Dir.pwd unless defined? SKETCH_ROOT
|
11
|
+
|
10
12
|
require 'ruby-processing/helpers/string'
|
11
13
|
require 'ruby-processing/helpers/numeric'
|
12
14
|
|
13
15
|
# The top-level namespace, a home for all Ruby-Processing classes.
|
14
16
|
module Processing
|
15
|
-
VERSION = [1,0,
|
17
|
+
VERSION = [1,0,4] unless defined? Processing::VERSION
|
16
18
|
|
17
19
|
# Returns the current version of Ruby-Processing.
|
18
20
|
def self.version
|
@@ -21,6 +23,7 @@ module Processing
|
|
21
23
|
|
22
24
|
autoload :App, 'ruby-processing/app'
|
23
25
|
autoload :Runner, 'ruby-processing/runner'
|
26
|
+
autoload :Watcher, 'ruby-processing/runners/watch'
|
24
27
|
autoload :Creator, 'ruby-processing/exporters/creator'
|
25
28
|
autoload :BaseExporter, 'ruby-processing/exporters/base_exporter'
|
26
29
|
autoload :AppletExporter, 'ruby-processing/exporters/applet_exporter'
|
data/lib/ruby-processing/app.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
require 'java'
|
6
6
|
|
7
|
-
module Processing
|
7
|
+
module Processing
|
8
8
|
|
9
9
|
# Conditionally load core.jar
|
10
10
|
require "#{RP5_ROOT}/lib/core/core.jar" unless Object.const_defined?(:JRUBY_APPLET)
|
@@ -19,8 +19,6 @@ module Processing
|
|
19
19
|
# called constantly, for every frame.
|
20
20
|
class App < PApplet
|
21
21
|
include Math
|
22
|
-
|
23
|
-
import "javax.swing.JFrame"
|
24
22
|
|
25
23
|
# Include some processing classes that we'd like to use:
|
26
24
|
%w(PShape PImage PGraphics PFont PVector).each do |klass|
|
@@ -46,6 +44,10 @@ module Processing
|
|
46
44
|
:key_released => :keyReleased,
|
47
45
|
:key_typed => :keyTyped
|
48
46
|
}
|
47
|
+
|
48
|
+
# Override the default width and height to make them a little larger.
|
49
|
+
DEFAULT_WIDTH = 200
|
50
|
+
DEFAULT_HEIGHT = 200
|
49
51
|
|
50
52
|
|
51
53
|
def self.method_added(method_name) #:nodoc:
|
@@ -67,8 +69,18 @@ module Processing
|
|
67
69
|
end
|
68
70
|
|
69
71
|
|
70
|
-
|
71
|
-
def self.
|
72
|
+
# Handy getters and setters on the class go here:
|
73
|
+
def self.sketch_class; @sketch_class; end
|
74
|
+
def self.full_screen; @@full_screen = true; end
|
75
|
+
def full_screen?; @@full_screen; end
|
76
|
+
|
77
|
+
|
78
|
+
# Keep track of what inherits from the Processing::App, because we're going
|
79
|
+
# to want to instantiate one.
|
80
|
+
def self.inherited(subclass)
|
81
|
+
super(subclass)
|
82
|
+
@sketch_class = subclass
|
83
|
+
end
|
72
84
|
|
73
85
|
|
74
86
|
# Are we running inside an applet?
|
@@ -103,8 +115,14 @@ module Processing
|
|
103
115
|
def self.load_ruby_library(dir)
|
104
116
|
dir = dir.to_sym
|
105
117
|
return true if @@loaded_libraries[dir]
|
106
|
-
|
107
|
-
|
118
|
+
if online?
|
119
|
+
begin
|
120
|
+
return @@loaded_libraries[dir] = (require "library/#{dir}/#{dir}")
|
121
|
+
rescue LoadError => e
|
122
|
+
return false
|
123
|
+
end
|
124
|
+
end
|
125
|
+
local_path = "#{SKETCH_ROOT}/library/#{dir}"
|
108
126
|
gem_path = "#{RP5_ROOT}/library/#{dir}"
|
109
127
|
path = File.exists?(local_path) ? local_path : gem_path
|
110
128
|
return false unless (File.exists?("#{path}/#{dir}.rb"))
|
@@ -122,10 +140,10 @@ module Processing
|
|
122
140
|
dir = dir.to_sym
|
123
141
|
return true if @@loaded_libraries[dir]
|
124
142
|
return @@loaded_libraries[dir] = !!(JRUBY_APPLET.get_parameter("archive").match(%r(#{dir}))) if online?
|
125
|
-
local_path = "#{
|
143
|
+
local_path = "#{SKETCH_ROOT}/library/#{dir}"
|
126
144
|
gem_path = "#{RP5_ROOT}/library/#{dir}"
|
127
145
|
path = File.exists?(local_path) ? local_path : gem_path
|
128
|
-
jars = Dir
|
146
|
+
jars = Dir["#{path}/**/*.jar"]
|
129
147
|
return false if jars.empty?
|
130
148
|
jars.each {|jar| require jar }
|
131
149
|
# Here goes...
|
@@ -139,23 +157,12 @@ module Processing
|
|
139
157
|
end
|
140
158
|
return @@loaded_libraries[dir] = true
|
141
159
|
end
|
142
|
-
|
160
|
+
|
143
161
|
|
144
162
|
def self.has_slider(*args) #:nodoc:
|
145
163
|
raise "has_slider has been replaced with a nicer control_panel library. Check it out."
|
146
164
|
end
|
147
|
-
|
148
|
-
|
149
|
-
# Used by the Processing::Watcher to completely remove all
|
150
|
-
# traces of the current sketch, so that it can be loaded afresh.
|
151
|
-
def self.wipe_out_current_app!
|
152
|
-
app = Processing::App.current
|
153
|
-
return unless app
|
154
|
-
app_class_name = app.class.to_s.to_sym
|
155
|
-
app.close
|
156
|
-
Object.send(:remove_const, app_class_name)
|
157
|
-
end
|
158
|
-
|
165
|
+
|
159
166
|
|
160
167
|
# When you make a new sketch, you pass in (optionally),
|
161
168
|
# a width, height, title, and whether or not you want to
|
@@ -163,20 +170,26 @@ module Processing
|
|
163
170
|
#
|
164
171
|
# This is a little different than Processing where height
|
165
172
|
# and width are declared inside the setup method instead.
|
166
|
-
def initialize(options
|
173
|
+
def initialize(options={})
|
167
174
|
super()
|
168
|
-
$app =
|
175
|
+
$app = self
|
176
|
+
proxy_java_fields
|
169
177
|
set_sketch_path unless online?
|
170
|
-
make_accessible_to_the_browser
|
171
|
-
options
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
178
|
+
make_accessible_to_the_browser if online?
|
179
|
+
@width = options[:width] || DEFAULT_WIDTH
|
180
|
+
@height = options[:height] || DEFAULT_HEIGHT
|
181
|
+
@title = options[:title] || File.basename(Processing::SKETCH_PATH, '.rb').titleize
|
182
|
+
@render_mode ||= JAVA2D
|
183
|
+
@@full_screen ||= options[:full_screen]
|
184
|
+
self.init
|
185
|
+
determine_how_to_display
|
186
|
+
end
|
187
|
+
|
188
|
+
|
189
|
+
# Make sure we set the size if we set it before we start the animation thread.
|
190
|
+
def start
|
191
|
+
self.size(@width, @height)
|
192
|
+
super()
|
180
193
|
end
|
181
194
|
|
182
195
|
|
@@ -189,10 +202,17 @@ module Processing
|
|
189
202
|
# By default, your sketch path is the folder that your sketch is in.
|
190
203
|
# If you'd like to do something fancy, feel free.
|
191
204
|
def set_sketch_path(path=nil)
|
192
|
-
field =
|
193
|
-
local =
|
205
|
+
field = @declared_fields['sketchPath']
|
206
|
+
local = SKETCH_ROOT
|
194
207
|
default = $__windows_app_mode__ ? "#{local}/lib" : local
|
195
|
-
field.set_value(
|
208
|
+
field.set_value(java_self, path || default)
|
209
|
+
end
|
210
|
+
|
211
|
+
|
212
|
+
# Specify what rendering Processing should use, without needing to pass size.
|
213
|
+
def render_mode(mode_const)
|
214
|
+
@render_mode = mode_const
|
215
|
+
size(@width, @height, @render_mode)
|
196
216
|
end
|
197
217
|
|
198
218
|
|
@@ -204,13 +224,6 @@ module Processing
|
|
204
224
|
end
|
205
225
|
|
206
226
|
|
207
|
-
# Specify what rendering Processing should use.
|
208
|
-
def render_mode(mode_const)
|
209
|
-
@render_mode = mode_const
|
210
|
-
size(@width, @height, @render_mode)
|
211
|
-
end
|
212
|
-
|
213
|
-
|
214
227
|
# Nice block method to draw to a buffer.
|
215
228
|
# You can optionally pass it a width, a height, and a renderer.
|
216
229
|
# Takes care of starting and ending the draw for you.
|
@@ -232,14 +245,18 @@ module Processing
|
|
232
245
|
yield x, y
|
233
246
|
end
|
234
247
|
end
|
248
|
+
|
249
|
+
|
250
|
+
# Provide a convenient handle for the Java-space version of self.
|
251
|
+
def java_self
|
252
|
+
@java_self ||= Java.ruby_to_java self
|
253
|
+
end
|
235
254
|
|
236
255
|
|
237
256
|
# Fix java conversion problems getting the last key
|
238
257
|
# If it's ASCII, return the character, otherwise the integer
|
239
258
|
def key
|
240
|
-
|
241
|
-
app = Java.ruby_to_java self
|
242
|
-
int = field.value(app)
|
259
|
+
int = @declared_fields['key'].value(java_self)
|
243
260
|
int < 256 ? int.chr : int
|
244
261
|
end
|
245
262
|
|
@@ -260,6 +277,25 @@ module Processing
|
|
260
277
|
def key_code; keyCode; end
|
261
278
|
|
262
279
|
|
280
|
+
# frame_rate needs to support reading and writing
|
281
|
+
def frame_rate(fps = nil)
|
282
|
+
return @declared_fields['frameRate'].value(java_self) unless fps
|
283
|
+
super(fps)
|
284
|
+
end
|
285
|
+
|
286
|
+
|
287
|
+
# Is the sketch still displaying with the default size?
|
288
|
+
def default_size?
|
289
|
+
@declared_fields['defaultSize'].value(java_self)
|
290
|
+
end
|
291
|
+
|
292
|
+
|
293
|
+
# Is the sketch done displaying itself?
|
294
|
+
def done_displaying?
|
295
|
+
@done_displaying
|
296
|
+
end
|
297
|
+
|
298
|
+
|
263
299
|
# Is the mouse pressed for this frame?
|
264
300
|
def mouse_pressed?
|
265
301
|
Java.java_to_primitive(java_class.field("mousePressed").value(java_object))
|
@@ -277,70 +313,81 @@ module Processing
|
|
277
313
|
def lerp_color(*args)
|
278
314
|
args.length > 3 ? self.class.lerp_color(*args) : super(*args)
|
279
315
|
end
|
280
|
-
|
316
|
+
|
281
317
|
|
282
318
|
# Cleanly close and shutter a running sketch.
|
283
319
|
def close
|
284
|
-
|
320
|
+
$app = nil
|
285
321
|
control_panel.remove if respond_to?(:control_panel) && !online?
|
286
|
-
container =
|
322
|
+
container = online? ? JRUBY_APPLET : @frame
|
287
323
|
container.remove(self)
|
288
324
|
self.destroy
|
289
325
|
container.dispose
|
290
326
|
end
|
291
|
-
|
292
|
-
|
293
|
-
def quit
|
294
|
-
exit
|
295
|
-
end
|
296
327
|
|
297
328
|
|
298
329
|
private
|
299
330
|
|
331
|
+
# Proxy over a list of Java declared fields that have the same name as
|
332
|
+
# some methods. Add to this list as needed.
|
333
|
+
def proxy_java_fields
|
334
|
+
@declared_fields = {}
|
335
|
+
fields = %w(sketchPath key frameRate defaultSize)
|
336
|
+
fields.each {|f| @declared_fields[f] = java_class.declared_field(f) }
|
337
|
+
end
|
338
|
+
|
339
|
+
|
300
340
|
# Tests to see which display method should run.
|
301
|
-
def determine_how_to_display
|
302
|
-
|
341
|
+
def determine_how_to_display
|
342
|
+
# Wait for init to get its grey tracksuit on and run a few laps.
|
343
|
+
sleep 0.02 while default_size? && !@@full_screen
|
344
|
+
|
345
|
+
if online?
|
303
346
|
display_in_an_applet
|
304
|
-
elsif
|
305
|
-
|
306
|
-
|
307
|
-
|
347
|
+
elsif full_screen?
|
348
|
+
# linux doesn't support full screen exclusive mode, but don't worry, it works very well
|
349
|
+
display = java.awt.GraphicsEnvironment.get_local_graphics_environment.get_default_screen_device
|
350
|
+
linux = java.lang.System.get_property("os.name") == "Linux"
|
351
|
+
supported = display.full_screen_supported?
|
352
|
+
supported || linux ? display_full_screen(display) : display_in_a_window
|
353
|
+
else
|
308
354
|
display_in_a_window
|
309
355
|
end
|
356
|
+
@done_displaying = true
|
310
357
|
end
|
311
358
|
|
312
359
|
|
313
|
-
|
314
|
-
|
315
|
-
|
360
|
+
# Go full screen, if possible
|
361
|
+
def display_full_screen(display)
|
362
|
+
@frame = java.awt.Frame.new(display.default_configuration)
|
363
|
+
mode = display.display_mode
|
316
364
|
@width, @height = mode.get_width, mode.get_height
|
317
|
-
gc = graphics_env.get_default_configuration
|
318
365
|
@frame.set_undecorated true
|
366
|
+
@frame.set_ignore_repaint true
|
319
367
|
@frame.set_background java.awt.Color.black
|
320
368
|
@frame.set_layout java.awt.BorderLayout.new
|
321
369
|
@frame.add(self, java.awt.BorderLayout::CENTER)
|
322
370
|
@frame.pack
|
323
|
-
|
371
|
+
display.set_full_screen_window @frame
|
324
372
|
@frame.set_location(0, 0)
|
325
373
|
@frame.show
|
326
|
-
self.init
|
327
374
|
self.request_focus
|
328
375
|
end
|
329
376
|
|
330
377
|
|
331
378
|
def display_in_a_window
|
332
|
-
@frame = JFrame.new(@title)
|
379
|
+
@frame = javax.swing.JFrame.new(@title)
|
333
380
|
@frame.add(self)
|
334
|
-
@frame.
|
335
|
-
@frame.
|
336
|
-
@frame.
|
381
|
+
@frame.pack
|
382
|
+
@frame.set_default_close_operation(javax.swing.JFrame::EXIT_ON_CLOSE)
|
383
|
+
@frame.set_resizable(false)
|
384
|
+
# Plus 22 for the height of the window's title bar
|
385
|
+
@frame.set_size(width, height + 22)
|
337
386
|
@frame.show
|
338
|
-
self.init
|
339
387
|
end
|
340
388
|
|
341
389
|
|
342
390
|
def display_in_an_applet
|
343
|
-
JRUBY_APPLET.set_size(@width, @height)
|
344
391
|
JRUBY_APPLET.background_color = nil
|
345
392
|
JRUBY_APPLET.double_buffered = false
|
346
393
|
JRUBY_APPLET.add self
|
@@ -348,7 +395,6 @@ module Processing
|
|
348
395
|
# Add the callbacks to peacefully expire.
|
349
396
|
JRUBY_APPLET.on_stop { self.stop }
|
350
397
|
JRUBY_APPLET.on_destroy { self.destroy }
|
351
|
-
self.init
|
352
398
|
end
|
353
399
|
|
354
400
|
|
@@ -356,7 +402,7 @@ module Processing
|
|
356
402
|
# accessible to javascript as the 'ruby' variable. From javascript,
|
357
403
|
# you can call evalScriptlet() to run code against the sketch.
|
358
404
|
def make_accessible_to_the_browser
|
359
|
-
return unless library_loaded?('net')
|
405
|
+
return unless library_loaded?('net')
|
360
406
|
field = java.lang.Class.for_name("org.jruby.JRubyApplet").get_declared_field("runtime")
|
361
407
|
field.set_accessible true
|
362
408
|
ruby = field.get(JRUBY_APPLET)
|