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

68<br />

display window background with black. The second stage will add a white ellipse, <strong>and</strong><br />

the third stage will create the gradient. In stages 2 <strong>and</strong> 3, you just need to add the new<br />

code shown in bold. Also, try running the sketch at each stage to see the effect of adding<br />

the new code.<br />

Stage 1 just generates a black 200-by-200-pixel display window:<br />

/*<br />

title: fun with variables<br />

description: stepped radial gradient<br />

created: August 7, 2005<br />

by: Ira Greenberg<br />

*/<br />

// set the sketch window size <strong>and</strong> background<br />

size(200,200);<br />

background(0);<br />

Stage 2 utilizes some variables <strong>and</strong> draws a white ellipse in the middle of the display window:<br />

/*<br />

title: fun with variables<br />

description: stepped radial gradient<br />

created: August 7, 2005<br />

by: Ira Greenberg<br />

*/<br />

// declare some global variables<br />

int xpos;<br />

int ypos;<br />

int gradientWidth, gradientHeight;<br />

// set the sketch window size <strong>and</strong> background<br />

size(200,200);<br />

background(0);<br />

// radial width/height<br />

gradientWidth = gradientHeight = width;<br />

//radial center pt<br />

xpos = width/2;<br />

ypos = height/2;<br />

//turn off stroke rendering<br />

noStroke();<br />

//create ellipses<br />

ellipse(xpos, ypos, gradientWidth, gradientHeight);

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

Saved successfully!

Ooh no, something went wrong!