Class: Processing::App
- Inherits:
-
PApplet
- Object
- PApplet
- Processing::App
- Includes:
- Math, HelperMethods
- Defined in:
- lib/ruby-processing/app.rb
Overview
All sketches extend this class
Class Attribute Summary collapse
-
.library_loader ⇒ Object
Handy getters and setters on the class go here:.
-
.sketch_class ⇒ Object
Handy getters and setters on the class go here:.
Class Method Summary collapse
-
.inherited(subclass) ⇒ Object
Keep track of what inherits from the Processing::App, because we’re going to want to instantiate one.
- .library_loaded?(library_name) ⇒ Boolean
- .load_java_library(*args) ⇒ Object
- .load_libraries(*args) ⇒ Object (also: load_library)
- .load_ruby_library(*args) ⇒ Object
-
.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.
Instance Method Summary collapse
-
#close ⇒ Object
Cleanly close and shutter a running sketch.
-
#initialize(options = {}) ⇒ App
constructor
It is ‘NOT’ usually necessary to directly pass options to a sketch, it gets done automatically for you.
-
#inspect ⇒ Object
Provide a loggable string to represent this sketch.
- #library_loaded?(library_name) ⇒ Boolean
- #post_initialize(_args) ⇒ Object
- #size(*args) ⇒ Object
- #sketch_class ⇒ Object
-
#start ⇒ Object
Set the size if we set it before we start the animation thread.
Methods included from HelperMethods
#blend_color, #buffer, #color, #constrain, #constrained_map, #dist, #find_method, #frame_rate, #grid, #java_self, #key, #key_pressed?, #lerp, #lerp_color, #load_strings, #map, #map1d, #max, #min, #mouse_pressed?, #norm, #proxy_java_fields, #save_strings, #set_sketch_path, #sketch_path, #thread
Constructor Details
#initialize(options = {}) ⇒ App
It is ‘NOT’ usually necessary to directly pass options to a sketch, it gets done automatically for you. Since processing-2.0 you should prefer setting the sketch width and height and renderer using the size method, in the sketch (as with vanilla processing), which should be the first argument in setup. Sensible options to pass are x and y to locate sketch on the screen, or full_screen: true (prefer new hash syntax)
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/ruby-processing/app.rb', line 102 def initialize( = {}) super() post_initialize() $app = self proxy_java_fields set_sketch_path # unless Processing.online? mix_proxy_into_inner_classes java.lang.Thread.default_uncaught_exception_handler = proc do |_thread_, exception| puts(exception.class.to_s) puts(exception.) puts(exception.backtrace.map { |trace| "\t#{trace}" }) close end run_sketch() end |
Class Attribute Details
.library_loader ⇒ Object
Handy getters and setters on the class go here:
63 64 65 |
# File 'lib/ruby-processing/app.rb', line 63 def library_loader @library_loader end |
.sketch_class ⇒ Object
Handy getters and setters on the class go here:
63 64 65 |
# File 'lib/ruby-processing/app.rb', line 63 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.
56 57 58 59 |
# File 'lib/ruby-processing/app.rb', line 56 def self.inherited(subclass) super(subclass) @sketch_class = subclass end |
.library_loaded?(library_name) ⇒ Boolean
71 72 73 |
# File 'lib/ruby-processing/app.rb', line 71 def library_loaded?(library_name) library_loader.library_loaded?(library_name) end |
.load_java_library(*args) ⇒ Object
79 80 81 |
# File 'lib/ruby-processing/app.rb', line 79 def load_java_library(*args) library_loader.load_java_library(*args) end |
.load_libraries(*args) ⇒ Object Also known as: load_library
65 66 67 68 |
# File 'lib/ruby-processing/app.rb', line 65 def load_libraries(*args) library_loader ||= LibraryLoader.new library_loader.load_library(*args) end |
.load_ruby_library(*args) ⇒ Object
75 76 77 |
# File 'lib/ruby-processing/app.rb', line 75 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.
85 86 87 88 |
# File 'lib/ruby-processing/app.rb', line 85 def method_added(method_name) #:nodoc: return unless METHODS_TO_ALIAS.key?(method_name) alias_method METHODS_TO_ALIAS[method_name], method_name end |
Instance Method Details
#close ⇒ Object
Cleanly close and shutter a running sketch.
144 145 146 147 148 |
# File 'lib/ruby-processing/app.rb', line 144 def close control_panel.remove if respond_to?(:control_panel) dispose frame.dispose end |
#inspect ⇒ Object
Provide a loggable string to represent this sketch.
139 140 141 |
# File 'lib/ruby-processing/app.rb', line 139 def inspect "#<Processing::App:#{self.class}:#{@title}>" end |
#library_loaded?(library_name) ⇒ Boolean
91 92 93 |
# File 'lib/ruby-processing/app.rb', line 91 def library_loaded?(library_name) self.class.library_loaded?(library_name) end |
#post_initialize(_args) ⇒ Object
128 129 130 |
# File 'lib/ruby-processing/app.rb', line 128 def post_initialize(_args) nil end |
#size(*args) ⇒ Object
119 120 121 122 123 124 125 126 |
# File 'lib/ruby-processing/app.rb', line 119 def size(*args) w, h, mode = *args @width ||= w @height ||= h @render_mode ||= mode import_opengl if /opengl/ =~ mode super(*args) end |
#sketch_class ⇒ Object
50 51 52 |
# File 'lib/ruby-processing/app.rb', line 50 def sketch_class self.class.sketch_class end |
#start ⇒ Object
Set the size if we set it before we start the animation thread.
133 134 135 136 |
# File 'lib/ruby-processing/app.rb', line 133 def start size(@width, @height) if @width && @height super() end |