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.

}<br />

sliderValue = (sliderH<strong>and</strong>le[0]-sliderBar[0]+10)*.25;<br />

}<br />

The last code snippet in draw() controls the slider event behavior. If the mouse is pressed<br />

on the slider h<strong>and</strong>le, it can be dragged only across the x-axis, constrained between the<br />

ends of the slider bar. In setting the sliderValue variable, I needed to add 10 <strong>and</strong> multiply<br />

the actual coordinate value by .25 so that the value of sliderH<strong>and</strong>le’s x position could<br />

be used for setting the pencil, brush, <strong>and</strong> eraser tools’ stroke sizes, which are controlled by<br />

the slider.<br />

After the draw() function is the mousePressed() function:<br />

void mousePressed(){<br />

//pencil<br />

if (mouseX>pencilBtn[0] && mouseXpencilBtn[1] && mouseYbrushBtn[0] && mouseXbrushBtn[1] && mouseYeraserBtn[0] && mouseXeraserBtn[1] && mouseYtools[0] && mouseXtools[1]+tools[3] && mouseY

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

Saved successfully!

Ooh no, something went wrong!