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.

PROCESSING: CREATIVE CODING AND COMPUTATIONAL ART<br />

366<br />

curveVertex(400, 800);<br />

curveVertex(400, 500);<br />

curveVertex(200, 500);<br />

curveVertex(200, 800);<br />

vertex(100, 500);<br />

vertex(100, 400);<br />

curveVertex(-200, 400);<br />

curveVertex(100, 400);<br />

curveVertex(100, 200);<br />

curveVertex(-200, 200);<br />

vertex(100, 100);<br />

endShape(CLOSE);<br />

Figure 9-19. Hybrid Shape sketch<br />

The next step was looking at the ugly code I had written <strong>and</strong> seeing if I could figure out an<br />

algorithm to generalize the form. This backward approach—making before thinking—<br />

seems to be a general pattern I use when I get stuck. I guess if you’re better at math than<br />

me, you might be able to lay down clean algorithms by just thinking about problems, but<br />

I usually have to get my h<strong>and</strong>s dirty first. Because the shape created in the sketch is symmetrical,<br />

<strong>and</strong> there is a recurring pattern of function calls in the code, I knew it would be<br />

possible, without too much hair pulling, to figure out the algorithm. I also knew, because<br />

of the radial symmetry, that using trig functions would somehow be the easiest solution.<br />

Here’s what I got (see Figure 9-20):

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

Saved successfully!

Ooh no, something went wrong!