Class: Ribiprocessing::SimpleApp
- Inherits:
-
PApplet
- Object
- PApplet
- Ribiprocessing::SimpleApp
- Defined in:
- lib/ribiprocessing/simple_app.rb
Overview
This class is the base class the user should inherit from when making their own sketch.
i.e.
class MySketch < SimpleApp
def draw
background rand(255)
end
end
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#draw ⇒ Object
This method is the main draw loop of the sketch.
-
#initialize(options = {}, arguments = []) ⇒ SimpleApp
constructor
SimpleApp should be instantiated with an optional list of options and array of arguments.
-
#run_sketch ⇒ Object
This method runs the processing sketch.
-
#setup ⇒ Object
This method provides the default setup for the sketch.
Constructor Details
#initialize(options = {}, arguments = []) ⇒ SimpleApp
SimpleApp should be instantiated with an optional list of options and array of arguments.
SimpleApp.new(width: 500, height: 500, headless: true)
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ribiprocessing/simple_app.rb', line 29 def initialize ={}, arguments=[] # Guard against invalid input. raise TypeError unless .is_a? Hash raise TypeError unless arguments.is_a? Array # Set up the sketch. super() @arguments = arguments @options = configure_sketch run_sketch end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
22 23 24 |
# File 'lib/ribiprocessing/simple_app.rb', line 22 def arguments @arguments end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
22 23 24 |
# File 'lib/ribiprocessing/simple_app.rb', line 22 def @options end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
22 23 24 |
# File 'lib/ribiprocessing/simple_app.rb', line 22 def title @title end |
Instance Method Details
#draw ⇒ Object
This method is the main draw loop of the sketch. This must be overridden by the user.
53 54 55 |
# File 'lib/ribiprocessing/simple_app.rb', line 53 def draw raise "please define a draw method on the SimpleApp subclass." end |
#run_sketch ⇒ Object
This method runs the processing sketch.
59 60 61 |
# File 'lib/ribiprocessing/simple_app.rb', line 59 def run_sketch PApplet.run_sketch(arguments, self) end |
#setup ⇒ Object
This method provides the default setup for the sketch. It can be overridden by the user for finer grained control.
44 45 46 47 48 |
# File 'lib/ribiprocessing/simple_app.rb', line 44 def setup width = .fetch(:width, 800) height = .fetch(:height, 640) size(width, height) end |