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.

Figure 10-28. Pixilate sketch<br />

The next sketch loads two copies of an image into the display window <strong>and</strong> increases the<br />

right image’s red saturation. Remember, the loadPixels() function call collects the display<br />

window pixel data, assigning it to the display window pixels[] array (not the<br />

img.pixels[] array). After making some changes to the pixels[] array, I need to call<br />

updatePixels() to have the changes actually updated within the display window. In the<br />

example, I’m using a 400 ✕ 400 pixel image <strong>and</strong> an 800 ✕ 400 pixel display window (see<br />

Figure 10-29):<br />

//Red Saturation<br />

size(800, 400);<br />

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

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

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

int threshold = 125;<br />

loadPixels();<br />

for(int j=0; j

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

Saved successfully!

Ooh no, something went wrong!