Class: Processing::App
- Inherits:
-
PApplet
- Object
- PApplet
- Processing::App
show all
- Includes:
- Math, MathTool, HelperMethods, Render
- Defined in:
- lib/jruby_art/app.rb
Overview
All sketches extend this class
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#blend_color, #buffer, #color, #dist, #find_method, #frame_rate, #hsb_color, #int_to_ruby_colors, #java_self, #kamera, #key, #key_pressed?, #lerp_color, #load_strings, #max, #min, #mouse_pressed?, #p52ruby, #perspektiv, #proxy_java_fields, #save_strings, #thread, #web_to_color_array
Constructor Details
#initialize(options = {}) ⇒ App
Since processing-3.0 you should prefer setting the sketch width and height and renderer using the size method in the settings loop of the sketch (as with vanilla processing) but is hidden see created java. Options are no longer relevant, define post_initialize method to use custom options (see Sandi Metz POODR)
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
# File 'lib/jruby_art/app.rb', line 105
def initialize(options = {})
super()
Processing.app = self
post_initialize(options)
proxy_java_fields
mix_proxy_into_inner_classes
java.lang.Thread.default_uncaught_exception_handler = proc do |_thread_, exception|
puts(exception.class.to_s)
puts(exception.message)
puts(exception.backtrace.map { |trace| "\t#{trace}" })
close
end
@surface = get_surface
run_sketch
end
|
Class Attribute Details
.library_loader ⇒ Object
Handy getters and setters on the class go here:
66
67
68
|
# File 'lib/jruby_art/app.rb', line 66
def library_loader
@library_loader
end
|
.sketch_class ⇒ Object
Handy getters and setters on the class go here:
66
67
68
|
# File 'lib/jruby_art/app.rb', line 66
def sketch_class
@sketch_class
end
|
Class Method Details
.inherited(subclass) ⇒ Object
Keep track of what inherits from the Processing::App, because we’re going to want to instantiate one.
59
60
61
62
|
# File 'lib/jruby_art/app.rb', line 59
def self.inherited(subclass)
super(subclass)
@sketch_class = subclass
end
|
.library_loaded?(library_name) ⇒ Boolean
74
75
76
|
# File 'lib/jruby_art/app.rb', line 74
def library_loaded?(library_name)
library_loader.library_loaded?(library_name)
end
|
.load_java_library(*args) ⇒ Object
82
83
84
|
# File 'lib/jruby_art/app.rb', line 82
def load_java_library(*args)
library_loader.load_java_library(*args)
end
|
.load_libraries(*args) ⇒ Object
Also known as:
load_library
68
69
70
71
|
# File 'lib/jruby_art/app.rb', line 68
def load_libraries(*args)
@library_loader ||= LibraryLoader.new
library_loader.load_library(*args)
end
|
.load_ruby_library(*args) ⇒ Object
78
79
80
|
# File 'lib/jruby_art/app.rb', line 78
def load_ruby_library(*args)
library_loader.load_ruby_library(*args)
end
|
.method_added(method_name) ⇒ Object
When certain special methods get added to the sketch, we need to let Processing call them by their expected Java names.
88
89
90
91
92
|
# File 'lib/jruby_art/app.rb', line 88
def method_added(method_name) return unless METHODS_TO_ALIAS.key?(method_name)
alias_method METHODS_TO_ALIAS[method_name], method_name
end
|
Instance Method Details
#close ⇒ Object
Close and shutter a running sketch. But don’t exit. way of disposing of sketch window…
166
167
168
169
170
171
172
|
# File 'lib/jruby_art/app.rb', line 166
def close
control_panel.remove if respond_to?(:control_panel)
surface.stopThread
surface.setVisible(false) if surface.isStopped
dispose
Processing.app = nil
end
|
#data_path(dat) ⇒ Object
141
142
143
144
145
|
# File 'lib/jruby_art/app.rb', line 141
def data_path(dat)
dat_root = File.join(SKETCH_ROOT, 'data')
Dir.mkdir(dat_root) unless File.exist?(dat_root)
File.join(dat_root, dat)
end
|
#exit ⇒ Object
174
175
176
177
|
# File 'lib/jruby_art/app.rb', line 174
def exit
control_panel.remove if respond_to?(:control_panel)
super()
end
|
#library_loaded?(library_name) ⇒ Boolean
95
96
97
|
# File 'lib/jruby_art/app.rb', line 95
def library_loaded?(library_name)
self.class.library_loaded?(library_name)
end
|
#on_top(arg = true) ⇒ Object
155
156
157
|
# File 'lib/jruby_art/app.rb', line 155
def on_top(arg = true)
surface.set_always_on_top(arg)
end
|
#post_initialize(_args) ⇒ Object
159
160
161
|
# File 'lib/jruby_art/app.rb', line 159
def post_initialize(_args)
nil
end
|
#resizable(arg = true) ⇒ Object
151
152
153
|
# File 'lib/jruby_art/app.rb', line 151
def resizable(arg = true)
surface.set_resizable(arg)
end
|
#size(*args) ⇒ Object
122
123
124
125
126
127
128
129
|
# File 'lib/jruby_art/app.rb', line 122
def size(*args)
width, height, mode = *args
@width ||= width
@height ||= height
@render_mode ||= mode
import_opengl if /opengl/.match?(mode)
super(*args)
end
|
#sketch_class ⇒ Object
53
54
55
|
# File 'lib/jruby_art/app.rb', line 53
def sketch_class
self.class.sketch_class
end
|
#sketch_path(spath = '') ⇒ Object
135
136
137
138
139
|
# File 'lib/jruby_art/app.rb', line 135
def sketch_path(spath = '')
return super() if spath.empty?
super(spath)
end
|
#sketch_size(x, y) ⇒ Object
147
148
149
|
# File 'lib/jruby_art/app.rb', line 147
def sketch_size(x, y)
surface.set_size(x, y)
end
|
#sketch_title(title) ⇒ Object
131
132
133
|
# File 'lib/jruby_art/app.rb', line 131
def sketch_title(title)
surface.set_title(title)
end
|