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.

isTrailsSelected, which changes the display window’s background fill from 100 percent<br />

alpha to 16 percent alpha with the following conditional block in the draw() function:<br />

if (isTrailable){<br />

fill(150, 16);<br />

rect(width/2, height/2, width, height);<br />

}<br />

else {<br />

background(150);<br />

}<br />

Next, I’ll look at the mouse Release event:<br />

void mouseReleased(){<br />

if (btn1Background==btnDownState){<br />

btn1Background = btnOverState;<br />

}<br />

else if (btn2Background==btnDownState){<br />

btn2Background = btnOverState;<br />

}<br />

}<br />

The mouse release event just returns the buttons to their over states. I used the over state<br />

instead of the up state, as the mouse will still be over the button during the mouse release.<br />

void mouseMoved(){<br />

if (mouseX>btn1X-btn1W/2 && mouseX< btn1X+btn1W/2 && ➥<br />

mouseY>btn1Y-btn1H/2 && mouseY< btn1Y+btn1H/2){<br />

cursor(HAND);<br />

btn1Background = btnOverState;<br />

}<br />

else {<br />

cursor(ARROW);<br />

btn1Background = btnUpState;<br />

}<br />

if (mouseX>btn2X-btn2W/2 && mouseX< btn2X+btn2W/2 && ➥<br />

mouseY>btn2Y-btn2H/2 && mouseY< btn2Y+btn2H/2){<br />

cursor(HAND);<br />

btn2Background = btnOverState;<br />

}<br />

else {<br />

cursor(ARROW);<br />

btn2Background = btnUpState;<br />

}<br />

//button 3<br />

if (mouseX>btn3X-btn3W/2 && mouseX< btn3X+btn3W/2 && ➥<br />

mouseY>btn3Y-btn3H/2 && mouseY< btn3Y+btn3H/2){<br />

cursor(HAND);<br />

INTERACTIVITY<br />

589<br />

12

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

Saved successfully!

Ooh no, something went wrong!