getBounds method
Returns the bounds of this GShape in the coordinate system of the
targetSpace
object. If the out
parameter is not null, the result will
be stored in that object and returned. Otherwise, a new GRect object
will be created and returned. If this GShape has no graphics, the bounds
will be based on its position and size.
The matrix
parameter is an optional matrix that is used to transform the
bounds from the local coordinate space of this GShape to the coordinate
space of the targetSpace
object. If the matrix
parameter is not
specified, the identity matrix will be used.
The out
parameter is an optional object that will be used to store the
result. If it is not null, the result will be stored in that object and
returned. Otherwise, a new GRect object will be created and returned.
Returns a GRect object representing the bounds of this GShape in the
coordinate space of the targetSpace
object.
Implementation
@override
GRect? getBounds(GDisplayObject? targetSpace, [GRect? out]) {
final matrix = _sHelperMatrix;
matrix.identity();
getTransformationMatrix(targetSpace, matrix);
if (_graphics != null) {
/// todo: fix the rect size.
// var _allBounds = _graphics.getAllBounds();
// out?.setEmpty();
// _allBounds.forEach((localBounds) {
// out ??= GxRect();
// /// modify the same instance.
// out.expandToInclude(MatrixUtils.getTransformedBoundsRect(
// matrix,
// localBounds,
// localBounds,
// ));
// });
/// single bounds, all paths as 1 rect.
return MatrixUtils.getTransformedBoundsRect(
matrix,
_graphics!.getBounds(out),
out,
);
} else {
final pos = GDisplayObjectContainer.$sBoundsPoint;
matrix.transformCoords(0, 0, pos);
out!.setTo(pos.x, pos.y, 0, 0);
}
return out;
}