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

36<br />

Java<br />

}<br />

this.y = y;<br />

this.wdth = wdth;<br />

this.ht = ht;<br />

this.fillCol = fillCol;<br />

/* check for stroke - if the last argument passed to the<br />

constructor is not -1 then use that value to set the<br />

stroke color. If it is -1, don't draw a stroke */<br />

if (strokeCol!=-1){<br />

this.strokeCol = strokeCol;<br />

stroke(strokeCol);<br />

}<br />

else {<br />

noStroke();<br />

}<br />

//drawRect method<br />

void drawRect(){<br />

//assign fill color<br />

fill(fillCol);<br />

// draw rectangle<br />

rect(x, y, wdth, ht);<br />

}<br />

}<br />

The other terms I threw at you earlier were “class files,” “compile,” “interpret,” <strong>and</strong> “Java<br />

Virtual Machine,” which I’ll define as I introduce Java <strong>and</strong> describe <strong>Processing</strong>’s special<br />

relationship to it.<br />

I want to cover a little of Java’s history (sorry), but I think you may find it somewhat interesting,<br />

especially as a lesson in the virtue of happy mistakes. I actually cover happy coding<br />

mistakes a little later on as well. Java’s history is also relevant in regard to a deeper underst<strong>and</strong>ing<br />

of <strong>Processing</strong>. Have I convinced you? Hope so.<br />

Java, originally named Oak, was developed in the early 1990s as a language to be used to<br />

program devices other than personal computers—things like microwave ovens with<br />

embedded processors—not terribly sexy stuff, but as you’ll see, pretty visionary. However,<br />

appliance manufacturers didn’t embrace the idea. So to save face, the Sun engineers went<br />

back to their drawing boards <strong>and</strong> came up with a plan to remarket Oak as a language to<br />

control “set-top boxes” for interactive TV. But alas, the cable companies passed on that idea<br />

as well. Things were not looking good for Oak. To make matters even worse, it was discovered<br />

that the name “Oak” had already been trademarked by another technology company.<br />

Before I tell you how Java was reborn out of this very inauspicious beginning, let me explain<br />

the basic problem the Sun engineers were trying to address in the design of Oak in the first<br />

place. Then you can try to guess (if it is not already obvious) what saved Java.

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

Saved successfully!

Ooh no, something went wrong!