intersect method

Rect intersect(
  1. Rect other
)

Implementation

Rect intersect(Rect other) {
  final nx = x > other.x ? x : other.x;
  final ny = y > other.y ? y : other.y;
  final nr = right < other.right ? right : other.right;
  final nb = bottom < other.bottom ? bottom : other.bottom;

  if (nr <= nx || nb <= ny) return const Rect.zero();
  return Rect(nx, ny, nr - nx, nb - ny);
}