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.

Figure 7-32. bezier() vs. bezierVertex() sketch<br />

The bezierVertex() function needs to be called between beginShape() <strong>and</strong> endShape(),<br />

with the initial call being a single vertex() call. Remember that beginShape() begins<br />

recording coordinate data until endShape() is called, at which time the data is rendered to<br />

the screen <strong>and</strong> filled by default. Although the shape will be filled, the path defining the<br />

shape will not be closed unless the CLOSE argument is included in the endShape(CLOSE)<br />

call. Of course, visually, you can make the path appear closed by making sure that the<br />

anchor point in the last bezierVertex(controPt1, controlPt2, anchorPt) call is placed<br />

at the same coordinate location as the initial vertex(x, y) call. If the starting <strong>and</strong> ending<br />

points are not in the same location, using the CLOSE argument will connect the two points<br />

with a straight line, which is what occurs in the second spiral in the last example. By<br />

default, the shape will be filled following the same rule, as illustrated in the third spiral,<br />

even though this spiral is technically not closed. This same pattern of rules holds true for<br />

the curve() <strong>and</strong> curveVertex() functions. For the sake of thoroughness, here’s a<br />

curve()/curveVertex() version of the last example:<br />

//curve() vs. curveVertex()<br />

size(650, 225);<br />

background(255);<br />

rectMode(CENTER);<br />

strokeWeight(2);<br />

//curve()<br />

noFill();<br />

curve(92, 15, 92, 15, 134, 15, 175, 50);<br />

curve(92, 15, 134, 15, 175, 50, 175, 175);<br />

curve(134, 15, 175, 50, 175, 175, 75, 175);<br />

curve(175, 50, 175, 175, 75, 175, 75, 75);<br />

curve(175, 175, 75, 175, 75, 75, 150, 75);<br />

curve(75, 175, 75, 75, 150, 75, 150, 150);<br />

curve(75, 75, 150, 75, 150, 150, 100, 150);<br />

curve(150, 75, 150, 150, 100, 150, 100, 150);<br />

CURVES<br />

287<br />

7

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

Saved successfully!

Ooh no, something went wrong!