From cc20182ec046dd50b06787daadf6f544f4f59f94 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Tue, 26 Feb 2019 12:17:10 -0500 Subject: [PATCH] Normalize translation in image editor. --- SignalMessaging/Views/ImageEditor/ImageEditorModel.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/SignalMessaging/Views/ImageEditor/ImageEditorModel.swift b/SignalMessaging/Views/ImageEditor/ImageEditorModel.swift index a1a1868a6..e4bee2cdd 100644 --- a/SignalMessaging/Views/ImageEditor/ImageEditorModel.swift +++ b/SignalMessaging/Views/ImageEditor/ImageEditorModel.swift @@ -113,6 +113,15 @@ public class ImageEditorTransform: NSObject { // image can be moved _exactly_ to the edge of the canvas // and no further in a way that reflects the current // crop, scaling and rotation. + // + // We need to clamp the translation to the valid "translation + // region" which is a rectangle centered on the origin. + // However, this rectangle is axis-aligned in canvas + // coordinates, not view coordinates. e.g. if you have + // a long image and a square output size, you could "slide" + // the crop region along the image's contents. That + // movement would appear diagonal to the user in the view + // but would be vertical on the canvas. // Normalize translation, Step 1: //