A first Sketch
Requirements
Requires JRubyArt-1.3.1+ (hence jruby-9.0.8.0+) or propane-2.3.2+
Install the generative gem
jruby -S gem install geomerative # safe way
gem install geomerative # using rvm rbenv to use jruby instead of MRI
Create basic sketch
mkdir 'fred'
mkdir 'fred/data'
cp '/usr/share/fonts/TTF/FreeMono.ttf fred/data' # other fonts are available
# '/usr/share/fonts/TTF/LiberationMono-Bold.ttf' Mac and Windows paths differ
cd fred
k9 create fred 600 400
Edit sketch as follows:-
require 'geomerative'
# Declare the objects we are going to use, so that they are accessible from
# setup and from draw (use '@' prefix in declare)
attr_reader :grp
def setup
sketch_title 'Fred'
RG.init(self) # important
fill(255, 102, 0)
# you could also use absolute path for fonts, then no need to copy
@grp = RG.get_text('Hello World!', data_path('FreeMono.ttf'), 72, CENTER)
end
def draw
background(255)
translate(width / 2, height / 2)
grp.draw
end
def settings
size(600, 400)
end
See more refined examples here, and even more here including rotating text and text obeying physics.
Usage with propane is very similar see examples here