I have a diamond drawn on a panel and I'm trying to calculate if the mouse position is within its bounds. The problem is trying to the diamond, it needs four coordinates making up four lines to create the shape.
The easy thing to do is to create/fit a square within the bounds of the diamond, but I want to account for the remaining triangular areas outside. I initially thought I trying to calculate the slope between two points and figuring out if the x and y of the mouse intersects the line by adding the slope into the the equation, but it proved to be a lot more difficult when it comes to the lines that make up the TOP->RIGHT, RIGHT->BOTTOM and BOTTOM->LEFT given that the center of the diamond is not zero.
Is there an easier implementation to check if the mouse's x,y is within the bounds of the diamond?
In pseudo-code (to be more readable):
Of math one knows (0, radii.y) and (radii.x, 0) determine the border line in the positive quadrant. That comes down to the formula above.
By the way: