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.

lend() PImage Method sketch<br />

// both PImages should be 300 x 400 pixels<br />

size(300, 400);<br />

PImage img1 = loadImage("airport.jpg");<br />

PImage img2 = loadImage("towers.jpg");<br />

img2.blend(img1, 0, 0, 300, 400, 0, 0, 300, 400, DARKEST);<br />

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

Figure 10-43. Simple blend() sketch<br />

Notice in the first sketch code (the function version of blend()), I didn’t need to explicitly<br />

call image() to draw the blended image to the screen; while in the second example, which<br />

uses the PImage method version of blend(), I did need to call image() to see the blended<br />

image.<br />

In the next two sketches, I’ll reuse the last blend() function example, changing the source<br />

image coordinates in the first example <strong>and</strong> then the destination image coordinate values<br />

in the second (see Figures 10-44 <strong>and</strong> 10-45):<br />

COLOR AND IMAGING<br />

461<br />

10

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

Saved successfully!

Ooh no, something went wrong!