getBoundingBox static method
Calculates the bounding rectangle that encloses a list of artifacts.
This static method takes a list of Artifact objects and computes the minimum and maximum coordinates to define a rectangular bounding box that contains all the artifacts.
If the input list is empty, this method returns Rect.zero.
Returns: A Rect representing the bounding box of the provided artifacts.
Implementation
static IntRect getBoundingBox(
final List<Artifact> artifacts, {
bool useAdjustedRect = true,
}) {
if (artifacts.isEmpty) {
return IntRect();
}
int minX = artifacts.first.rectFound.left;
int minY = artifacts.first.rectFound.top;
int maxX = artifacts.first.rectFound.right;
int maxY = artifacts.first.rectFound.bottom;
for (final Artifact artifact in artifacts) {
final IntRect rect = useAdjustedRect
? artifact.rectAdjusted
: artifact.rectFound;
minX = min(minX, rect.left);
minY = min(minY, rect.top);
maxX = max(maxX, rect.right);
maxY = max(maxY, rect.bottom);
}
return IntRect.fromLTRB(minX, minY, maxX, maxY);
}