jruby -Djava.library.path="/home/tux/lib/linux64" trefoil.rbI needed to change the build to include the lwjgl jars and app.rb to accommodate the changes to processing but also unlike vanilla processing the sketch was also modified, replacing the applet convention of size(width, height, renderer) in setup with 3 methods (not required to be called in setup):-
# Old def setup size(1024, 768, P3D) end #New def sketch_width 1024 end def sketch_height 768 end def sketch_renderer P3D end
Here is a working 'bare' JAVA2D sketch (run using k9 run keyboard.rb) which was tested with jruby-complete-18.104.22.168.pre2.
def setup @num_chars = 26 @key_scale = 200.0 / @num_chars - 1.0 @rect_width = width / 4 no_stroke background 0 end def draw return unless key_pressed? && ('A'..'z').include?(key) key_index = key.ord - (key <= 'Z' ? 'A'.ord : 'a'.ord) fill millis % 255 begin_rect = map1d(key_index, (0..25), (0..width - @rect_width)) rect begin_rect, 0, @rect_width, height end def sketch_width; 640; end def sketch_height; 360; end def sketch_renderer; JAVA2D; end
Rubocop will complain of single line definition, but here I think it makes sense! The default renderer is currently JAVA2D, but it looks like Ben is having some success with JavaFX so that might change v. soon. It should be possible to use the java Class loader to set the java.library.path as we do in load_library, but this will probably require 'k9 run sketch', however there is work to be done to even run anything other than Java2D with k9. So presently I think I will concentrate on jruby-22.214.171.124 work.....
Allowing for Ben / Andrés to progress processing-3.0, before I waste any more time.
Warning this has all changed in favour of settings method, and defining renderer along with size as single line entry ie like processing-2.0 but in settings, not setup... furthermore jruby class loader reverted to original and the design of JRubyArt mirrored ruby-processing