computeScaleDelta static method

double computeScaleDelta({
  1. required Size sourceSize,
  2. required Size targetSize,
})

Computes the geometric scale ratio from sourceSize to targetSize.

Uses the square root of the area ratio, which treats width and height symmetrically:

Δ_scale = √(targetArea / sourceArea)

Returns 1.0 when sourceSize is zero-area (zero-sized triggers).

Implementation

static double computeScaleDelta({
  required Size sourceSize,
  required Size targetSize,
}) {
  final sourceArea = sourceSize.width * sourceSize.height;
  final targetArea = targetSize.width * targetSize.height;
  if (sourceArea <= 0.0) return 1.0;
  return math.sqrt(targetArea / sourceArea);
}