nearestPoint method
Returns a point on the shape's boundary which is closest to the given
point
.
The point
must lie outside of the shape. If there are multiple nearest
points, any one can be returned.
This method will not modify point
. At the same time, the caller does
not get ownership of the returned object: they must treat it as an
immutable short-lived object.
Implementation
@override
Vector2 nearestPoint(Vector2 point) {
return _tmpResult
..setValues(
(point.x).clamp(_left, _right),
(point.y).clamp(_top, _bottom),
);
}