We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexDiscussionExhibition › Ruby on Acid...
Page Index Toggle Pages: 1
Ruby on Acid... (Read 596 times)
Ruby on Acid...
Dec 18th, 2009, 11:32pm
 
I hooked my Ruby-based library (which uses the Gang of Four strategy pattern to generate visuals) up to Ruby-Processing, with excellent results:


jay.mcgavren.com/blog/wp-content/uploads/2009/12/picture-8.png
jay.mcgavren.com/blog/wp-content/uploads/2009/12/picture-7.png
(Copy-paste the links to your address bar; my board permissions don't let me post links yet.)

It was pretty easy, too - the entire code is below.

Code:

require 'rubygems'
require 'ruby-processing'
require 'rubyonacid/factories/example'

class Sketch < Processing::App

 def setup
   @f = RubyOnAcid::ExampleFactory.new
   @resetter = RubyOnAcid::SkipFactory.new(0.9999)
   background 0
   smooth
   ellipse_mode CENTER
 end
 def draw
   100.times do
     fill(
       @f.get(:red, :max => 255),
       @f.get(:green, :max => 255),
       @f.get(:blue, :max => 255),
       @f.get(:alpha, :max => 255)
     )
     no_stroke
     ellipse(
       @f.get(:x, :max => width),
       @f.get(:y, :max => height),
       @f.get(:width, :max => 300),
       @f.get(:height, :max => 300)
     )
     @f.reset_assignments if @resetter.boolean(:reset)
   end
 end
 
end

Processing::SKETCH_PATH = ""

Sketch.new :title => "Ruby On Acid", :width => 1024, :height => 768, :full_screen => true


Ensure JRuby is installed (I haven't been able to get external libraries working with Ruby-Processing's included rp5 tool).  Then run "sudo jgem install ruby-processing rubyonacid" to install the JRuby gems.  Save the above code to "acid.rb" and type "jruby acid.rb" to run it.

This can definitely be taken a lot further - I haven't had a chance to play with most of Processing's capabilities.  If anyone on the board tries it out and encounters trouble, drop me a line and I'll see if I can help.
Page Index Toggle Pages: 1