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 />

150<br />

Export (Cmd+E on OS X; Ctrl+E on Windows): Creates a Java applet of your sketch<br />

<strong>and</strong> places it within an “applet” subdirectory, inside your current sketch directory.<br />

Once this subdirectory is created, <strong>Processing</strong> opens it up for you, displaying five<br />

files, which I’ll discuss in a moment. Applets are Java programs that can be viewed<br />

in any Java-enabled browser, which includes most modern browsers. These<br />

browsers have a built-in Java interpreter, more commonly known as the JVM. Java<br />

programs can run as applets or as st<strong>and</strong>-alone applications on the desktop.<br />

However, the source code is not identical for applets <strong>and</strong> applications, so it does<br />

take a little work to convert an applet to an application <strong>and</strong> visa versa—that is, if<br />

you’re not using <strong>Processing</strong>. <strong>Processing</strong> includes the ability to export both Java<br />

applets <strong>and</strong> st<strong>and</strong>-alone Java applications.<br />

The applet subdirectory contains these five files:<br />

index.html: The HTML page you load into the browser, with the embedded<br />

applet.<br />

yourfilename.pde: Your original processing file.<br />

yourfilename.jar: A JAR (Java Archive) file, which is downloaded <strong>and</strong> run by<br />

the browser’s virtual machine. It contains the <strong>Processing</strong> core classes, other custom<br />

classes, <strong>and</strong> any media files (images, fonts, etc.) residing within the “data”<br />

subdirectory of your sketch directory. Since everything within the subdirectory<br />

is packed into the JAR file when you export, you should remove unneeded data<br />

from the subdirectory before exporting. If your sketch doesn’t use any external<br />

media, you don’t need a data subdirectory.<br />

yourfilename.java: A Java file created by <strong>Processing</strong> from the main sketch<br />

(PDE) file. Java files are compiled by the JVM into bytecode (class files). These<br />

class files get packed into the JAR file.<br />

loading.gif: The artwork initially shown as your page loads; it’s replaced by the<br />

applet when it’s loaded.<br />

Finally, if you’re running <strong>Processing</strong> in OS X, there are three places in which you can alter<br />

the <strong>Processing</strong> window structure (as shown in Figure 5-2). Some of these adjustments can<br />

be made in Windows as well. You can drag the bar between the text editor <strong>and</strong> message<br />

area up <strong>and</strong> down to resize the window panes. You can resize the entire <strong>Processing</strong> application<br />

window by dragging the lower-right corner of the window. The “collapse panes”<br />

buttons (OS X) work as follows: if the window is in its default state, showing both the text<br />

editor <strong>and</strong> the message area, clicking the up arrow exp<strong>and</strong>s the message area while collapsing<br />

the text editor, <strong>and</strong> the down arrow does the opposite.<br />

File menu<br />

This menu is pretty straightforward, <strong>and</strong> most of it should be self-explanatory. In Figure 5-4,<br />

the Sketchbook submenus are exploded. Please note that in Windows, the <strong>Processing</strong><br />

menu is contained within the <strong>Processing</strong> application window, while in OS X, the menu system<br />

is separate from the <strong>Processing</strong> application. Aside from appearances, the two menus<br />

on the different platforms have identical functionality <strong>and</strong> comm<strong>and</strong> sets.

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

Saved successfully!

Ooh no, something went wrong!