Mouse 2D

This example is for Processing version 1.1+. If you have a previous version, use the examples included with your software. If you see any errors or have suggestions, »please let us know.

Click.

Move the mouse to position the shape. Press the mouse button to invert the color.



void setup() {
  size(200, 200);
  fill(126);
  background(102);
}

void draw() {
  if(mousePressed) {
    stroke(255);
  } else {
    stroke(0);
  }
  line(mouseX-66, mouseY, mouseX+66, mouseY);
  line(mouseX, mouseY-66, mouseX, mouseY+66); 
}