Skip to content
Martin Prout edited this page Aug 14, 2014 · 58 revisions

Read platform requirements here. New Mac users (OSX 9+) should follow this step by step installation guide.

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 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.

gem install ruby-processing
rp5 setup install # uses wget to download jruby-complete-1.7.13.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).

And voilà.

jwishy

See also examples from the Learning Processing book, check out Learning Processing with Ruby. Yet more samples are available for the Nature of Code book, also by Daniel Shiffman.

Making Your Own

Since the latest release bare sketches are preferred, although class wrapped sketches are still supported. 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

P3D sketches

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

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)

end


## Windows caveats
See also 

[[For Windows Users]]

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.