Class: Processing::SketchBase
- Inherits:
-
PApplet
- Object
- PApplet
- Processing::SketchBase
show all
- Defined in:
- lib/processing/sketch_base.rb
Overview
The base class of a Processing sketch
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of SketchBase.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
23
24
25
|
# File 'lib/processing/sketch_base.rb', line 23
def method_missing(name, *args)
self.class.__send__(name, *args) if PApplet.public_methods.include?(name)
end
|
Class Method Details
.method_added(name) ⇒ Object
14
15
16
17
18
19
20
21
|
# File 'lib/processing/sketch_base.rb', line 14
def self.method_added(name)
name = name.to_s
if name.include?('_')
lcc_name = name.split('_').map(&:capitalize).join('')
lcc_name[0] = lcc_name[0].downcase
alias_method lcc_name, name if lcc_name != name
end
end
|
Instance Method Details
#frame_rate(fps = nil) ⇒ Object
36
37
38
39
|
# File 'lib/processing/sketch_base.rb', line 36
def frame_rate(fps = nil)
return get_field_value('frameRate') unless fps
super(fps)
end
|
#get_field_value(name) ⇒ Object
27
28
29
|
# File 'lib/processing/sketch_base.rb', line 27
def get_field_value(name)
java_class.declared_field(name).value(to_java(PApplet))
end
|
#key ⇒ Object
41
42
43
44
|
# File 'lib/processing/sketch_base.rb', line 41
def key
code = get_field_value('key')
code < 256 ? code.chr : code
end
|
#key_pressed? ⇒ Boolean
46
47
48
|
# File 'lib/processing/sketch_base.rb', line 46
def key_pressed?
get_field_value('keyPressed')
end
|
#mouse_pressed? ⇒ Boolean
50
51
52
|
# File 'lib/processing/sketch_base.rb', line 50
def mouse_pressed?
get_field_value('mousePressed')
end
|