Processing libraries are extra packages that you can add to your sketch for extra functionality. One of the great advantages of the strong Processing user base is that many libraries have been contributed to the project which offer the end-users (you) endless possibilities for expanding and upgrading their applications.
Processing comes with a handful of core libraries, such as Serial and OpenGL, but all contributed libraries must be downloaded and installed in order to use them. Libraries are packaged in a JAR file and usually come in a directory structure similar to <package-name>/library/<package-name>.jar. This directory tree must be placed in the path/to/Processing/libraries/ folder in order to be recognized by the Processing IDE.
To use a specific library in a sketch, we need to include its classes in our source. The easiest way to do this is to select the appropriate library name from the Processing menu bar under Sketch/Import Library.... This will add an import statement at the top of the code, which tells Processing to look for class definitions in this additional package.
Each package consists of a few classes, each with its specific attributes and methods, much like the Pulse and Soldier classes we have already defined. Most libraries have a webpage with examples and documentation that you should read to make sure you understand how to use them. We will now cover a few libraries and go through simple examples to get started.
- proXML: A library for reading/writing XML and loading/saving XML files.
- Video / JMyron: Libraries for displaying and analyzing video feeds.
The following libraries are also very useful and interesting. Their websites are complete with documentation and examples to get you started.
- Easing: A Processing implementation of Robert Penner's easing equations.
- Physics: A fast and easy to use physics library. It supports particles, springs, gravity, and drag, but no collisions.
- Sonia: A library for sound playback and audio synthesis. The sounds used can either be loaded from disk or recorded live from an input source.
- controlP5: A complete collection of GUI elements (such as buttons, knobs, sliders, etc.) with easy to implement event handling.
The following two links are shameless plugs for libraries I have been working on.