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.

nodeYPos = append(nodeYPos, mouseY);<br />

// increase size of dynamics arrays<br />

xSpeed = append(xSpeed, 0);<br />

jitter = append(jitter, r<strong>and</strong>om(-jitterRange, jitterRange));<br />

elasticity = append(elasticity, r<strong>and</strong>om(elasticRangeMin, ➥<br />

elasticRangeMax));<br />

ySpeed = append(ySpeed, 0);<br />

}<br />

else {<br />

// set to true to avoid additional nodes on shape<br />

isShapeClosed = true;<br />

}<br />

}<br />

//function to move shape<br />

void moveShape(){<br />

//animate after shape is closed<br />

if (isShapeClosed){<br />

for (int i=0; iwidth-nodeRadius){<br />

nodeXPos[i] = width-nodeRadius;<br />

xSpeed[i]*=-1;<br />

}<br />

// left display window edge<br />

if (nodeXPos[i]height-nodeRadius){<br />

nodeYPos[i] = height-nodeRadius;<br />

xSpeed[i]+=jitter[i];<br />

xSpeed[i]*=friction;<br />

jitter[i]*=friction;<br />

ySpeed[i]*=-1;<br />

ySpeed[i]*=elasticity[i];<br />

}<br />

}<br />

}<br />

}<br />

INTERACTIVITY<br />

573<br />

12

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

Saved successfully!

Ooh no, something went wrong!