Propane
A slim layer to communicate with Processing from JRuby, features a polyglot maven build, this started out as a non serious project by Phillip Cunningam called ribiprocessing. It has now morphed into an experimental project for ruby-processing so we can now "Cook with Gas". We have created a configuration free version of ruby processing, albeit tied to processing-2.2.1, where we get processing core from maven central (and opengl currently testing on linux64/mac). These jars are small enough to include in the gem distribution, and hence we should not require configuration. This has created a mainly scriptable version, ie files get run direct from jruby. However (as with ruby-processing/JRubyArt) certain sketches need to call jruby via jruby-complete, for this we have created an executable propane that can also be used to install jruby-complete as well as run sketches (maybe export?, possibly watch).
Requirements
- jdk8+ since version 0.6.0
- jruby-9.0.5.0+
- mvn-3.3.1+ (development only)
Building and testing
rake
rake gem
rake javadoc
Installation
jgem install propane-{version}-java.gem # local install
jgem install propane --pre # from rubygems.org, drop --pre once there is a regular released version
Usage
require 'propane'
class FlashingLightsSketch < Propane::App
attr_reader :random_background
def initialize opts={}
@random_background = opts.fetch :random_background, RandomBackground.new(self)
super
end
def setup
size(800, 600)
end
def draw
random_background.generate
end
end
class RandomBackground
include Propane::Proxy
def generate
background(rand(255), rand(255), rand(255))
end
end
FlashingLightsSketch.new title: "Flashing Lights"
Many sketches will run just using an installed jruby, but shader sketches must be run using jruby-complete, but don't worry we make it easy, to install jruby-complete:
propane --install
There is a handy sketch creator tool
propane -c my_sketch 200 200 # for default renderer
propane -c my_sketch 200 200 p2d # for opengl 2D renderer
propane -c my_sketch 200 200 p3d # for opengl 3D renderer
NB: will not overwrite existing sketch with the same name eg my_sketch.rb above
To run sketches using the installed jruby-complete, you can also use shortform -r
propane --run my_sketch.rb # or
jruby -S propane --run my_sketch.rb # belt and braces version