union method

DiffRect union(
  1. DiffRect other
)

The bounding box of both, their changed pixels summed — exact, because components never share a pixel.

Implementation

DiffRect union(DiffRect other) {
  var left = math.min(x, other.x);
  var top = math.min(y, other.y);
  return DiffRect(
    x: left,
    y: top,
    width: math.max(x + width, other.x + other.width) - left,
    height: math.max(y + height, other.y + other.height) - top,
    pixels: pixels + other.pixels,
  );
}