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

572<br />

}<br />

}<br />

}<br />

// function to draw nodes<br />

void drawNode(){<br />

// draw nodes at shape vertices<br />

noStroke();<br />

for (int i=0; i2){<br />

if (dist(mouseX, mouseY, nodeXPos[0], nodeYPos[0]) < nodeRadius){<br />

isOnNode = true;<br />

}<br />

}<br />

return isOnNode;<br />

}<br />

void mousePressed(){<br />

if(isShapeClosed){<br />

// after shape is closed empty arrays<br />

nodeXPos = subset(nodeXPos, 0, 0);<br />

nodeYPos = subset(nodeYPos, 0, 0);<br />

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

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

jitter = subset(jitter, 0, 0);<br />

elasticity = subset(elasticity, 0, 0);<br />

//reset variable to false<br />

isShapeClosed = false;<br />

}<br />

if(!isInitialNode()){<br />

// if not on initial node plot at mouse position<br />

// increase size of node coordinate arrays<br />

nodeXPos = append(nodeXPos, mouseX);

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

Saved successfully!

Ooh no, something went wrong!