TransformData.fromRect constructor

TransformData.fromRect(
  1. Rect rect,
  2. Size layout,
  3. Size maxSize,
  4. VideoEditorController controller,
)

Implementation

factory TransformData.fromRect(
  // the selected crop rect area
  Rect rect,
  // the maximum size of the crop area
  Size layout,
  // the maximum size to display
  Size maxSize,
  VideoEditorController controller,
) {
  if (controller.rotation == 90 || controller.rotation == 270) {
    maxSize = maxSize.flipped;
  }

  final double scale = scaleToSize(maxSize, rect);
  final double rotation = -controller.rotation * (pi / 180.0);
  final Offset translate = Offset(
    ((layout.width - rect.width) / 2) - rect.left,
    ((layout.height - rect.height) / 2) - rect.top,
  );

  return TransformData(
    rotation: rotation,
    scale: scale,
    translate: translate,
  );
}