09.04.2016 Views

www.ebook777.com

Make_Getting_Started_with_Processing_Second_Edition

Make_Getting_Started_with_Processing_Second_Edition

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

PImage img;<br />

void setup() {<br />

size(480, 120);<br />

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

}<br />

void draw() {<br />

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

}<br />

Optional fourth and fifth parameters set the width and height to<br />

draw the image. If the fourth and fifth parameters are not used,<br />

the image is drawn at the size at which it was created.<br />

These next examples show how to work with more than one<br />

image in the same program and how to resize an image.<br />

Example 7-2: Load More Images<br />

For this example, you’ll need to add the capsule.jpg file (found in<br />

the media folder you downloaded) to your sketch using one of<br />

the methods described earlier:<br />

PImage img1;<br />

PImage img2;<br />

void setup() {<br />

size(480, 120);<br />

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

Media 91

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

Saved successfully!

Ooh no, something went wrong!