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.

vertex(120, 120);<br />

vertex(20, 118);<br />

//complex quad<br />

vertex(175, 40);<br />

vertex(275, 30);<br />

vertex(170, 118);<br />

vertex(270, 120);<br />

endShape();<br />

Figure 9-23. Simple/Complex Quads sketch<br />

Simple vs. complex polygons is a big issue in 3D, where quadrilateral surfaces can become<br />

non-planar <strong>and</strong> cause anomalies when rendering. Triangles, on the other h<strong>and</strong>, are always<br />

planar. For our current purposes, in 2D, complex quads just form an interesting pattern. If<br />

you want to learn more about quads in general, check out http://en.wikipedia.org/<br />

wiki/Quadrilateral (I especially like the taxonomic classification chart). One other minor<br />

but significant point about using either TRIANGLE or QUADS mode is that you’ll want to<br />

make sure that you use the right number of vertex() comm<strong>and</strong>s. The number of comm<strong>and</strong>s<br />

should be divisible by 3 for TRIANGLES <strong>and</strong> 4 for QUADS. Additional vertex() lines<br />

that aren’t grouped in three or four lines, respectively, will be disregarded. For example,<br />

as shown in Figure 9-24, the fourth <strong>and</strong> fifth lines in the following sequence will be<br />

disregarded:<br />

size (120, 120);<br />

beginShape(TRIANGLES);<br />

vertex(20, 20);<br />

vertex(100, 100);<br />

vertex(40, 100);<br />

vertex(30, 60);<br />

vertex(20, 50);<br />

endShape();<br />

SHAPES<br />

371<br />

9

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

Saved successfully!

Ooh no, something went wrong!