getFractionY method

double getFractionY(
  1. double y
)

Returns the fractional Y position of a given Y coordinate within the bounds of this BoundingBox. Throws UnboundedError if Y bounds are not set.

Implementation

double getFractionY(double y) {
  if (this case BoundingBox(:final minY?, :final maxY?)) {
    if (minY == maxY) {
      return 0;
    }

    return 1 - (y - minY) / (maxY - minY);
  }

  throw UnboundedError(
    message:
        'Getting Y-axis fraction is not possible without specific X-axis bounds. Please ensure minX and maxX are set. Current bounds: minY=$minY, maxY=$maxY',
  );
}