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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

PROCESSING: CREATIVE CODING AND COMPUTATIONAL ART<br />

94<br />

// set initial ball placement<br />

xpos[i] = width/2+r<strong>and</strong>om(-width/3, width/3);<br />

ypos[i] = height/2+r<strong>and</strong>om(-height/3, height/3);<br />

}<br />

// turn off shape stroke rendering<br />

noStroke();<br />

//set the animation loop speed<br />

frameRate(30);<br />

}<br />

After declaring the global variables, I do some program initialization in the setup() function.<br />

I set the window size <strong>and</strong> background color, <strong>and</strong> then I use a somewhat hairy-looking<br />

for loop. In reality, it’s not that different from the single-ball setup() function, but arrays<br />

can look intimidating until you get used to them. The for loop<br />

for (int i=0; i

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

Saved successfully!

Ooh no, something went wrong!