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

Thursday, 28 November 2013

Ruby-processing on MacOSX, Apple or Oracle JVM

UPDATED 1 February 2014 ruby-processing-2.4.2 (is now available as a rubygem)

Now this is entirely theoretical as I've exceptionally limited experience with a MAC (I once loaded some photos on my Artist friends MAC). However, from what I understand if you update to Mavericks, you won't have java installed.  The ideal solution from my point of view, is that this forces you to install Oracle jdk1.7.0_51 (64 bit). However apparently if you are conservative, or otherwise need it, apparently you can get Apple jvm here.


For OSX users incapable of using google, for some reason following link may be helpful stackoverflow it may even encourage you to do the sensible thing and install the Oracle jvm?

But what does this mean for ruby-processing on MacOSX:

Use processing-2.0.3 especially if you are sticking with Apple jvm (Mavericks or otherwise)
Step by step instruction to install of the latest version of ruby-processing:-

  1. Install jruby (at least version 1.7.3 but preferably 1.7.10)
  2. Install processing-2.0.3, or if not on Mavericks you could try processing-2.1.1 & jdk7
  3. Run the processing sketch here to set the path to the processing root
  4. gem install ruby-processing
  5. install_jruby_complete
  6. cd your work directory
  7. rp5 unpack samples
  8. cd samples/contributed
  9. rp5 run grapher.rb (or jwishy.rb or whatever)
Please report how you get on since if I can establish that this is working OK we will be able to return to ruby-gems distribution. If you don't have a system installed jruby, all sketches you would need to use the --nojruby flag to use the vendored jruby-complete eg

rp5 --nojruby run grapher.rb

Here is another link that might be useful re installing jdk7.

Monday, 25 November 2013

Running Ruby Processing from Netbeans-7.4

Hey this is a bit exciting I've managed to get ruby processing to run under Netbeans just checkout this screen shot:-

Wednesday, 20 November 2013

A Rakefile to demo ruby-processing samples

Loosely based on a Shoes4 Rakefile, here is a Rakefile to demo ruby-processing files in a folder:-

# Simple demo Rakefile to autorun samples

SAMPLES_DIR="/home/tux/samples/contributed"

desc 'run demo'
task :default => [:demo]

desc 'demo'
task :demo do
  samples_list.shuffle.each{|sample| run_sample sample}
end

def samples_list
  files = []
  Dir.chdir(SAMPLES_DIR)
  Dir.glob("*.rb").each do |file|
    files << File.join(SAMPLES_DIR, file)
  end
  return files
end

def run_sample(sample_name)
  puts "Running #{sample_name}...quit to run next sample"
  system "rp5 run #{sample_name}"
end

Bleeding edge development of ruby-processing

I have just set myself up to do bleeding edge testing of ruby processing.

  1. To use the latest development version of jruby-complete I created this rake file.
  2. To use the latest development version of processing I cloned it from github.
  3. Did a linux build.
  4. Modified my .rp5rc to point PROCESSING_ROOT to the work folder (3)
To keep it separate I created a copy of my monkstone-branch to develop (taking care to remove the .git archive).
Update December 10th see a more recent blog entry for latest developments.

Tuesday, 19 November 2013

Testing the GLW renderer with ruby-processing

Andreas Colubri is working on an alternative renderer for processing (which seems to be stabilising as the GLW renderer). Here is an example sketch translated to ruby-processing requires processing-2.1.1 to run (OK development version as that is not currently available).
load_library :glw

include_package 'processing.glw'

def setup
  size(2560, 1440, GLW::P2D)
  frame_rate(180) # NB: here we are using the "processing" set frame rate method
end

def draw
  background(255, 0, 0)
  fill(255)
  # NB: here we access "processing" frame rate variable 
  text("FPS: #{frame_rate}", mouse_x, mouse_y)
end

Tuesday, 12 November 2013

Working towards returning ruby-processing to gem distribution by rubygems.org

I have made the first steps toward returning ruby-processing to rubygems distribution. See my fork on github. This is work in progress, however it does work on Archlinux, and also should also work on the MAC, where the path to the processing jars should be stable?

  1. Install processing-2.1.0 (for your OS)
  2. Create or edit the YAML .rp5rc file to point to processing-root possibly using the sketch below (in the processing ide) config.pde
  3. Clone my fork
  4. cd ruby-processing (or whatever you call it)
  5. rake (MAC and linux) to see if tests work
  6. gem install ruby-processing-{version}.gem for more comprehensive testing
Currently for ease of testing we still include jruby-complete download as option, but it is not required for many sketches, intention is it will be available as a post install option.
String processingRoot = "enter your processing root here"; // edit this line in the sketch
String home;
PFont font;

void setup() {
  size(400, 200);
  font = createFont("Helvetica", 18);
  home = System.getProperty("user.home");
}

void draw() {
  background(255);
  fill(255, 0, 0);
  textFont(font, 18);
  // this adds a blinking cursor after your text, at the expense of redrawing everything every frame
  text(processingRoot+(frameCount/10 % 2 == 0 ? "_" : ""), 35, 45);
}

void keyReleased() {
  if (key != CODED) {
    switch(key) {
    case BACKSPACE:
      processingRoot = processingRoot.substring(0, max(0, processingRoot.length()-1));
      break;
    case ENTER:   // save the processing root to the config file
    case RETURN:
      PrintWriter pw = createWriter(home + "/.rp5rc");
      pw.write("PROCESSING_ROOT: \"" + processingRoot + "\"");
      pw.close();
      break;
    case ESC:
    case DELETE:
      break;
    default:
      processingRoot += key;
    }
  }
}

Saturday, 2 November 2013

Promise for the future of jruby, ruby-processing

It was probably a bit too early when I last looked at tuning ruby processing, because it preceded the processing-2.1 release (now compiled for java 7, which means I can run ruby-processing with java 8). Also since I am looking to the future I will use jruby-9000.dev for future performance tests. The esfera test is good because it is dynamic (you can actually see both compiler and garbage collector kick-in, well thats unless I'm very much mistaken). Here are past results combined with current results using jruby-complete-9000.dev (2 November 2013 snapshot). On continued running current test stabilised at ca 6 fps. What the test doesn't show is elapsed time, because there is actual pause seen when I presume compiler kicks in (and the later lesser dips in performance must be the garbage collector). These are my java args for the test (jdk 7 unless stated)
 java_args.txt
  • None 
  • Args 1.  -XX:+TieredCompilation XX:CompileCommand=dontinline,org.jruby.runtime.invokedynamic.InvokeDynamicSupport::invocationFallback
  • Args 2. -XX:+TieredCompilation -XX:TieredStopAtLevel=1 XX:CompileCommand=dontinline,org.jruby.runtime.invokedynamic.InvokeDynamicSupport::invocationFallback
  •  Args Java 8 -Xms2048M -Xmx2048M -XX:+UnlockExperimentalVMOptions -XX:G1NewSizePercent=20 -XX:G1MaxNewSizePercent=80.
F.P.S esfera
No Args Args 1 Args 2 Java 8
5.4547 5.17617 4.70084 5.27
4.26695 3.71662 2.90269 4.24
3.85179 3.22197 2.30053 3.889
3.769622 3.105720 2.077115 3.70
3.769622 3.122121 2.022429 4.15
3.756052 3.340643 1.940190 4.98
4.849481 3.122121 1.953019 5.03
5.173814 3.34064 5.09

PS: linux users it may also be worth doing the following, one-time exercise, to improve java startup
sudo java -Xshare:dump

For Rails Hackers

I'm a bit disappointed so far with the response to my updating of ruby-processing to run with processing-2.1. Perhaps interest in the ruby language is on the decline, or could it be that rails hackers have become so dependent on their frameworks/tools they find it a challenge to work outside them (I mean just look at Shoes4 lots of meaningless tests many contributors, and it is travelling at snails pace to where? _why is surely less than impressed)!!! For inspiration just check out the Karsten Schmidt story.

Eyeo 2013 - Karsten Schmidt from Eyeo Festival on Vimeo.

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