A suitable version of ruby (MRI ruby > 2.1 or
jruby-220.127.116.11 to download gem.
jdk1.8.0_60+ can be openjdk with OpenJFX a separate download works on ArchLinux probably safer to go with the Oracle version, currently FX2D is experimental is expected to replace JAVA2D in the near future see changes above...
recommended installs (JRubyArt is currently hard-coded to expect them)
processing video and sound libraries best installed from the processing-3.0 ide
Config file is
config.yml in the
~/.jruby_art folder so can co-exist with a ruby-processing install
# YAML configuration file for jruby_art # K9_HOME: "/home/ruby2.2.0 ... /jruby_art" #windows users may need to set this PROCESSING_ROOT: /home/tux/processing-3.0 # important sketch_book path may be different for processing-3.0 sketchbook_path: /home/tux/sketchbook
Install Steps (assumes you have requirements above)
gem install jruby_art k9 setup install # installs jruby-complete-18.104.22.168 k9 setup unpack_samples # downloads and installs samples to ~/k9_samples cd ~/k9_samples/contributed k9 --nojruby run jwishy.rb # unless you have jruby-22.214.171.124 installed or config JRUBY: 'false' k9 run jwishy.rb # if you have jruby-126.96.36.199 installed or config JRUBY: 'false'
Create sketches from built in templates
k9 create fred 200, 200 # basic FX2D sketch fred.rb k9 create fred 200, 200, p2d # basic P2D sketch fred.rb k9 create fred 200, 200 --wrap # class wrapped FX2D sketch fred.rb k9 create fred 200, 200, p2d --wrap # class wrapped P2D sketch fred.rb k9 create ted 200, 200 --emacs # class wrapped sketch ted.rb for emacs / netbeans k9 create ted 200, 200, p2d --emacs # class wrapped P2D sketch ted.rb for emacs / netbeans
# :sketch_title belongs in setup it is a convenience method of jruby_art-3.0 def setup sketch_title 'My Sketch' end def draw background 0 fill 200 ellipse width / 2, height / 2, 300, 200 end # NB: changes for processing-3.0 # size, full_screen, pixel_density and smooth should all be moved to settings (this is hidden # to users of processing ide, but not for JRubyArt, or for Eclipse NetBeans users). The FX2D # rendering mode was introduced, and was expected to replace JAVA2D (as default rendering mode) # but may not now happen, and not for processing-3.0 in any case. def settings size 400, 300, FX2D end
k9 run sketch.rb
k9 --nojruby run sketch.rb
be prepared to KILL the odd java process (that doesn't exit cleanly all the time), watch seems now to work
k9 watch sketch.rb # don't try and change render mode, or use FX2D render mode during watch yet
Open pry console on sketch
k9 live sketch.rb # pry is bound to $app # needs `jruby -S gem install pry`
Worked Examples more to follow, feel free to add your own, especially ruby-2.1+ syntax now we can. These can now be downloaded using
k9 setup unpack_samples please move existing k9_samples.
I wrote this little script to convert sketches from ruby-processing (processing-2) to jruby_art (processing-3.0) here.
See The-Nature-of-Code-Examples-in-Ruby converted to The-Nature-of-Code-Examples-for-JRubyArt using the script.