From 909f9480ccd69ff1147c2f855b4d520a8051bc6c Mon Sep 17 00:00:00 2001 From: Manolis Papadeas <35376950+OverloadedOrama@users.noreply.github.com> Date: Sun, 16 May 2021 03:19:49 +0300 Subject: [PATCH] Correct rectangular and elliptical selection mirroring --- src/Tools/SelectionTools/EllipseSelect.gd | 13 ++++++------ src/Tools/SelectionTools/RectSelect.gd | 24 +++++++++++------------ 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/Tools/SelectionTools/EllipseSelect.gd b/src/Tools/SelectionTools/EllipseSelect.gd index d699601cc..1924a8bc4 100644 --- a/src/Tools/SelectionTools/EllipseSelect.gd +++ b/src/Tools/SelectionTools/EllipseSelect.gd @@ -76,21 +76,22 @@ func apply_selection(_position : Vector2) -> void: if _rect.size != Vector2.ZERO: var selection_bitmap_copy : BitMap = project.selection_bitmap.duplicate() set_ellipse(selection_bitmap_copy, _rect.position) + # Handle mirroring if tool_slot.horizontal_mirror: var mirror_x_rect := _rect - mirror_x_rect.position.x = Global.current_project.x_symmetry_point - _rect.position.x - mirror_x_rect.end.x = Global.current_project.x_symmetry_point - _rect.end.x + mirror_x_rect.position.x = Global.current_project.x_symmetry_point - _rect.position.x + 1 + mirror_x_rect.end.x = Global.current_project.x_symmetry_point - _rect.end.x + 1 set_ellipse(selection_bitmap_copy, mirror_x_rect.abs().position) if tool_slot.vertical_mirror: var mirror_xy_rect := mirror_x_rect - mirror_xy_rect.position.y = Global.current_project.y_symmetry_point - _rect.position.y - mirror_xy_rect.end.y = Global.current_project.y_symmetry_point - _rect.end.y + mirror_xy_rect.position.y = Global.current_project.y_symmetry_point - _rect.position.y + 1 + mirror_xy_rect.end.y = Global.current_project.y_symmetry_point - _rect.end.y + 1 set_ellipse(selection_bitmap_copy, mirror_xy_rect.abs().position) if tool_slot.vertical_mirror: var mirror_y_rect := _rect - mirror_y_rect.position.y = Global.current_project.y_symmetry_point - _rect.position.y - mirror_y_rect.end.y = Global.current_project.y_symmetry_point - _rect.end.y + mirror_y_rect.position.y = Global.current_project.y_symmetry_point - _rect.position.y + 1 + mirror_y_rect.end.y = Global.current_project.y_symmetry_point - _rect.end.y + 1 set_ellipse(selection_bitmap_copy, mirror_y_rect.abs().position) project.selection_bitmap = selection_bitmap_copy diff --git a/src/Tools/SelectionTools/RectSelect.gd b/src/Tools/SelectionTools/RectSelect.gd index d413d4ef9..3e147709b 100644 --- a/src/Tools/SelectionTools/RectSelect.gd +++ b/src/Tools/SelectionTools/RectSelect.gd @@ -61,18 +61,18 @@ func draw_preview() -> void: # Handle mirroring if tool_slot.horizontal_mirror: var mirror_x_rect := _rect - mirror_x_rect.position.x = Global.current_project.x_symmetry_point - _rect.position.x - mirror_x_rect.end.x = Global.current_project.x_symmetry_point - _rect.end.x + mirror_x_rect.position.x = Global.current_project.x_symmetry_point - _rect.position.x + 1 + mirror_x_rect.end.x = Global.current_project.x_symmetry_point - _rect.end.x + 1 canvas.draw_rect(mirror_x_rect, Color.black, false) if tool_slot.vertical_mirror: var mirror_xy_rect := mirror_x_rect - mirror_xy_rect.position.y = Global.current_project.y_symmetry_point - _rect.position.y - mirror_xy_rect.end.y = Global.current_project.y_symmetry_point - _rect.end.y + mirror_xy_rect.position.y = Global.current_project.y_symmetry_point - _rect.position.y + 1 + mirror_xy_rect.end.y = Global.current_project.y_symmetry_point - _rect.end.y + 1 canvas.draw_rect(mirror_xy_rect, Color.black, false) if tool_slot.vertical_mirror: var mirror_y_rect := _rect - mirror_y_rect.position.y = Global.current_project.y_symmetry_point - _rect.position.y - mirror_y_rect.end.y = Global.current_project.y_symmetry_point - _rect.end.y + mirror_y_rect.position.y = Global.current_project.y_symmetry_point - _rect.position.y + 1 + mirror_y_rect.end.y = Global.current_project.y_symmetry_point - _rect.end.y + 1 canvas.draw_rect(mirror_y_rect, Color.black, false) canvas.draw_set_transform(canvas.position, canvas.rotation, canvas.scale) @@ -93,18 +93,18 @@ func apply_selection(_position) -> void: # Handle mirroring if tool_slot.horizontal_mirror: var mirror_x_rect := _rect - mirror_x_rect.position.x = Global.current_project.x_symmetry_point - _rect.position.x - mirror_x_rect.end.x = Global.current_project.x_symmetry_point - _rect.end.x + mirror_x_rect.position.x = Global.current_project.x_symmetry_point - _rect.position.x + 1 + mirror_x_rect.end.x = Global.current_project.x_symmetry_point - _rect.end.x + 1 Global.canvas.selection.select_rect(mirror_x_rect.abs(), operation) if tool_slot.vertical_mirror: var mirror_xy_rect := mirror_x_rect - mirror_xy_rect.position.y = Global.current_project.y_symmetry_point - _rect.position.y - mirror_xy_rect.end.y = Global.current_project.y_symmetry_point - _rect.end.y + mirror_xy_rect.position.y = Global.current_project.y_symmetry_point - _rect.position.y + 1 + mirror_xy_rect.end.y = Global.current_project.y_symmetry_point - _rect.end.y + 1 Global.canvas.selection.select_rect(mirror_xy_rect.abs(), operation) if tool_slot.vertical_mirror: var mirror_y_rect := _rect - mirror_y_rect.position.y = Global.current_project.y_symmetry_point - _rect.position.y - mirror_y_rect.end.y = Global.current_project.y_symmetry_point - _rect.end.y + mirror_y_rect.position.y = Global.current_project.y_symmetry_point - _rect.position.y + 1 + mirror_y_rect.end.y = Global.current_project.y_symmetry_point - _rect.end.y + 1 Global.canvas.selection.select_rect(mirror_y_rect.abs(), operation) Global.canvas.selection.commit_undo("Rectangle Select", undo_data)