CIT020 Index > Conditionals

Conditionals: Determining where the mouse is

square at 45 degree angle inscribed in sketch window Presume that the sketch width and height is given as SIZE.

Mouse is in areawhen
A mouseX + mouseY < SIZE / 2.0
B mouseX - mouseY > SIZE / 2.0
C mouseX + mouseY > 3.0 * SIZE / 2.0
D mouseX - mouseY < -SIZE / 2.0

If the mouse isn’t in area A, B, C, or D, then it must be in the diamond in the center of the diagram.