calculateMorphScaleFactorRaw static method

double calculateMorphScaleFactorRaw(
  1. List<RoundedPolygon> polygons, {
  2. bool approximate = true,
})

Implementation

static double calculateMorphScaleFactorRaw(
  List<material_shapes.RoundedPolygon> polygons, {
  bool approximate = true,
}) {
  var scaleFactor = 1.0;
  for (final polygon in polygons) {
    final bounds = approximate
        ? polygon.calculateApproximateBounds()
        : polygon.calculateBounds();
    final maxBounds = polygon.calculateMaxBounds();

    final scaleX = bounds.width / maxBounds.width;
    final scaleY = bounds.height / maxBounds.height;

    // We use max(scaleX, scaleY) to handle cases like a pill-shape that can
    // throw off the entire calculation.
    scaleFactor = math.min(scaleFactor, math.max(scaleX, scaleY));
  }
  return scaleFactor;
}