Getting Started

All that you need to get Ruby-Processing going is Ruby and Java, and your machine probably came with both of those. Then, naturally, you’ll need to get your hands on Ruby-Processing itself. Download the cutting-edge version. Unzip that and keep it ready-to-hand. It’s easiest to sketch by storing your projects inside of the Ruby-Processing folder. The release comes with a variety of samples that you can run:

cd /path/to/ruby-processing

script/open samples/jwishy.rb

# Or, if you're on windows:
ruby script/open.rb samples/jwishy.rb

And voilĂ .

Making Your Own

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 generator to get you started on the right foot with the proper (minimal) boilerplate. Using script/generate my_sketch 800 600, will generate a Processing::App that’s 800 by 600 pixels in size, and just displays a blank window. The generated my_sketch.rb will look like:

require 'ruby-processing'

class MySketch < Processing::App

  def setup

  end

  def draw

  end

end

MySketch.new :title => "My Sketch", :width => 800, :height => 600

Automatically Reload your Sketch with script/watch

script/watch will keep an eye the source file of your sketch. Whenever you save a change to it, it’ll reload your running sketch, so you can try out your ideas quickly.

Sliders!

Inspired by Nodebox, Ruby-Processing provides a way to control the instance variables of your sketch with sliders. Doing:

class SliderTest < Processing::App
  has_slider :alpha
  has_slider :quantity, 0..100

  # Rest of the code follows
end

Will create a sketch with a control panel for adjusting the value of the @alpha and @quantity instance variables. Alpha will range from 0.0 to 1.0 by default, and quantity’s slider will go from 0.0 to 100.0. It looks like this:

Last edited by jashkenas, 2 months ago
Versions: