normalized method

RoundedPolygon normalized({
  1. bool approximate = true,
})

Implementation

RoundedPolygon normalized({bool approximate = true}) {
  final bounds = calculateBounds(approximate: approximate);

  final width = bounds.right - bounds.left;
  final height = bounds.bottom - bounds.top;
  final side = math.max(width, height);

  // Center the shape if bounds are not a square
  final offsetX = (side - width) / 2.0 - bounds.left;
  final offsetY = (side - height) / 2.0 - bounds.top;

  return transformed((x, y) => ((x + offsetX) / side, (y + offsetY) / side));
}