Skip to content

Building latest gem

Martin Prout edited this page May 30, 2016 · 83 revisions

Clone this repository

Install maven (ruby-2.1+ is assumed to be installed)

maven-3.3.3+

jdk1.8.0_92+ can be openjdk with OpenJFX a separate download works on ArchLinux

cd JRubyArt

rake

Regular Minitests tests should run and pass, but the sketch tests will fail without the optional configuration, which will be needed runtime:-

Optional Configuration ( but required for installation )

You should install processing-3.1.1 and the video library independently (maven central only has 3.0.2) furthermore the sketch tests will not run without them and a valid config.yml. You probably also want to install want to install jruby-9.1.2.0+, but in case you don't add JRUBY: 'false' to config.yml.

NB: You will need to edit the pom.rb properties to match your 'processing.core' and 'processing.sketchbook' paths on your system.

Config file is config.yml in ~/.jruby_art folder so can co-exist with a ruby-processing install

Typical linux version

# 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.1.1
sketchbook_path: /home/tux/sketchbook3
# JRUBY: 'false'

Typical macosx version

# YAML configuration file for jruby_art
# K9_HOME: "/home/ruby2.2.0 ... /jruby_art" #windows users may need to set this
PROCESSING_ROOT: /Applications/Processing.app/Contents/Java
sketchbook_path: # (as set by user in processing ide or see preferences.txt)
MAX_WATCH: 30

warning: if you used homebrew to install processing prefix /Application with your home directory, we need path to jars, symbolic links to executable wont do...

Steps

 rake      # compiles and builds rpextras (from source) depends on config, before building gem
 gem install --local jruby_art-1.1.2.gem
 k9 setup install # Downloads and install jruby-complete-9.1.2.0

Create sketches from built in templates

k9 create fred 200, 200               # basic 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

Simple Sketch

# :sketch_title belongs in setup it is a convenience method of jruby_art
def setup
  sketch_title 'My Sketch'
end

def draw
  background 0
  fill 200
  ellipse width / 2, height / 2, 300, 200
end

# size goes here since processing-3.0, the processing guys hide this
# by doing pre-processing on the pde file (check the java output).
def settings
  size 400, 300
end

Run Sketch

k9 run sketch.rb or k9 --nojruby run sketch.rb

be prepared to KILL the 'rare' java process (that doesn't exit cleanly all the time), watch seems now to work

Watch sketches

k9 watch sketch.rb # don't try and change render mode, or use the FX2D render mode

Example sketches

Worked Examples more to follow, feel free to add your own, especially ruby-2.2+ syntax now we can. These can now be downloaded using k9 setup unpack_samples please move existing rp_samples.

Conversion Tool

I wrote this little script to convert sketches from ruby-processing (processing-2) to jruby_art (processing-3.0) here

Javadocs RPExtras

The javadocs for rpextra can be generated as follows:-

mvn javadoc:javadoc # see target site

But here is link to already created javadocs note links to jruby and processing api...