translateY static method

double translateY({
  1. required double y,
  2. required Size canvasSize,
  3. required Size imageSize,
  4. required InputImageRotation rotation,
  5. required CameraLensDirection cameraLensDirection,
})

Translates the Y coordinate based on canvas and image size, rotation, and camera lens direction.

y The Y coordinate to be translated. canvasSize The size of the canvas where the image is displayed. imageSize The size of the original image. rotation The rotation of the input image. cameraLensDirection The direction of the camera lens (front or back). Returns the translated Y coordinate.

Implementation

static double translateY({
  required double y,
  required Size canvasSize,
  required Size imageSize,
  required InputImageRotation rotation,
  required CameraLensDirection cameraLensDirection,
}) {
  double imageHeight = Platform.isIOS ? imageSize.height : imageSize.width;
  switch (rotation) {
    case InputImageRotation.rotation90deg:
    case InputImageRotation.rotation270deg:
      return y * canvasSize.height / imageHeight;
    case InputImageRotation.rotation0deg:
    case InputImageRotation.rotation180deg:
      return y * canvasSize.height / imageSize.height;
  }
}