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 9-25. TRIANGLE_STRIP Mode sketch<br />

I reused the basic trig functions I’ve been using throughout the book for generating an<br />

ellipse. By setting an outer <strong>and</strong> inner radius, this shape could be useful as an end cap for a<br />

hollow 3D cylinder. Next, I simply decreased the radii <strong>and</strong> fill color value (from white to<br />

black) each loop iteration, creating a spiral (see Figure 9-26):<br />

// TRIANGLE_STRIP Spiral<br />

size(400, 400);<br />

background(0);<br />

smooth();<br />

int x = width/2;<br />

int y = height/2;<br />

int outerRad = 160;<br />

int innerRad = 200;<br />

float px = 0, py = 0, angle = 0;<br />

int pts = 36;<br />

float rot = 360.0/pts;<br />

int fillCol = 255;<br />

int fillfade = fillCol/pts;<br />

beginShape(TRIANGLE_STRIP);<br />

for (int i=0; i

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

Saved successfully!

Ooh no, something went wrong!