Module: Processing

Defined in:
lib/jruby_art.rb,
lib/jruby_art/app.rb,
lib/jruby_art/config.rb,
lib/jruby_art/runner.rb,
lib/jruby_art/runners/base.rb,
lib/jruby_art/runners/watch.rb,
lib/jruby_art/helper_methods.rb,
lib/jruby_art/library_loader.rb,
lib/jruby_art/creators/creator.rb

Overview

processing wrapper module

Defined Under Namespace

Modules: HelperMethods, Proxy, Render Classes: App, BasicSketch, ClassSketch, Creator, EmacsSketch, Inner, LibraryLoader, Runner, SketchWriter, WatchException, Watcher

Constant Summary collapse

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\n  def setup\n    sketch_title 'Nude Sketch'\n    %s\n    no_loop\n  end\n\n  def settings\n    size(150, 150)\n  end\nend\n"

Class Method Summary collapse

Class Method Details

.load_and_run_sketchObject

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



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/jruby_art/runners/base.rb', line 33

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
    load SKETCH_PATH
    Processing::App.sketch_class.new unless $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.



48
49
50
# File 'lib/jruby_art/runners/base.rb', line 48

def self.read_sketch_source
  File.read(SKETCH_PATH)
end