diff --git a/croppa/main.py b/croppa/main.py index d3d58f8..5fad58b 100644 --- a/croppa/main.py +++ b/croppa/main.py @@ -1310,7 +1310,7 @@ class VideoEditor: def _map_rotated_to_screen(self, rx, ry): """Map a point in ROTATED frame coords to canvas screen coords (post-crop).""" - # Subtract crop offset in rotated space (use current EFFECTIVE crop) + # Subtract crop offset in rotated space (EFFECTIVE crop at current frame) cx, cy, cw, ch = self._get_effective_crop_rect_for_frame(getattr(self, 'current_frame', 0)) rx2 = rx - cx ry2 = ry - cy @@ -1328,8 +1328,8 @@ class VideoEditor: offy = 0 zx = rx2 * self.zoom_factor - offx zy = ry2 * self.zoom_factor - offy - visible_w = new_w if not cropped_due_to_zoom else min(new_w, self.window_width) - visible_h = new_h if not cropped_due_to_zoom else min(new_h, self.window_height) + visible_w = new_w if not cropped_due_to_zoom else self.window_width + visible_h = new_h if not cropped_due_to_zoom else self.window_height available_height = self.window_height - (0 if self.is_image_mode else self.TIMELINE_HEIGHT) scale_canvas = min(self.window_width / max(1, visible_w), available_height / max(1, visible_h)) final_w = int(visible_w * scale_canvas) @@ -1344,13 +1344,10 @@ class VideoEditor: """Map a point on canvas screen coords back to ROTATED frame coords (pre-crop).""" frame_number = getattr(self, 'current_frame', 0) angle = self.rotation_angle - # Rotated base dims - if angle in (90, 270): - rotated_w, rotated_h = self.frame_height, self.frame_width - else: - rotated_w, rotated_h = self.frame_width, self.frame_height - new_w = int(rotated_w * self.zoom_factor) - new_h = int(rotated_h * self.zoom_factor) + # Use EFFECTIVE crop dims as the displayed base after rotation + cx, cy, cw, ch = self._get_effective_crop_rect_for_frame(frame_number) + new_w = int(cw * self.zoom_factor) + new_h = int(ch * self.zoom_factor) cropped_due_to_zoom = (self.zoom_factor != 1.0) and (new_w > self.window_width or new_h > self.window_height) visible_w = new_w if not cropped_due_to_zoom else min(new_w, self.window_width) visible_h = new_h if not cropped_due_to_zoom else min(new_h, self.window_height) @@ -1377,7 +1374,6 @@ class VideoEditor: rx = zx / max(1e-6, self.zoom_factor) ry = zy / max(1e-6, self.zoom_factor) # Unapply current EFFECTIVE crop to get PRE-crop rotated coords - cx, cy, cw, ch = self._get_effective_crop_rect_for_frame(frame_number) rx = rx + cx ry = ry + cy return int(round(rx)), int(round(ry))