Experiments with ruby-processing (processing-2.2.1) and JRubyArt for processing-3.0

Tuesday, 16 December 2014

Experimenting with jruby-complete-SNAPSHOT-9.0.0.0 and ruby processing

Anyone wishing to explore ruby-2.1+ syntax with ruby-processing should get hold of jruby-complete-SNAPSHOT-9.0.0.0.jar (compile it yourself) rename the jar to jruby-complete.jar and manually replace the jruby-complete.jar in the ruby-processing gem (lives in lib/ruby folder). Gems typically live in .gem/ruby/2.1.0/gems folder depending on your system unless you use rvm or other such nasty stuff. To ensure jruby-complete use add 'JRUBY: false' to your ~/.rp5rc settings (or use the --nojuby flag). Also use watch rather than run to run sketches (to avoid the failure in draw loop bug). Here is a sketch I posted earlier using 2.1 syntax, but here I explore using 'format' to present rationals....
After experimentation you can easily restore the original jruby-complete by running 'rp5 setup install' (no download required since we keep copy of the original in the vendors folder).
def setup
  size 640, 250
  background 10
  f = createFont("Arial", 24, true)
  third = 1 / 3r     # since ruby 2.1.0
  quarter = 1 / 4r
  add = format("%s + %s = %s", third, quarter, third + quarter)
  subtract = format("%s - %s = %s", third, quarter, third - quarter)
  multiply = format("%s * %s = %s", third, quarter, third * quarter)
  text_font(f, 24)
  fill(220)
  text("Math blackboard ruby-processing", 80, 50)
  text(add, 110, 100)
  text(subtract, 110, 150)
  text(multiply, 110, 200)
end


PS: this one of the sketches not affected by draw loop bug. May'be we don't need to wait too long for a preview version?

No comments:

Post a Comment

Followers

About Me

My photo
I have developed JRubyArt and propane new versions of ruby-processing for JRuby-9.1.5.0 and processing-3.2.2