You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Martin Prout edited this page Apr 14, 2015
·
6 revisions
Processing inner classes
Regular processing makes much use of java "inner classes" to make PApplet methods and variables available to the inner classes (with ruby-processing you can include Processing::Proxy module to achieve a similar result.
JRubyArt
Since JRubyArt version 0.2.5.pre Processing::Proxy module provide similar access, but now implemented using :method_missing to access PConstants, also include PConstants (or use PConstants::). However you can use ruby forwardable instead, to produce an even more elegant solution (inmho). See Node class below:-
require'forwardable'classNode < Physics::VerletParticle2DextendForwardabledef_delegators(:@app,:fill,:stroke,:stroke_weight,:ellipse)definitialize(pos)super(pos)@app= $app
end# All we're doing really is adding a display function to a VerletParticledefdisplayfill(50,200,200,150)stroke(50,200,200)stroke_weight(2)ellipse(x,y,16,16)endend
To be even more kosher you could replace the global $app via an extra initialize argument.