Skip to content
Martin Prout edited this page Jul 29, 2015 · 28 revisions

Automatically Reload your Sketch with k9 watch

k9 watch will keep an eye on the source file 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.

Live Coding

Ruby-Processing is a playground for live coding. Sketches can be loaded into an interactive code session (pry) using k9 live. Once your sketch is running, the full powers of Ruby meta-programming are there for you to use. Methods and classes can be redefined on the fly, arguments passed, values changed and all that.

>> k9 live contributed/jwishy.rb
[1] pry(#<Sketch>)> def bluish
[1] pry(#<Sketch>)*   sin(y_wiggle)
[1] pry(#<Sketch>)* end  
=> :bluish
[2] pry(#<Sketch>)> @back_color = 0.5, 0.5, 0.5
=> [0.5, 0.5, 0.5, 0.5]

This opens up the Wishy Worm example in a window, and redefines the bluish method to return a function of the y_wiggle. The blue begins to pulse. We then set background color by changing the `back_color variable, you also need to move alpha slider to 0.03 or so to get the following look to your sketch:-

jwishy pic

To view a bunch of methods available ls in the pry console, pry aficionados will know more..

Clone this wiki locally