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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Transformations include moving, scaling, skewing, <strong>and</strong> rotating vertices. Remember, vertices<br />

(points) are the foundation for all the other geometry you see on the screen. The<br />

simplest way to show how the transform functions work is through some examples. First,<br />

I’ll give you a (rather dull) example that transforms 2D geometry (see Figure A-12). Then<br />

I’ll apply the concepts from the 2D example to a more interesting (albeit more complicated)<br />

3D example.<br />

//Example 1:<br />

noStroke();<br />

rect(10, 10, 25, 25);<br />

printMatrix();<br />

pushMatrix();<br />

translate(20, 20);<br />

scale (1.5);<br />

rect(10, 10, 25, 25);<br />

printMatrix();<br />

popMatrix();<br />

pushMatrix();<br />

translate(70, 70);<br />

scale (.5);<br />

rect(10, 10, 25, 25);<br />

printMatrix();<br />

popMatrix();<br />

printMatrix();<br />

Figure A-12. Transform Example 1 sketch<br />

PROCESSING LANGUAGE API<br />

713<br />

A

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

Saved successfully!

Ooh no, something went wrong!