09.04.2016 Views

www.ebook777.com

Make_Getting_Started_with_Processing_Second_Edition

Make_Getting_Started_with_Processing_Second_Edition

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

void setup() {<br />

size(240, 120);<br />

strokeWeight(30);<br />

}<br />

void draw() {<br />

background(204);<br />

stroke(102);<br />

line(40, 0, 70, height);<br />

if (mousePressed) {<br />

stroke(0);<br />

} else {<br />

stroke(255);<br />

}<br />

line(0, 70, width, 50);<br />

}<br />

Example 5-12: Multiple Mouse<br />

Buttons<br />

Processing also tracks which button is pressed if you have more<br />

than one button on your mouse. The mouseButton variable can<br />

be one of three values: LEFT, CENTER, or RIGHT. To test which button<br />

was pressed, the == operator is needed, as shown here:<br />

void setup() {<br />

size(120, 120);<br />

strokeWeight(30);<br />

}<br />

void draw() {<br />

background(204);<br />

stroke(102);<br />

line(40, 0, 70, height);<br />

if (mousePressed) {<br />

if (mouseButton == LEFT) {<br />

stroke(255);<br />

Response 59

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

Saved successfully!

Ooh no, something went wrong!