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

468<br />

Figure 10-49. PImage blend() Method LIGHTEST Mode—R<strong>and</strong>om Source<br />

Coodinates & save() sketch<br />

An object-oriented approach<br />

Before concluding the chapter, I’d like to apply an OOP approach to a color/imaging<br />

example (shown in Figure 10-50) that extends some of the OOP concepts looked at in the<br />

last two chapters. In Chapter 9, you used OOP to create a little neighborhood of houses<br />

composed of a number of component classes. The classes shared certain characteristics<br />

<strong>and</strong> had a number of redundant instance variables <strong>and</strong> methods. For example, the Door,<br />

Window, Roof, <strong>and</strong> House classes all had x, y, width, <strong>and</strong> height properties, as well as their<br />

own drawing methods. In programming, you usually try to avoid creating redundant elements.<br />

OOP includes some advanced concepts <strong>and</strong> language structures for minimizing<br />

redundancy <strong>and</strong> creating efficient, modular, <strong>and</strong> hopefully reusable classes. One of these<br />

key concepts is called inheritance, which I introduced in Chapter 8.

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

Saved successfully!

Ooh no, something went wrong!