diff --git a/CHANGELOG.md b/CHANGELOG.md index de6c272d0..2de50b520 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ PinyaColada, RĂ©mi Verschelde (akien-mga), dasimonde, gschwind, AbhinavKDev - Fixed issues where fully transparent color could not be picked. One of these cases was [#364](https://github.com/Orama-Interactive/Pixelorama/issues/364). - Fixed "Export" option in the File menu not working properly and not remembering the directory path and file name when switching between projects (tabs). - When opening a .pxo project which has guides, they will no longer be added to the project at the first tab too. +- Symmetry guides now adjust their position when the image is being resized. ([#379](https://github.com/Orama-Interactive/Pixelorama/issues/379)) - Fixed Chinese and Korean characters not displaying properly in the Splash dialog and the About dialog. - Fixed crash when importing an incorrectly formatted GIMP Color Palette file. ([#363](https://github.com/Orama-Interactive/Pixelorama/issues/363)) - Using the lighten/darken on pixels with an alpha value of 0 no longer has an effect on them. diff --git a/src/Autoload/DrawingAlgos.gd b/src/Autoload/DrawingAlgos.gd index b8740bcd5..baa8d103a 100644 --- a/src/Autoload/DrawingAlgos.gd +++ b/src/Autoload/DrawingAlgos.gd @@ -235,9 +235,7 @@ func colorDistance(c1 : Color, c2 : Color) -> float: # Image effects func scale_image(width : int, height : int, interpolation : int) -> void: - Global.current_project.undos += 1 - Global.current_project.undo_redo.create_action("Scale") - Global.current_project.undo_redo.add_do_property(Global.current_project, "size", Vector2(width, height).floor()) + general_do_scale(width, height) for f in Global.current_project.frames: for i in range(f.cels.size() - 1, -1, -1): @@ -254,10 +252,7 @@ func scale_image(width : int, height : int, interpolation : int) -> void: Global.current_project.undo_redo.add_do_property(f.cels[i].image, "data", sprite.data) Global.current_project.undo_redo.add_undo_property(f.cels[i].image, "data", f.cels[i].image.data) - Global.current_project.undo_redo.add_undo_property(Global.current_project, "size", Global.current_project.size) - Global.current_project.undo_redo.add_undo_method(Global, "undo") - Global.current_project.undo_redo.add_do_method(Global, "redo") - Global.current_project.undo_redo.commit_action() + general_undo_scale() func crop_image(image : Image) -> void: @@ -284,9 +279,7 @@ func crop_image(image : Image) -> void: var width := used_rect.size.x var height := used_rect.size.y - Global.current_project.undos += 1 - Global.current_project.undo_redo.create_action("Scale") - Global.current_project.undo_redo.add_do_property(Global.current_project, "size", Vector2(width, height).floor()) + general_do_scale(width, height) for f in Global.current_project.frames: # Loop through all the layers to crop them for j in range(Global.current_project.layers.size() - 1, -1, -1): @@ -294,16 +287,11 @@ func crop_image(image : Image) -> void: Global.current_project.undo_redo.add_do_property(f.cels[j].image, "data", sprite.data) Global.current_project.undo_redo.add_undo_property(f.cels[j].image, "data", f.cels[j].image.data) - Global.current_project.undo_redo.add_undo_property(Global.current_project, "size", Global.current_project.size) - Global.current_project.undo_redo.add_undo_method(Global, "undo") - Global.current_project.undo_redo.add_do_method(Global, "redo") - Global.current_project.undo_redo.commit_action() + general_undo_scale() func resize_canvas(width : int, height : int, offset_x : int, offset_y : int) -> void: - Global.current_project.undos += 1 - Global.current_project.undo_redo.create_action("Scale") - Global.current_project.undo_redo.add_do_property(Global.current_project, "size", Vector2(width, height).floor()) + general_do_scale(width, height) for f in Global.current_project.frames: for c in f.cels: var sprite := Image.new() @@ -312,7 +300,36 @@ func resize_canvas(width : int, height : int, offset_x : int, offset_y : int) -> Global.current_project.undo_redo.add_do_property(c.image, "data", sprite.data) Global.current_project.undo_redo.add_undo_property(c.image, "data", c.image.data) + general_undo_scale() + + +func general_do_scale(width : int, height : int) -> void: + var x_ratio = Global.current_project.size.x / width + var y_ratio = Global.current_project.size.y / height + var new_x_symmetry_point = Global.current_project.x_symmetry_point / x_ratio + var new_y_symmetry_point = Global.current_project.y_symmetry_point / y_ratio + var new_x_symmetry_axis_points = Global.current_project.x_symmetry_axis.points + var new_y_symmetry_axis_points = Global.current_project.y_symmetry_axis.points + new_x_symmetry_axis_points[0].y /= y_ratio + new_x_symmetry_axis_points[1].y /= y_ratio + new_y_symmetry_axis_points[0].x /= x_ratio + new_y_symmetry_axis_points[1].x /= x_ratio + + Global.current_project.undos += 1 + Global.current_project.undo_redo.create_action("Scale") + Global.current_project.undo_redo.add_do_property(Global.current_project, "size", Vector2(width, height).floor()) + Global.current_project.undo_redo.add_do_property(Global.current_project, "x_symmetry_point", new_x_symmetry_point) + Global.current_project.undo_redo.add_do_property(Global.current_project, "y_symmetry_point", new_y_symmetry_point) + Global.current_project.undo_redo.add_do_property(Global.current_project.x_symmetry_axis, "points", new_x_symmetry_axis_points) + Global.current_project.undo_redo.add_do_property(Global.current_project.y_symmetry_axis, "points", new_y_symmetry_axis_points) + + +func general_undo_scale() -> void: Global.current_project.undo_redo.add_undo_property(Global.current_project, "size", Global.current_project.size) + Global.current_project.undo_redo.add_undo_property(Global.current_project, "x_symmetry_point", Global.current_project.x_symmetry_point) + Global.current_project.undo_redo.add_undo_property(Global.current_project, "y_symmetry_point", Global.current_project.y_symmetry_point) + Global.current_project.undo_redo.add_undo_property(Global.current_project.x_symmetry_axis, "points", Global.current_project.x_symmetry_axis.points) + Global.current_project.undo_redo.add_undo_property(Global.current_project.y_symmetry_axis, "points", Global.current_project.y_symmetry_axis.points) Global.current_project.undo_redo.add_undo_method(Global, "undo") Global.current_project.undo_redo.add_do_method(Global, "redo") Global.current_project.undo_redo.commit_action()