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

452<br />

blend() <strong>and</strong> filter()<br />

There are two other powerful Photoshop-esque imaging functions in <strong>Processing</strong>’s toolbox:<br />

blend() <strong>and</strong> filter(). These functions each do so much that they could easily have been<br />

divided into a bunch of separate functions. They’re built upon some very low-level<br />

coding—mostly using bitwise operations—<strong>and</strong> were developed as a group effort, with<br />

considerable contributions by Karsten Schmidt (a.k.a. toxi) (www.toxi.co.uk/) <strong>and</strong> Mario<br />

Klingemann (www.quasimondo.com/). If you’d like to take a look at the actual source<br />

code implementation (to better appreciate toxi <strong>and</strong> Klingemann’s efforts), check out<br />

<strong>Processing</strong>’s PImage class at http://dev.processing.org/source/index.cgi/trunk/<br />

processing/core/src/processing/core/PImage.java?view=markup.<br />

I do, however, have some (small) misgivings about these functions being included in<br />

<strong>Processing</strong>, as they so deeply encapsulate very low-level processing, <strong>and</strong>—not unlike<br />

Photoshop—can become easy targets for fast, uninformed effects. In this sense, I feel their<br />

ease of use <strong>and</strong> power actually have the potential to limit creativity. For example, here’s a<br />

sketch that uses the filter function to invert an image (see Figure 10-36). Please remember<br />

to add an image into your data directory for all the examples prior to using loadImage(),<br />

as in the previous examples.<br />

// INVERT Filter<br />

// image should be 600 x 400 pixels<br />

size(600, 400);<br />

background(255);<br />

PImage img = loadImage("view.jpg");<br />

image(img,0,0);<br />

filter(INVERT);<br />

Figure 10-36. INVERT Filter sketch

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

Saved successfully!

Ooh no, something went wrong!