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 />

182<br />

Once you have a single line doing some interesting stuff, you can try to extend the concept<br />

with multiple lines. One way of thinking of this is as looping a loop. You can pretty easily<br />

put your existing for loop within another for loop <strong>and</strong> move your line down the display<br />

window, repeating the structure over <strong>and</strong> over again. It is often through these types of<br />

overlapping iterative processes that really unexpected <strong>and</strong> interesting stuff starts emerging<br />

out of the code. One caution, though: if you’ve been reading this stuff pretty quickly <strong>and</strong><br />

not thoroughly experimenting with these structures along the way, you’re missing many<br />

interesting possibilities, <strong>and</strong> more importantly, the feature creep in the sketches is going to<br />

quickly overwhelm you. I really recommend reading this chapter in small bites <strong>and</strong> then<br />

thoroughly chewing through the code possibilities. It’s the best way to begin to remember<br />

all the weird syntax <strong>and</strong> keywords. The next example runs the previous code through<br />

another outer loop <strong>and</strong> adds some other modifications, drawing a series of lines down the<br />

display window (see Figure 6-9).<br />

/*<br />

Razor Tooth Pattern<br />

Ira Greenberg, November 20, 2005<br />

*/<br />

size(300, 300);<br />

background(0);<br />

int totalPts = 1000;<br />

float steps = totalPts+1;<br />

int totalRows = 50; // needs to be < = 300<br />

int rowShift = height/totalRows;<br />

float rowNudge = -.4;<br />

float rowHop = 0;<br />

int r<strong>and</strong>Nudge = 5;<br />

stroke(255);<br />

for (int i=rowShift; i

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

Saved successfully!

Ooh no, something went wrong!