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

442<br />

Figure 10-29. Red Saturation sketch<br />

An easier way to add a tint or color overlay to an image is to use <strong>Processing</strong>’s tint() function.<br />

The function requires a color argument, which can be specified five different ways:<br />

gray, with or without alpha; RGB or RGBA color; or a single color value, using <strong>Processing</strong>’s<br />

color data type. In the next example, shown in Figure 10-30, I used an image the same size<br />

as the display window (600 ✕ 400 pixels):<br />

// Tint()<br />

size(600, 400);<br />

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

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

int tintAlpha = 255;<br />

int[][]cols = {<br />

{255, 0, 0, tintAlpha}, {255, 255, 0, tintAlpha},<br />

{0, 0, 255, tintAlpha}, {0, 255, 0, tintAlpha},<br />

{255, 0, 255, tintAlpha}, {255, 127, 0, tintAlpha}<br />

};<br />

int columns = 3;<br />

int w = width/columns;<br />

int h = cols.length;<br />

for (int i=0; i

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

Saved successfully!

Ooh no, something went wrong!