Module: Processing

Defined in:
lib/ruby-processing.rb,
lib/ruby-processing/app.rb,
lib/ruby-processing/config.rb,
lib/ruby-processing/runner.rb,
lib/ruby-processing/runners/base.rb,
lib/ruby-processing/runners/watch.rb,
lib/ruby-processing/helper_methods.rb,
lib/ruby-processing/library_loader.rb,
lib/ruby-processing/exporters/creator.rb,
lib/ruby-processing/exporters/base_exporter.rb,
lib/ruby-processing/exporters/application_exporter.rb

Overview

More processing module

Defined Under Namespace

Modules: HelperMethods, Proxy Classes: App, ApplicationExporter, BaseExporter, BasicSketch, ClassSketch, Creator, Inner, LibraryLoader, Runner, SketchWriter, Watcher

Constant Summary collapse

RP_CONFIG =
{ 'PROCESSING_ROOT' => RP5_ROOT, 'JRUBY' => 'false' }
BARE_WRAP =

For use with “bare” sketches that don't want to define a class or methods

"class Sketch < Processing::App\n%s\nend\n"
NAKED_WRAP =
"class Sketch < Processing::App\ndef setup\nsize(DEFAULT_WIDTH, DEFAULT_HEIGHT)\n%s\nno_loop\nend\nend\n"

Class Method Summary collapse

Class Method Details

.load_and_run_sketchObject


35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/ruby-processing/runners/base.rb', line 35

def self.load_and_run_sketch
  source = read_sketch_source
  wrapped = !source.match(/^[^#]*< Processing::App/).nil?
  no_methods = source.match(/^[^#]*(def\s+setup|def\s+draw)/).nil?
  if wrapped
    run_app
    return
  end
  code = no_methods ? format(NAKED_WRAP, source) : format(BARE_WRAP, source)
  Object.class_eval(code, SKETCH_PATH, -1)
  Processing::App.sketch_class.new
end

.read_sketch_sourceObject

Read in the sketch source code. Needs to work both online and offline.


49
50
51
# File 'lib/ruby-processing/runners/base.rb', line 49

def self.read_sketch_source
  File.read(SKETCH_PATH)
end

.run_appObject

This method is the common entry point to run a sketch, bare or complete.


30
31
32
33
# File 'lib/ruby-processing/runners/base.rb', line 30

def self.run_app
    load SKETCH_PATH
    Processing::App.sketch_class.new unless $app
end