setTopLeftAndBottomRight method
The order of the input parameters does not matter, coordinates are sorted based on comparison.
- It is important that each of the four coordinates are ordered based on value, as a Rect never has negative width or height.
Implementation
void setTopLeftAndBottomRight(Coordinate point1, Coordinate point2)
{
left = Math.min(point1.x, point2.x);
top = Math.min(point1.y, point2.y);
width = Math.max(point1.x, point2.x) - left;
height = Math.max(point1.y, point2.y) - top;
}