Philip Cunningham music, code and stuff.

Ribiprocessing: A really slim layer between JRuby and Processing 09 February 2013

I'm taking a class called Generative Creativity this semester and thought it'd be nice to use Ruby for my project. There's already an option out there to use Processing from Ruby, ruby-processing, but it seemed really heavyweight for my needs and there doesn't seem to be a very stable way to use it with Ruby 1.9.3 mode. I'll probably expand ribiprocessing as the class progresses.

Installation

Add this line to your application's Gemfile:

gem 'ribiprocessing'

And then execute:

$ bundle

Or install it yourself as:

$ gem install ribiprocessing

Usage

require 'ribiprocessing'

class FlashingLightsSketch < Ribiprocessing::SimpleApp

  attr_reader :random_background

  def initialize(opts={})
    @random_background = opts[:random_background] || RandomBackground.new(self)
    super
  end

  def setup
    size 800, 600
  end

  def draw
    random_background.generate
  end

end

class RandomBackground
  include Ribiprocessing::Proxy

  def generate
    background rand(255), rand(255), rand(255)
  end

end

FlashingLightsSketch.new({:title=>"Flashing Lights"})