getBounds method
Returns the bounds of the text in the target coordinate space.
The targetSpace
parameter determines the coordinate space of the
returned bounds object. You can use this parameter to get the bounds of
the text relative to any display object.
If the targetSpace
parameter is not passed, the method returns the
bounds of the text in its local coordinate space.
By default, the bounds object returned by this method contains the text's dimensions.
If the method is called with an existing out
parameter, the returned
value will be the same as the out
parameter. This is useful when you
want to avoid creating a new bounds GRect object.
Implementation
@override
GRect getBounds(GDisplayObject? targetSpace, [GRect? out]) {
validate();
out ??= GRect();
out.setTo(0, 0, intrinsicWidth, textHeight);
if (targetSpace == this) {
/// optimization.
return out;
}
final matrix = _sHelperMatrix;
matrix.identity();
getTransformationMatrix(targetSpace, matrix);
MatrixUtils.getTransformedBoundsRect(matrix, out, out);
return out;
}