06.01.2013 Views

Learning Processing: A Beginner's Guide to Programming Images ...

Learning Processing: A Beginner's Guide to Programming Images ...

Learning Processing: A Beginner's Guide to Programming Images ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

196 <strong>Learning</strong> <strong>Processing</strong><br />

Many of the chapters that follow will require the explicit use of external <strong>Processing</strong> libraries, such as video,<br />

networking, serial, and so on. Documentation for these libraries can be found on the <strong>Processing</strong> web site<br />

at http://www.processing.org/reference/libraries/ . Th ere, you will fi nd a list of libraries that come with<br />

<strong>Processing</strong> , as well as links <strong>to</strong> third party libraries available for download on the web.<br />

12.2<br />

Built-in Libraries<br />

Using a built-in library is easy because there is no installation required. Th ese libraries come with your<br />

<strong>Processing</strong> application. Th e list of built-in libraries (full list available at above URL) is not terribly long<br />

and all but a few are covered in this book as listed below.<br />

• Video —For capturing images from a camera, playing movie files, and recording movie files. Covered<br />

in Chapters 16 and 21.<br />

• Serial —For sending data between <strong>Processing</strong> and an external device via serial communication.<br />

Covered in Chapter 19.<br />

• OpenGL —For rendering a sketch with graphics acceleration. Covered in Chapter 14.<br />

• Network —For creating client and server sketches that can communicate across the internet.<br />

Covered in Chapter 19.<br />

• PDF —For creating high resolution PDFs of graphics generated in <strong>Processing</strong> . Covered in Chapter 21.<br />

• XML —For importing data from XML documents. Covered in Chapter 18.<br />

Examples specifi cally tailored <strong>to</strong>ward using the above libraries are found in the chapters listed. Th e<br />

<strong>Processing</strong> web site also has superb documentation for these libraries (found on the “ libraries ” page). Th e only<br />

generic knowledge you need regarding <strong>Processing</strong> built-in libraries is that you must include the appropriate<br />

import statement at the <strong>to</strong>p of your program. Th is statement will au<strong>to</strong>matically be added <strong>to</strong> the sketch if you<br />

select SKETCH → IMPORT LIBRARY. Or, you can simply type the code in manually (using the import<br />

library menu option does not do anything other than just add the text for the import statement).<br />

import processing.video.*;<br />

import processing.serial.*;<br />

import processing.opengl.*;<br />

import processing.net.*;<br />

import processing.pdf.*;<br />

import processing.xml.*;<br />

12.3<br />

Contributed Libraries<br />

Th e world of third party (also known as “ contributed ” ) libraries for <strong>Processing</strong> resembles the wild west.<br />

As of the writing of this book, there are 47 contributed libraries, with capabilities ranging from sound<br />

generation and analysis, <strong>to</strong> packet sniffi ng, <strong>to</strong> physics simulations, <strong>to</strong> GUI controls. Several of these<br />

contributed libraries will be demonstrated over the course of the remainder of this book. Here, we will<br />

take a look at the process of downloading and installing a contributed library.<br />

Th e fi rst thing you need <strong>to</strong> do is fi gure out where you installed <strong>Processing</strong> . On a Mac, the application<br />

is most likely found in the “ Applications ” direc<strong>to</strong>ry, on a PC, “ Program Files. ” We will make this<br />

assumption, but have no fear if you installed it somewhere else ( <strong>Processing</strong> can be installed in any direc<strong>to</strong>ry<br />

and will work just fi ne), just replace the path listed below with your own fi le path!<br />

Once you have determined where you installed <strong>Processing</strong> , take a look inside the <strong>Processing</strong> folder. See<br />

Figure 12.1 .

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!