Automatically Reload your Sketch with
k9 --watch will keep an eye on the source files (*.rb and *.glsl only) of your sketch. Whenever you save a change to it, it’ll reload your running code, so you can try out your ideas quickly.
k9 --watch is the best way to quickly prototype a sketch. To guard against you running watch in a top level folder we limit the number of files to
watch to 20, but you can set a different limit in ~/.jruby_art/config.yml
MAX_WATCH: 100. However the safest thing to do is make sure that you use watch from a custom folder to avoid
watching non-sketch code. See Joanne Cheng video for a demo of the ruby-processing watch mode. See Wiki for true live mode with pry.
k9 --create simple 300 300 k9 --watch simple.rb # NB don't :!k9 --watch % from vim
In another console (or use other editor)
def setup sketch_title 'Simple' end def draw end def settings size 300, 300 # pixel_density(2) # here for hi-dpi displays only # smooth # here end
Add a red ellipse to draw loop and save (sketch reloads automatically)
def draw fill 200, 0, 0 ellipse 150, 150, 200, 100 end
Set background blue and save (sketch reloads automatically)
def draw background 0, 0, 200 fill 200, 0, 0 ellipse 150, 150, 200, 100 end
If you declare constants in your sketch you may wish to define them this way
CONSTANT ||= 'some value' to avoid getting the
warning: already initialized constant when the sketch re-loads.