-
Notifications
You must be signed in to change notification settings - Fork 0
Using the Processing API
All of the Processing methods, as explained in the Processing Language API, are available as instance methods on your Processing::App. (frame_rate, ellipse, and the 158 others.) This makes it easy as pie to use them within your sketch.
# Triangles gone wild def setup color_mode RGB, 1.0 frame_rate 30 fill 0.8, 0.6 smooth end def draw triangle(rand(width), rand(height), rand(width), rand(height), rand(width), rand(height)) end
Many methods that you might expect to find under their Processing names will be available by more Rubyish monikers. “keyPressed” becomes “key_pressed?”. And some things are better done with regular Ruby than with Processing; instead of using load_strings("file.txt") to read in a file, consider File.readlines("file.txt").
Because of this method madness, Processing::Apps have a convenience method for searching through them. $app.find_method("ellipse") will return a list of the method names that may match what you’re looking for: “ellipse”, “ellipseMode”, and “ellipse_mode”.