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

Saturday, 10 May 2014

Exploring ruby-2.1.2 syntax in ruby-processing

To run the following sketch you need to be using jruby-9000 (the development version of jruby which supports ruby 2.1.0 syntax out of the box), here I am actually used JRubyArt the development version of ruby-processing (that uses jruby-9000 by default). This sketch uses the very concise syntax for rationals in ruby-2.1.0 (fractions for the masses)
def setup
  size 640, 250
  background 10
  f = createFont("Arial", 24, true)
  third = 1 / 3r     # since ruby 2.1.0
  quarter = 1 / 4r
  add = "#{third} + #{quarter} = #{third + quarter}"
  subtract = "#{third} - #{quarter} = #{third - quarter}"
  multiply = "#{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


 
Update 16th November, after a long hiatus the sketch is now working again with jruby 9000.dev-SNAPSHOT (2.1.2p142) 2014-11-08 8a13045 OpenJDK 64-Bit Server VM 24.65-b04 on 1.7.0_65-b32 +jit [linux-amd64]. Unfortunately not many others sketches will currently run...

No comments:

Post a Comment

Followers

Blog Archive

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