Class: Propane::App

Inherits:
PApplet
  • Object
show all
Includes:
Math, MathTool, HelperMethods
Defined in:
lib/propane/app.rb

Overview

All sketches extend this class

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from HelperMethods

#blend_color, #buffer, #color, #dist, #find_method, #frame_rate, #grid, #hsb_color, #int_to_ruby_colors, #java_self, #kamera, #key, #key_pressed?, #lerp_color, #load_strings, #max, #min, #mouse_pressed?, #perspektiv, #save_strings, #thread, #web_to_color_array

Constructor Details

#initialize(options = {}, arguments = []) ⇒ App

Returns a new instance of App.

Raises:

  • (TypeError)


107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/propane/app.rb', line 107

def initialize(options = {}, arguments = [])
  # Guard against invalid input.
  proxy_java_fields
  raise TypeError unless options.is_a? Hash
  raise TypeError unless arguments.is_a? Array
  # Set up the sketch.
  super()
  $app = self
  @arguments = arguments
  @options   = options
  run_sketch
end

Class Attribute Details

.argumentsObject

Handy getters and setters on the class go here:



75
76
77
# File 'lib/propane/app.rb', line 75

def arguments
  @arguments
end

.library_loaderObject

Handy getters and setters on the class go here:



75
76
77
# File 'lib/propane/app.rb', line 75

def library_loader
  @library_loader
end

.optionsObject

Handy getters and setters on the class go here:



75
76
77
# File 'lib/propane/app.rb', line 75

def options
  @options
end

.sketch_classObject

Handy getters and setters on the class go here:



75
76
77
# File 'lib/propane/app.rb', line 75

def sketch_class
  @sketch_class
end

.titleObject

Handy getters and setters on the class go here:



75
76
77
# File 'lib/propane/app.rb', line 75

def title
  @title
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.



63
64
65
66
# File 'lib/propane/app.rb', line 63

def self.inherited(subclass)
  super(subclass)
  @sketch_class = subclass
end

.library_loaded?(library_name) ⇒ Boolean

Returns:

  • (Boolean)


83
84
85
# File 'lib/propane/app.rb', line 83

def library_loaded?(library_name)
  library_loader.library_loaded?(library_name)
end

.load_java_library(*args) ⇒ Object



91
92
93
# File 'lib/propane/app.rb', line 91

def load_java_library(*args)
  library_loader.load_java_library(*args)
end

.load_libraries(*args) ⇒ Object Also known as: load_library



77
78
79
80
# File 'lib/propane/app.rb', line 77

def load_libraries(*args)
  library_loader ||= LibraryLoader.new
  library_loader.load_library(*args)
end

.load_ruby_library(*args) ⇒ Object



87
88
89
# File 'lib/propane/app.rb', line 87

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.



97
98
99
100
# File 'lib/propane/app.rb', line 97

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

#data_path(dat) ⇒ Object



133
134
135
136
137
# File 'lib/propane/app.rb', line 133

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

#library_loaded?(library_name) ⇒ Boolean

Returns:

  • (Boolean)


103
104
105
# File 'lib/propane/app.rb', line 103

def library_loaded?(library_name)
  self.class.library_loaded?(library_name)
end

#size(*args) ⇒ Object



120
121
122
123
124
125
126
127
# File 'lib/propane/app.rb', line 120

def size(*args)
  w, h, mode = *args
  @width ||= w
  @height ||= h
  @render_mode ||= mode
  import_opengl if /opengl/ =~ mode
  super(*args)
end

#sketch_classObject



57
58
59
# File 'lib/propane/app.rb', line 57

def sketch_class
  self.class.sketch_class
end

#sketch_title(title) ⇒ Object



129
130
131
# File 'lib/propane/app.rb', line 129

def sketch_title(title)
  surface.set_title(title)
end