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

574<br />

Figure 12-1. Shape Builder <strong>and</strong> Animator Example sketch<br />

You should play with this sketch some to see what it can do. Besides running the sketch, I<br />

also recommend messing with some of the variable values declared at the top of the<br />

program.<br />

To give you a better underst<strong>and</strong>ing, I’ll now go over the sketch a section at a time.<br />

// Shape Builder <strong>and</strong> Animator Example<br />

float nodeRadius = 5.0;<br />

// holds node coordinate values<br />

float[]nodeXPos = new float[0];<br />

float[]nodeYPos= new float[0];<br />

color initialNode = color(0);<br />

boolean isShapeClosed = false;<br />

//dynamics variables (moves shape)<br />

float gravity = .95;<br />

float jitterRange = 5;<br />

float elasticRangeMin = .75;<br />

float elasticRangeMax = .95;<br />

float friction = .85;<br />

float[]jitter = new float[0];<br />

float[]xSpeed = new float[0];<br />

float[]ySpeed = new float[0];<br />

float[]elasticity = new float[0];

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

Saved successfully!

Ooh no, something went wrong!