translateX function
double
translateX(
- double x,
- Size canvasSize,
- Size imageSize,
- InputImageRotation rotation,
- CameraLensDirection cameraLensDirection,
)
Implementation
double translateX(
double x,
Size canvasSize,
Size imageSize,
InputImageRotation rotation,
CameraLensDirection cameraLensDirection,
) {
switch (rotation) {
case InputImageRotation.rotation90deg:
return x * canvasSize.width / (Platform.isIOS ? imageSize.width : imageSize.height);
case InputImageRotation.rotation270deg:
return canvasSize.width - x * canvasSize.width /
(Platform.isIOS ? imageSize.width : imageSize.height);
case InputImageRotation.rotation0deg:
case InputImageRotation.rotation180deg:
switch (cameraLensDirection) {
case CameraLensDirection.back:
return x * canvasSize.width / imageSize.width;
default:
return canvasSize.width - x * canvasSize.width / imageSize.width;
}
}
}