normalized method
Returns a new RoundedPolygon, moving and resizing this one, so it's completely inside the (0, 0) -> (1, 1) square, centered if there is extra space in one direction.
Implementation
RoundedPolygon normalized() {
final Rect bounds = calculateApproximateBounds();
final double side = math.max(bounds.width, bounds.height);
if (side < distanceEpsilon) {
return this;
}
// Center the shape if bounds are not a square.
final double offsetX = (side - bounds.width) / 2 - bounds.left;
final double offsetY = (side - bounds.height) / 2 - bounds.top;
return transformed((x, y) => ((x + offsetX) / side, (y + offsetY) / side));
}