getBounds method
Returns the bounds of this container in the given targetSpace
.
If out
is provided, the results will be stored there. Otherwise, a new
GRect will be created and returned.
Implementation
@override
GRect? getBounds(GDisplayObject? targetSpace, [GRect? out]) {
out ??= GRect();
final len = children.length;
if (len == 0) {
getTransformationMatrix(targetSpace, $sBoundsMatrix);
$sBoundsMatrix.transformCoords(0, 0, $sBoundsPoint);
out.setTo($sBoundsPoint.x, $sBoundsPoint.y, 0, 0);
return out;
} else if (len == 1) {
return children[0].getBounds(targetSpace, out);
} else {
var minX = 10000000.0;
var maxX = -10000000.0;
var minY = 10000000.0;
var maxY = -10000000.0;
final len = numChildren;
for (var i = 0; i < len; ++i) {
children[i].getBounds(targetSpace, out);
if (out.isEmpty) continue;
if (minX > out.x) minX = out.x;
if (maxX < out.right) maxX = out.right;
if (minY > out.y) minY = out.y;
if (maxY < out.bottom) maxY = out.bottom;
}
out.setTo(minX, minY, maxX - minX, maxY - minY);
return out;
}
}