Clone this wiki locally
Before you start you might wish to install jruby on your system see jruby site, you will also need to install vanilla processing preferably processing-2.2.1, although other versions up to processing-3.0a5 may also work). You will also need to set your
PROCESSING_ROOT in your
.rp5rc configuration file, this is easiest done by running the
configRP5.pde (see this gist) sketch from the vanilla processing ide and/or this blog entry for more details, and a manual alternative.
gem install ruby-processing rp5 setup install # uses wget to download jruby-complete-xxx.jar rp5 setup unpack_samples rp5 run rp_samples/contributed/jwishy.rb
Or if not using an installed jruby
rp5 setup unpack_samples rp5 --nojruby run rp_samples/contributed/jwishy.rb
To avoid using
--nojruby flag you could use
~/.rp5rc config file to set
JRUBY: false (since ruby-processing-2.5.0).
Making Your Own
In keeping with vanilla processing it is suggested you create "bare" sketches, although class wrapped sketches are also supported should you prefer.
Because every sketch has a
setup method, called once at the start, and a
draw method, called continuously as it animates; Ruby-Processing includes a sketch creator to get you started on the right foot with the proper (minimal) boilerplate. Using
rp5 create my_sketch 800 600, will generate a Processing::App that's 800 by 600 pixels in size, and just displays a blank window.
def setup size 800, 600 end def draw end
rp5 create my_sketch 800 600 p3d since ruby-processing-2.6.0
def setup size 800, 600, P3D end def draw end
Class wrapped sketches
Since ruby-processing-2.6.5 make sure you call new, or your class wrapped sketch will not run!!!
rp5 create my_sketch 800 600 --wrap
# my_sketch.rb class MySketch < Processing::App def setup size 800, 600, P3D end def draw end end MySketch.new(x: 10, y: 30)
Let's say you want to run a more complex app using processing:
require_relative "lib/custom_libs.rb" require_relative "my_processing_app.rb" MyProcessingApp.new x:50, y:50
Running that with
rp5 run won't work, because it will try to wrap the code, like the native Processing does. In that case you can do
rp5 run-app file.rb. This way, it skips the
wrapping functions, assuming that you took care of this.
You may not have
wget installed, if so you can download the jar into the
vendors folder, before running
rp5 setup install use
rp5 setup check to check your configuration.
Gem install didn't seem to create environment variable RP5_ROOT upon which ruby-processing depends. Adding this environment variable to the path of the gem seemed to do the trick. If you're getting some errors where you don't know what's going on this might be the issue. For permanent solution amend your .rp5rc configuration file.