Skip to content
Martin Prout edited this page Dec 6, 2013 · 58 revisions

Read platform requirements here Before you start you might wish to install jruby on your system see here Building and installing from the cloned repo unix:-

git clone https://github.com/jashkenas/ruby-processing.git
cd ruby-processing
# optional step for bundler users
bundle install # can be used to tie ruby-processing to jruby, and installs build dependencies 
rake       # This builds, and tests the ruby-processing-2.3.1.gem (an external minitest is preferred)
jruby -S gem install ruby-processing-2.3.1.gem  # to install locally may need sudo access
# or if not using an installed jruby (or if you have a clever way of managing gem hell)
gem install ruby-processing-2.3.1.gem  # to install locally may need sudo access especially ubuntu

Windows user might prefer to use github for windows to clone repo, I'm not sure there is a rake-gui for windows, so some terminal work will be required.

Alternatively there is a zipped source for latest release here. Simply unzip/untar the archive in your local directory and use rake as described previously.

Ruby-Processing provides you with the rp5 command, which is what you'll use to run all the Ruby-Processing commands. Try typing rp5 --help to get a brief overview of the options. If you're ready to try out an example, then let's get started by unpacking the folder of samples so that you can examine and run them. Go to a folder where you'd like to store the samples, and type:

jruby -S rp5 unpack samples
jruby -S rp5 run samples/contributed/jwishy.rb

Or if not using an installed jruby

rp5 unpack samples
rp5 --nojruby run samples/contributed/jwishy.rb

Or if jruby is your default ruby, or you have smart ruby version control system

rp5 unpack samples
rp5 run samples/contributed/jwishy.rb

And voilà.

jwishy

See also examples from the Learning Processing book, check out Learning Processing with Ruby, and download the examples (note many of the sketches will need updating for processing-2.0, and the latest ruby-processing).

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

jruby -S rp5 create my_sketch --p3d 800 600

def setup
  size 800, 600, P3D  
end
  
def draw 

end

Windows caveats

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.

Clone this wiki locally