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

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

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

23<br />

23.1<br />

Java<br />

“ I l o ve c off ee, I love tea, I love the Java Jive and it loves me. ”<br />

—Ben Oakland and Mil<strong>to</strong>n Drake<br />

In this chapter:<br />

– <strong>Processing</strong> is really Java.<br />

– If we did not have <strong>Processing</strong> what would our code look like?<br />

– Exploring the Java API.<br />

– Some useful examples: ArrayList, and Rectangle.<br />

– Exception (error) handling—try and catch.<br />

– Beyond <strong>Processing</strong> ?<br />

Revealing the Wizard<br />

Java 423<br />

Perhaps, all along while reading this book, you have been thinking: “ Gosh, this is so awesome. I love<br />

programming. I am so glad I am learning <strong>Processing</strong> . I can’t wait <strong>to</strong> go on and learn Java! ” Th e funny thing<br />

is, you do not really need <strong>to</strong> learn Java. Pulling back the curtain of <strong>Processing</strong> , what we will discover is that<br />

we have been learning Java all along. For example, in Java, you:<br />

• Declare, initialize, and use variables the same way.<br />

• Declare, initialize, and use arrays the same way.<br />

• Employ conditional and loop statements the same way.<br />

• Define and call functions the same way.<br />

• Create classes the same way.<br />

• Instantiate objects the same way.<br />

<strong>Processing</strong> , of course, gives us some extra stuff for free (and simplifi es some stuff here and there) and this<br />

is why it is a great <strong>to</strong>ol for learning and for developing interactive graphics projects. Here is a list of some<br />

of what <strong>Processing</strong> off ers that is not as easily available with just plain Java.<br />

• A set of functions for drawing shapes.<br />

• A set of functions for loading and displaying text, images, and video.<br />

• A set of functions for 3D transformations.<br />

• A set of functions for mouse and keyboard interaction.<br />

• A simple development environment <strong>to</strong> write your code.<br />

• A friendly online community of artists, designers, and programmers!<br />

23.2<br />

If we did not have <strong>Processing</strong> , what would our code look like?<br />

In Chapter 2, we discussed the compilation and execution process—this is what happens when you<br />

press the play but<strong>to</strong>n and turn your code in<strong>to</strong> a window with graphics. Step 1 of this process involves<br />

“ translating ” your <strong>Processing</strong> code in<strong>to</strong> Java. In fact, when you export <strong>to</strong> applet, this same process<br />

occurs and you will notice that along with the fi le “ Sketchname.pde, ” a new fi le will appear named

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

Saved successfully!

Ooh no, something went wrong!