module Processing

The top-level namespace, a home for all JRubyArt classes.

A wrapper module for the processing App

The processing wrapper module

processing wrapper module

More processing module

Constants

BARE_WRAP

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

NAKED_WRAP
RP_CONFIG

Attributes

app[RW]
surface[RW]

Public Class Methods

load_and_run_sketch() click to toggle source

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

# 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 Processing.app
    return
  end
  name = RP_CONFIG.fetch('sketch_title', 'Naked Sketch')
  width = RP_CONFIG.fetch('width', 200)
  height = RP_CONFIG.fetch('height', 200)
  code = no_methods ? format(NAKED_WRAP, name, source, width, height) : format(BARE_WRAP, source)
  Object.class_eval code, SKETCH_PATH, -1
  Processing::App.sketch_class.new unless Processing.app
end
read_sketch_source() click to toggle source

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

# File lib/jruby_art/runners/base.rb, line 51
def self.read_sketch_source
  File.read(SKETCH_PATH)
end