The Shoebox. A place for lil' apps to live in peace and harmony.

This is no Shoes app. This is a Ruby wrapper that lets you harness Processing’s awesome power. It makes Processing act in a slightly more Shoes-like way, and replaces the ol’ crusty faux-Java-1.4-syntax sandals that Processing usually wears with some new Ruby slippers.

For complete and thorough instructions on how to get started, how to load libraries, how to do live coding, how to export for the web, how to create Mac applications, and all that, you’ll have to check out…

The Wiki

It’s usually best to grab the latest code, as it often has improvements over the releases that can be found here.

What’s new in 0.9

  • Inspired by NodeBox, Ruby-Processing now sports the ability to have sliders control numeric variables in your sketches. If you’re using an instance variable, say, @speed, to control the speed of your sketch.
    has_slider :speed

    Will bring up a panel alongside with a slider that controls the speed. It can take a range of values as an optional parameter. Check out and run jwishy.rb for an example.

  • Multi-platform app export! Exporting your Ruby-Processing apps will now create executable apps for Mac/Windows/Linux.
  • Live coding support. Now you can do script/live path/to/sketch.rb to open up an interactive session with your sketch available as @app.
  • Nick Sieger donated an additional sample.

Speak now or forever hold your peace:

omygawshkenas
February 28, 2008

It’s only been tested on the Mac so far, so reports about success or failure on other platforms would be welcome.

meekish
February 29, 2008

I used Processing for some motion graphics a while back. It’s an awesome tool, but writing verbose Java to quickly hack up little visual experiments seems paradoxical. Ruby-Processing is an awesome idea. I hope it is very successful!

Jesse
February 29, 2008

I know nothing about processing, but lemme try this all out on WinXP:

I put jruby in a place. I put processing in another place. I put ruby_processing.rb into the lib/ruby/1.8 folder in jruby.

I ran # jruby jwishy.rb, it complained about not being able to find processing. I modifed the default path from ruby_processing.rb line 11.

Then I get this error:

Jesse@LAPUTA$ jruby jwishy.rb cygpath: can’t convert empty path C:/Program Files/Common Files/jruby/lib/ruby/1.8/ruby-processing.rb:13: no such file to load—/cygdrive/c/Program Files/Common Files/processing/lib/core (Load Error) from jwishy.rb:1 from jwishy.rb:1:in `require’ from jwishy.rb:1

Line 13 is trying to load the core.jar file, and the core.jar file is there, so I’m not sure what the complaint is here.

Mikkel Bo Rasmussen
February 29, 2008

I also get the LoadError of core.jar

Here is my setup on a PowerBook G4 running OSX 10.4.11:

mikkelbo ~/Processing (35)$ ls /Applications/Processing/lib/core* /Applications/Processing/lib/core.jar mikkelbo ~/Processing (36)$ which jruby /Users/mikkelbo/src/jruby-1.0.1/bin/jruby mikkelbo ~/Processing (37)$ ll total 24 rw-r-r— 1 mikkelbo mikkelbo 869 Feb 28 23:19 jwishy.rb rw-r-r— 1 mikkelbo mikkelbo 590 Feb 28 23:19 reflection.rb rw-r-r— 1 mikkelbo mikkelbo 1779 Feb 29 15:24 ruby-processing.rb mikkelbo ~/Processing (38)$ java -version java version “1.5.0_13” Java™ 2 Runtime Environment, Standard Edition (build 1.5.0_13-b05-241) Java HotSpot™ Client VM (build 1.5.0_13-121, mixed mode, sharing)

The error is:

mikkelbo ~/Processing (40)$ jruby reflection.rb ./ruby-processing.rb:13: IO error—/Applications/Processing/lib/core (LoadError) from reflection.rb:5 from reflection.rb:5:in `require’ from reflection.rb:5

Any clue where the problem/fix is?

omygawshkenas
February 29, 2008

I just ran through, and it works fine on Windows, but there’s problems with finding and loading Processing’s core.jar.

If anything is unable to load, try looking in ruby-processing.rb, and making sure that the correct path is getting passed in (the whole thing is tiny — it shouldn’t be too hard to patch.)

I’m going to fix up a platform compatible version of the puppy, and upload it later today. Making sure that the correct path is getting require’d will work until then.

omygawshkenas
February 29, 2008

Okay, new version’s up. It includes the beating heart of Processing, so you don’t actually have to download Processing to use this. I’ve tested it on the Mac and on Windows, and it works like a charm.

Stephen
February 29, 2008

It works nicely on my MacBook Pro. But ‘ish is sloooow. You can do some nice static graphics with that but realtime is a non, non, non.

Check the performance of my tiny Hello World…

require ‘ruby-processing’

class Hello < Processing::App end

def setup
    puts "Oi, Oi" 
end
def draw
    load_pixels        
    pixels.each_with_index { |e, i| pixels[i]=color(rand(255)) }    
    update_pixels
end

Hello.new(:width => 200, :height => 200, :title => “Hello World” )

Thanks anyways!

omygawshkenas
February 29, 2008

Yeah, it is, indeed, quite slow compared to vanilla Processing. But there’s no funny method_missing or other kinds of indirection happening, so it’s probably as fast as a JRuby-Processing bridge can be — and will improve in speed as JRuby speeds up (especially with calls into native Java).

Justin
March 1, 2008

It works on Ubuntu (7.04). Looking forward to future versions. Thanks!

Charles Oliver Nutter
March 1, 2008

A substantial part of the perf overhead is known bottlenecks in our Java Integration layer. Those aren’t scheduled to be fixed until after the 1.1 final release (which still focuses on raw Ruby performance) but fixed they shall be. I expect Java Integration issues to fall like dominos once 1.1 is out the door.

Very nice use of JRuby with Processing. Thank you!

Jesse
March 1, 2008

Yay, it works on WinXP. :)

But I don’t know how to use processing. What capabilities has it? As a shoes developer, I cannot make sense of the processing documentation at processing.org. I don’t see where to start.

Jesse
March 1, 2008

Ignore that last documentation request, I figured it out. It’s just that the table of contents has names like “how to add 2+2” and “what’s a function” making it look like a basic programmers tutorial (!= what I wanted) however the chapters cover high level api decisions simultaneously.

I think I can work this thing. :)

Jesse
March 1, 2008

If this is successful, you’ll want to make a seperate shoebox category for jruby/processing apps. :]

Joe Holt
March 2, 2008

I added a translation of CircleCollision from the Processing Topics pages…

http://processing.org/learning/topics/circlecollision.html

Joe Holt
March 2, 2008

Added a modified version of CircleCollision that draws more than two circles. I changed things around in the code to make it more in the spirit of Ruby.

Joe Holt
March 2, 2008

Translation of the tree example from Processing Topics.

http://processing.org/learning/topics/tree.html

I won’t post any more—don’t want to clutter this page with Ruby+Processing programs. But I’m finding it extremely informative to port the demos and fiddle with them. I A/B’d the tree program and found that the Ruby performance was about 90% that of Java+Processing (had them running side by side on an Intel Mac).

I’ve started a wiki page about my efforts and encourage others to contribute.

http://wiki.bennington.edu/wiki/Ruby+Processing

Kris Leech
March 2, 2008

**:~/Desktop/ruby-processing$ jruby ./samples/jwishy.rb ./ruby-processing.rb:12:in `require’: no such file to load—home//Desktop/ruby-processing/core (LoadError) from ./ruby-processing.rb:12 from ./samples/jwishy.rb:2 from ./samples/jwishy.rb:2:in `require’ from ./samples/jwishy.rb:2

ruby-processing 0.2 Ubuntu Gibson JRuby 1.8.5 Java 1.6

omygawshkenas
March 3, 2008

Version 0.4 is up, with fullscreen support. I’ve tested it on Mac and Windows, but if someone could let me know if fullscreen works on Linux, that would be grand.

omygawshkenas
March 9, 2008

Version 0.5 is up, which helps you load Processing libraries (even native ones) easier.

ian
March 13, 2008

the iPhods may use J2ME later or sooner, so i wondered if there is a path to the iPhods in this, or if work is needed, what bridges are needed. ?

omygawshkenas
March 13, 2008

H’mmm, that’s a good question. I heard that the Java guys were just getting started on the iPhone version of Java. So I think we’ll have to wait until they’re done, and then we’ll see.

omygawshkenas
March 20, 2008

Ey! Ruby-Processing 0.6 is up. It’s got an applet_tree for growing applets. Check ‘em out

Remco
March 29, 2008

Very nice!

A few findings in combination with the opengl library. The rest worked out of the shoebox!

Suggestion: The opengl library needed a new directory so libraries/opengl and for me it only worked when I placed the jar files there (maybe good to add in the instructions)

Than still two problems (maybe related) if I tried full_screen sample may mac only shows a black screen and I am not able to get it out of the way so I can only do a hard restart.

Therefore I changed the programm to not displaying full screen (setting :false_screen false), but then I found there is a problem with not able to find library PGraphicsOpenGL, I did not found a quick solution and searching the internet I found (omygawshkenas and headius) in a small discussion. I could not figure out if that discussion solved the issue or not. Did you find a solution? Thanks, Remco

omygawshkenas
March 29, 2008

Hey Remco: I can’t duplicate the problems that you’re having — If I download Ruby-Processing 0.6 and drop the opengl library into the library folder, full_screen.rb just works.

And I’ve certainly never seen it lock up the system: hitting escape can bring it out of the full-screen.

I’d appreciate it if you’d email me your zipped up install, and I’ll take a look. (Address is in the shoebox at the bottom).

Matthew Kanwisher
March 30, 2008

Haha ok this is awesome ;) I’m definitely working on some stuff using this! Finally Processing with a killer language!

omygawshkenas
March 31, 2008

Remco and I worked out his issue: If you want to use a Processing library, make sure to drop the entire folder into your library directory. Otherwise it’s easy to miss stray jars.

Xavier Shay
April 14, 2008

yes yes yes. I am excited to find this. Processing is the only java I’ve done in years, and I couldn’t stop thinking “if only this was ruby”.

Peter
May 19, 2008

I love the instance variable slider in v0.9, it works great! I had problems with loading images, though: there doesn’t seem to be a way to load images from a “data” folder like in Processing, I could only load the image by its full path. Is that so or did I do wrong?

omygawshkenas
May 20, 2008

Peter —

Data folders work just fine. It’s only that they’re relative to the root of the app, so you have to put a single data folder in your main Ruby-Processing directory. When you export applets or applications, the data folder will get sucked in.

Iain
May 21, 2008

This is great. It combines 2 of my favourite toolsets.

Is there a mailing list or some such forum where I can ask lots of stupid questions?

omygawshkenas
May 21, 2008

Iain —

There isn’t on official forum (yet), but if you have a question that you’d think would be useful information for everyone, please feel free to add a page to the Wiki and ask it there.

Otherwise, shoot me an email:

jeremy (at) ashkenas (dot) com

Iain
May 24, 2008

What is the best way to create self contained classes? For example If i want to create a class for a Ball that can be reused in a number of Processing apps, how would I do this?

I have looked at the samples and seen 2 approaches:

One is to use a global object ‘P’ which is a subclass of Processing::App. This global object is used to make all the calls to the Processing API.

The other approach seems to be to declare subclasses inside the body of the class definition for the application.

Neither of these approaches seems particularly elegant or reusable.

omygawshkenas
May 24, 2008

For self-contained classes, you can either do the global constant thing, or pass a reference to the sketch to any class that needs to draw with it…

But your question speaks to the larger problem of reusing behavior/objects across sketches, and the best way to do that is with a library. If you make a ruby library, say “Balls” and drop it into the library folder, every sketch will be able to load it with:

load_ruby_library 'balls'

Check out the included 'boids' library for an example of how to do this.

sandip
May 29, 2008

Hi, whenever i try to run CircleCollision.rb or jwishy.rb on windows using ruby script/open samples/xyz , I get an error: script/open:1: Cant exec \bin\bash (fatal)

Im relatively new to ruby. SOS!

PS: Im using instant rails on xp.

omygawshkenas
May 30, 2008

Heya Sandip.

For windows, since there’s no shell, you have a Ruby version of the open script. Give this a try:

ruby script/open.rb samples/circle_collision.rb

rndrfero
June 1, 2008

hej friends, got solution for this: http://pastie.caboo.se/191445/wrap ??? (i am on mac os x with ruby 1.8.6 (2008-04-22 rev 6555) [i386-jruby1.1.1] )


How do I use this?