-
Notifications
You must be signed in to change notification settings - Fork 89
Sketch Watching and Live Coding
h2. Automatically Reload your Sketch with rp5 watch
rp5 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. rp5 watch
is the best way to quickly prototype a sketch, ( note currently this does not work for either P2D or P3D sketches, but should be returning with processing-2.1.2, since development version is working ).
h2. Live Coding
Ruby-Processing is a playground for live coding. Sketches can be loaded into an interactive code session (IRB) using rp5 live
. Once your sketch is running, the full powers of Ruby metaprogramming are there for you to use. Methods and classes can be redefined on the fly, arguments passed, values changed and all that. $app
will give you a handle to the running sketch. Use it like so:
>> rp5 live samples/jwishy.rb
irb(main):001:0> def $app.bluish
irb(main):002:1> Math.sin(@y_wiggle)
irb(main):003:1> end
irb(main):004:0> $app.background = 0.5, 0.5, 0.5, 0.035
This opens up the WishyWorm example in a window, and redefines the bluish
method to return a function of the y_wiggle
. The blue begins to pulse. Then the background is set to be a mostly transparent gray. For ruby-processing-1.0.11 pry was reported as working. It also seems to work with current version but it is a bit flakey in my hands.