A Rect has parameters left, top, right and bottom to represent a rectangle, but it actually represents two rectangles. See the diagram below:
When i rotated the rectangle on the left using:
matrix.setRotate(45,myRect.exactCenterX(), myRect.exactCenterY());
matrix.mapRect(myRect);
I was expecting the rectangle in Red color, but I got the one in Blue color. Because the same parameters (left, top, right, bottom) represents two rectangles.
Is this a problem with Android's Rect? How can I get the rectangle in the Red color?
Rect holds four integer coordinates for a rectangle. The rectangle is represented by the coordinates of its 4 edges (left, top, right bottom).
The Rect
class is basically just a set of the coordinates for left/top and right/bottom corner. It has no concept of rotation whatsoever.