04.04.2013 Views

Processing: Creative Coding and Computational Art

Processing: Creative Coding and Computational Art

Processing: Creative Coding and Computational Art

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

PROCESSING: CREATIVE CODING AND COMPUTATIONAL ART<br />

154<br />

The Sketch menu contains the following six comm<strong>and</strong>s:<br />

Run (Cmd+R on OS X; Ctrl+R on Windows): Has the same functionality as the Run<br />

button on the toolbar.<br />

Present (Cmd+Shift+R on OS X; Ctrl+Shift+R on Windows): Creates a full-screen<br />

display of your executing sketch. The sketch window is centered against a neutral<br />

background. You can stop the display by selecting the Stop comm<strong>and</strong> in the lowerleft<br />

corner of the screen, or by pressing the Esc key.<br />

Stop: Stops a running sketch.<br />

Import Library: Adds a required import statement to the top of your sketch, allowing<br />

you to use the classes in the imported code library. The current core <strong>Processing</strong><br />

libraries (which can be selected from the Import Library drop-down menu) include<br />

the following:<br />

c<strong>and</strong>y<br />

dxf<br />

javascript<br />

net<br />

opengl<br />

pdf<br />

serial<br />

videos<br />

xml<br />

If you select Sketch ➤ Import Library ➤ opengl, then the following line of code is<br />

added to the top of your sketch: import processing.opengl.*;. Using import<br />

statements is st<strong>and</strong>ard practice in Java, for which related classes of code are<br />

grouped in directories called packages. Packages allow you to organize code<br />

libraries for reuse <strong>and</strong> distribution. They also provide a way of helping to ensure<br />

that class names don’t collide or interfere with one another. For example, if I create<br />

a class called Ball, <strong>and</strong> you create a class called Ball, <strong>and</strong> both of our classes<br />

are within a common code library, Java won’t know which one to use. We can solve<br />

this problem by putting each of our classes in a uniquely named package (directory)<br />

<strong>and</strong> then importing the package with the version of the Ball class we need.<br />

Then, even if we use both Ball classes, as long as the class files reside in their own<br />

distinctive packages, there will be no naming conflict.<br />

Show Sketch Folder (Cmd+K on OS X; Ctrl+K on Windows): Opens up the directory<br />

of your current sketch. Normally, your current sketch directory will reside within<br />

your main sketchbook directory. If you remember, your main sketchbook location<br />

is specified in the preferences.<br />

Add File: Opens a file navigator, allowing you to load an image, font, or other media<br />

into a data subdirectory within your sketch directory. If no data directory exists,<br />

<strong>Processing</strong> will automatically create one for you.

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

Saved successfully!

Ooh no, something went wrong!