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 6-7. R<strong>and</strong>omized particle spray<br />

You can even use a r<strong>and</strong>om() function to generate values for another r<strong>and</strong>om() function.<br />

Run the next example a couple of times to see the range of output (one example of which<br />

is shown in Figure 6-8); it’s pretty interesting <strong>and</strong> getting fairly organic. As always, play with<br />

the numbers to see the expressive potential of the algorithm.<br />

size(300, 300);<br />

background(0);<br />

int totalPts = 300;<br />

float steps = totalPts+1;<br />

stroke(255);<br />

float r<strong>and</strong> = 0;<br />

for (int i=1; i< steps; i++){<br />

point((width/steps)*i, (height/2)+r<strong>and</strong>om(-r<strong>and</strong>, r<strong>and</strong>));<br />

r<strong>and</strong>+=r<strong>and</strong>om(-5, 5);<br />

}<br />

Figure 6-8. Doubly r<strong>and</strong>omized particle line<br />

LINES<br />

181<br />

6

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

Saved successfully!

Ooh no, something went wrong!