transformRect method
Returns a rect that bounds the result of applying the given matrix as a perspective transform to the given rect.
This function assumes the given rect is in the plane with z equals 0.0. The transformed rect is then projected back into the plane with z equals 0.0 before computing its bounding rect.
Implementation
static Rect transformRect(Matrix4 transform, Rect rect) {
final Offset point1 = transformPoint(transform, rect.topLeft);
final Offset point2 = transformPoint(transform, rect.topRight);
final Offset point3 = transformPoint(transform, rect.bottomLeft);
final Offset point4 = transformPoint(transform, rect.bottomRight);
return Rect.fromLTRB(
_min4(point1.dx, point2.dx, point3.dx, point4.dx),
_min4(point1.dy, point2.dy, point3.dy, point4.dy),
_max4(point1.dx, point2.dx, point3.dx, point4.dx),
_max4(point1.dy, point2.dy, point3.dy, point4.dy)
);
}