if (xPosition < 100 || Canvas.getWidth()-xPosition < 100) { changeColor("red"); } else { changeColor("black"); } if (yPosition < 100 || Canvas.getHeight()-yPosition < 100) { changeColor("red"); } else { changeColor("black"); }