From eff79337e067587c67ba9cf8d353fe6dcc792c4a Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas Date: Tue, 23 Jan 2024 19:54:23 +0200 Subject: [PATCH] Fix selection being incorrect when the image is being scaled (mostly when being made smaller). --- src/Autoload/DrawingAlgos.gd | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Autoload/DrawingAlgos.gd b/src/Autoload/DrawingAlgos.gd index 3e7f5ede8..84f638213 100644 --- a/src/Autoload/DrawingAlgos.gd +++ b/src/Autoload/DrawingAlgos.gd @@ -557,6 +557,12 @@ func general_do_and_undo_scale( var x_ratio = project.size.x / width var y_ratio = project.size.y / height + var selection_map_copy := SelectionMap.new() + selection_map_copy.copy_from(project.selection_map) + selection_map_copy.crop(size.x, size.y) + redo_data[project.selection_map] = selection_map_copy.data + undo_data[project.selection_map] = project.selection_map.data + var new_x_symmetry_point = project.x_symmetry_point / x_ratio var new_y_symmetry_point = project.y_symmetry_point / y_ratio var new_x_symmetry_axis_points = project.x_symmetry_axis.points @@ -569,14 +575,12 @@ func general_do_and_undo_scale( project.undos += 1 project.undo_redo.create_action("Scale") project.undo_redo.add_do_property(project, "size", size) - project.undo_redo.add_do_method(project.selection_map, "crop", size.x, size.y) project.undo_redo.add_do_property(project, "x_symmetry_point", new_x_symmetry_point) project.undo_redo.add_do_property(project, "y_symmetry_point", new_y_symmetry_point) project.undo_redo.add_do_property(project.x_symmetry_axis, "points", new_x_symmetry_axis_points) project.undo_redo.add_do_property(project.y_symmetry_axis, "points", new_y_symmetry_axis_points) Global.undo_redo_compress_images(redo_data, undo_data) project.undo_redo.add_undo_property(project, "size", project.size) - project.undo_redo.add_undo_method(project.selection_map, "crop", project.size.x, project.size.y) project.undo_redo.add_undo_property(project, "x_symmetry_point", project.x_symmetry_point) project.undo_redo.add_undo_property(project, "y_symmetry_point", project.y_symmetry_point) project.undo_redo.add_undo_property(