07.01.2013 Views

Fractal.Invaders, Substrate (Interview with Jared Tarbell) - Processing

Fractal.Invaders, Substrate (Interview with Jared Tarbell) - Processing

Fractal.Invaders, Substrate (Interview with Jared Tarbell) - Processing

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

213 Input 1: Mouse I<br />

fill(126); // Gray<br />

}<br />

rect(25, 25, 50, 50);<br />

}<br />

// Set the square to black when the left mouse button<br />

// is pressed, white when the right button is pressed,<br />

// and gray when a button is not pressed<br />

void setup() {<br />

size(100, 100);<br />

}<br />

void draw() {<br />

if (mousePressed == true) {<br />

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

fill(0); // Black<br />

} else if (mouseButton == RIGHT) {<br />

fill(255); // White<br />

}<br />

} else {<br />

fill(126); // Gray<br />

}<br />

rect(25, 25, 50, 50);<br />

}<br />

Not all mice have multiple buttons, and if software is distributed widely, the interaction<br />

should not rely on detecting which button is pressed. For example, if you are posting<br />

your work on the Web, don’t rely on the middle or right button for using the software<br />

because many users won’t have a two- or three-button mouse.<br />

Cursor icon<br />

The cursor can be hidden <strong>with</strong> the noCursor() function and can be set to appear as a<br />

different icon <strong>with</strong> the cursor() function. When the noCursor() function is run, the<br />

cursor icon disappears as it moves into the display window. To give feedback about the<br />

location of the cursor <strong>with</strong>in the software, a custom cursor can be drawn and controlled<br />

<strong>with</strong> the mouseX and mouseY variables.<br />

23-16<br />

cont.<br />

23-17

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

Saved successfully!

Ooh no, something went wrong!