- Notifications
You must be signed in to change notification settings - Fork 0
Using Contributed Processing Libraries
Install regular processing, if you have not already done so ( this is highly recommended for users of external processing libraries, for Mac users can even use the downloaded binary in the vendors folder, to install vanilla processing ). Since processing-2.0 it is possible to install many [Contributed][] libraries directly via the processing ide (see [Contributed][] where some [Legacy][] libraries are also listed). Other processing libraries should be manually installed following the [Legacy][] libraries instructions. However some [Legacy][] and other libraries may need updating to work with processing-2.0 (and hence ruby-processing-2.0+).
You can simply load_library or load_libraries to load the required libraries (if installed as above), will also either need to java_import, or sometimes it is better to include_package to access the java classes. It can alos be convenient to create a module to access these packages via a module as below. Read more about calling java from ruby at the [JRuby Wiki][].
load_libraries'simutils','toxiclibscore','colorutils'moduleToxiinclude_package"toxi.sim.grayscott"include_package"toxi.math"include_package"toxi.color"endUsing the toxiclibs example above, we created a Toxi namespace by creating a Toxi module. To access the named color constants we need to use :: not the dot separator.
@tone_map=Toxi::ToneMap.new(0,0.33,Toxi::NamedColor::CRIMSON,Toxi::NamedColor::WHITE,256)Also see the many included [External Library][] examples, which should help to get you started
Processing libraries built according to the [Build Instructions][] need to be initialized with the instance of the processing PApplet. So for example to use PeasyCam in processing:-
PeasyCammyCam = newPeasyCam(this, 100); // this is the PApplet instance For ruby-processing you should replace this with self:-
@my_cam=PeasyCam.new(self,100)Some library builders like to do it differently so for the fisica library this becomes:-
Fisica.init(self)If you get a method/variable missing message when using JRuby-Complete (instead of using installed jruby via the --jruby flag) it might be worth trying to run the sketch using an external jruby. This is the case for the fisica library (which has a lazily "protected" abstract class which is "invisible" when using JRuby-Complete). [Build Instructions]:https://github.com/processing/processing/wiki [Jruby Wiki]:https://github.com/jruby/jruby/wiki/CallingJavaFromJRuby/ [Contributed]:http://processing.org/reference/libraries/ [Legacy]:http://wiki.processing.org/w/How_to_Install_a_Contributed_Library [External Library]:https://github.com/jashkenas/ruby-processing/tree/master/samples/external_library/java_processing