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

52<br />

// set inital branch point from top of trunk<br />

pts[0] = new Point2D.Float(width/2+lean2[trunkSegments], ➥<br />

height-trunkLength);<br />

//create branches<br />

branch(pts);<br />

}<br />

//main function that draws branches <strong>and</strong> leaves<br />

void branch(Point2D.Float[]pts){<br />

int stemCount=2;<br />

// global variable branchLimit controls complexity of tree<br />

if (counter2=200){<br />

// at top of tree branches get thinner <strong>and</strong> more numerous<br />

stemCount = 2+(int)(Math.r<strong>and</strong>om()*15);<br />

// leave color<br />

stroke(r<strong>and</strong>om(60), 50+r<strong>and</strong>om(90), r<strong>and</strong>om(20), 230);<br />

yg-=myR<strong>and</strong>(.65);<br />

xg+=r<strong>and</strong>om(1.5);<br />

radius*=(.91);<br />

}<br />

for (int j=0; j

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

Saved successfully!

Ooh no, something went wrong!