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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

PROCESSING: CREATIVE CODING AND COMPUTATIONAL ART<br />

148<br />

When you create a new tab, you’ll be prompted to give it a name. <strong>Processing</strong> requires PDE<br />

<strong>and</strong> Java file names to begin with a letter or underscore <strong>and</strong> contain no spaces. You may<br />

use numbers in the name after the initial character, <strong>and</strong> names should be no more than 64<br />

characters in length. If you try to name a PDE or Java file using an illegal character,<br />

<strong>Processing</strong> will rename your file automatically, converting the illegal character to an<br />

underscore. For example, the name function 1 will be renamed function_1. In addition,<br />

you have the option of adding a .pde or .java suffix. If no suffix is added, <strong>Processing</strong><br />

assumes the new file is of type PDE. You won’t see the .pde suffix displayed in the tabs, but<br />

if you look in your project directory, you’ll see it there. If you specify .java as a suffix, then<br />

the file should be a st<strong>and</strong>ard Java file, <strong>and</strong> you should see the .java suffix in the tab;<br />

although the suffix doesn’t come up at the bottom of the tabs pop-up menu.<br />

Any other suffix you add will be removed <strong>and</strong> appended to the root of the name, <strong>and</strong> the<br />

file will be of type PDE. For example, if you accidentally try to save your sketch with the<br />

name newfilename.ppe, the full file name will be converted to newfilename_ppe.pde.<br />

Again, in the tab, you’ll only see the newfilename_ppe part. Finally, if you hide a tab, it<br />

does more than just temporarily change the tab’s visibility. When you run or export your<br />

project, if a tab is hidden, then the file associated with the tab will not be compiled or<br />

included in the applet subdirectory. The Hide function is a convenient way to ensure that<br />

classes <strong>and</strong> functions not being used in your final sketch do not unnecessarily bloat your<br />

program when you compile. If you accidentally hide a tab, but still reference it in your<br />

code, the compiler will give you an error—either “No accessible method,” for a missing<br />

function; or “Type . . . was not found,” for a missing class. If you look in your sketch directory<br />

(see Figure 5-3), you’ll notice that hidden files get appended with .x after the .pde or<br />

.java suffix.<br />

Figure 5-3. Screen capture of a <strong>Processing</strong> sketch directory

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

Saved successfully!

Ooh no, something went wrong!