transform method

Rect transform(
  1. List<double> matrix
)

Transform this rectangle using a matrix a, b, c, d, e, f.

Implementation

Rect transform(List<double> matrix) {
  final corners = [topLeft, topRight, bottomLeft, bottomRight];
  final transformed = corners.map((p) => p.transform(matrix)).toList();
  double minX = double.infinity, minY = double.infinity;
  double maxX = double.negativeInfinity, maxY = double.negativeInfinity;
  for (final p in transformed) {
    if (p.x < minX) minX = p.x;
    if (p.y < minY) minY = p.y;
    if (p.x > maxX) maxX = p.x;
    if (p.y > maxY) maxY = p.y;
  }
  return Rect(minX, minY, maxX, maxY);
}