06.01.2013 Views

Learning Processing: A Beginner's Guide to Programming Images ...

Learning Processing: A Beginner's Guide to Programming Images ...

Learning Processing: A Beginner's Guide to Programming Images ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

0<br />

1<br />

2<br />

3<br />

4<br />

5<br />

6<br />

7<br />

8<br />

9<br />

fi g. 1.9<br />

<strong>to</strong>p left (5,5)<br />

0 1 2 3 4 5 6 7 8 9<br />

bot<strong>to</strong>m right (8,7)<br />

rectMode (CORNERS)<br />

rect (5,5,8,7);<br />

bot<strong>to</strong>m right y<br />

Pixels 7<br />

Once we have become comfortable with the concept of drawing a rectangle, an ellipse is a snap. In fact, it<br />

is identical <strong>to</strong> rect( ) with the diff erence being that an ellipse is drawn where the bounding box 1 (as shown<br />

in Figure 1.11 ) of the rectangle would be. Th e default mode for ellipse( ) is “ CENTER ” , rather than<br />

“ CORNER ” as with rect( ) . See Figure 1.10 .<br />

<strong>to</strong>p left<br />

x<br />

<strong>to</strong>p left<br />

y<br />

bot<strong>to</strong>m right x<br />

0 1 2 3 4 5 6 7 8 9<br />

0 1 2 3 4 5 6 7 8 9<br />

0<br />

0<br />

1<br />

1<br />

2<br />

2<br />

3<br />

3<br />

4 ellipseMode (CENTER); 4<br />

5<br />

ellipse (3,3,5,5); 5<br />

6<br />

6<br />

7<br />

7<br />

8<br />

8<br />

9<br />

9<br />

0 1 2 3 4 5 6 7 8 9<br />

0<br />

1<br />

2<br />

3<br />

4<br />

5<br />

6<br />

7<br />

8<br />

9<br />

fi g. 1.10<br />

ellipseMode (CORNERS);<br />

ellipse (5,5,8,7);<br />

ellipseMode (CORNER);<br />

ellipse (3,3,4,4);<br />

It is important <strong>to</strong> acknowledge that in Figure 1.10 , the ellipses do not look particularly circular. <strong>Processing</strong><br />

has a built-in methodology for selecting which pixels should be used <strong>to</strong> create a circular shape. Zoomed<br />

in like this, we get a bunch of squares in a circle-like pattern, but zoomed out on a computer screen,<br />

we get a nice round ellipse. Later, we will see that <strong>Processing</strong> gives us the power <strong>to</strong> develop our own<br />

1 A bounding box of a shape in computer graphics is the smallest rectangle that includes all the pixels of that shape. For example, the<br />

bounding box of a circle is shown in Figure 1.11 .

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

Saved successfully!

Ooh no, something went wrong!