From 7371cd79e49ee1cd9b6399b08cf8b38c635117f4 Mon Sep 17 00:00:00 2001 From: OverloadedOrama <35376950+OverloadedOrama@users.noreply.github.com> Date: Wed, 3 Jun 2020 02:53:15 +0300 Subject: [PATCH] Fixed image effects Also replaced flip_image_horizontal() and flip_image_vertical() with just flip_image() --- src/Main.gd | 36 ++++++++++++++------------------- src/UI/Dialogs/HSVDialog.gd | 16 +++++++-------- src/UI/Dialogs/OutlineDialog.gd | 2 +- 3 files changed, 24 insertions(+), 30 deletions(-) diff --git a/src/Main.gd b/src/Main.gd index 4cda7c35c..d69fd39d9 100644 --- a/src/Main.gd +++ b/src/Main.gd @@ -436,33 +436,27 @@ func crop_image() -> void: Global.undo_redo.commit_action() -func flip_image_horizontal() -> void: - var canvas : Canvas = Global.canvas - canvas.handle_undo("Draw") - canvas.layers[Global.current_layer].image.unlock() - canvas.layers[Global.current_layer].image.flip_x() - canvas.layers[Global.current_layer].image.lock() - canvas.handle_redo("Draw") - - -func flip_image_vertical() -> void: - var canvas : Canvas = Global.canvas - canvas.handle_undo("Draw") - canvas.layers[Global.current_layer].image.unlock() - canvas.layers[Global.current_layer].image.flip_y() - canvas.layers[Global.current_layer].image.lock() - canvas.handle_redo("Draw") +func flip_image(horizontal : bool) -> void: + var image : Image = Global.frames[Global.current_frame].cels[Global.current_layer].image + Global.canvas.handle_undo("Draw") + image.unlock() + if horizontal: + image.flip_x() + else: + image.flip_y() + image.lock() + Global.canvas.handle_redo("Draw") func show_rotate_image_popup() -> void: - var image : Image = Global.canvas.layers[Global.current_layer].image + var image : Image = Global.frames[Global.current_frame].cels[Global.current_layer].image $RotateImage.set_sprite(image) $RotateImage.popup_centered() Global.dialog_open(true) func invert_image_colors() -> void: - var image : Image = Global.canvas.layers[Global.current_layer].image + var image : Image = Global.frames[Global.current_frame].cels[Global.current_layer].image Global.canvas.handle_undo("Draw") for xx in image.get_size().x: for yy in image.get_size().y: @@ -474,7 +468,7 @@ func invert_image_colors() -> void: func desaturate_image() -> void: - var image : Image = Global.canvas.layers[Global.current_layer].image + var image : Image = Global.frames[Global.current_frame].cels[Global.current_layer].image Global.canvas.handle_undo("Draw") for xx in image.get_size().x: for yy in image.get_size().y: @@ -508,10 +502,10 @@ func image_menu_id_pressed(id : int) -> void: crop_image() 2: # Flip Horizontal - flip_image_horizontal() + flip_image(true) 3: # Flip Vertical - flip_image_vertical() + flip_image(false) 4: # Rotate show_rotate_image_popup() diff --git a/src/UI/Dialogs/HSVDialog.gd b/src/UI/Dialogs/HSVDialog.gd index 000d716b7..d497a160e 100644 --- a/src/UI/Dialogs/HSVDialog.gd +++ b/src/UI/Dialogs/HSVDialog.gd @@ -1,6 +1,6 @@ extends WindowDialog -var current_layer : Image +var current_cel : Image var preview_image : Image var preview_texture : ImageTexture @@ -16,15 +16,15 @@ onready var preview = $MarginContainer/VBoxContainer/TextureRect func _ready() -> void: - current_layer = Image.new() + current_cel = Image.new() preview_image = Image.new() preview_texture = ImageTexture.new() preview_texture.flags = 0 func _on_HSVDialog_about_to_show() -> void: - current_layer = Global.canvas.layers[Global.current_layer].image - preview_image.copy_from(current_layer) + current_cel = Global.frames[Global.current_frame].cels[Global.current_layer].image + preview_image.copy_from(current_cel) update_preview() @@ -35,9 +35,9 @@ func _on_Cancel_pressed() -> void: func _on_Apply_pressed() -> void: Global.canvas.handle_undo("Draw") - DrawingAlgos.adjust_hsv(current_layer,0,hue_slider.value) - DrawingAlgos.adjust_hsv(current_layer,1,sat_slider.value) - DrawingAlgos.adjust_hsv(current_layer,2,val_slider.value) + DrawingAlgos.adjust_hsv(current_cel,0,hue_slider.value) + DrawingAlgos.adjust_hsv(current_cel,1,sat_slider.value) + DrawingAlgos.adjust_hsv(current_cel,2,val_slider.value) Global.canvas.update_texture(Global.current_layer) Global.canvas.handle_redo("Draw") reset() @@ -56,7 +56,7 @@ func reset() -> void: func update_preview() -> void: - preview_image.copy_from(current_layer) + preview_image.copy_from(current_cel) DrawingAlgos.adjust_hsv(preview_image,0,hue_slider.value) DrawingAlgos.adjust_hsv(preview_image,1,sat_slider.value) DrawingAlgos.adjust_hsv(preview_image,2,val_slider.value) diff --git a/src/UI/Dialogs/OutlineDialog.gd b/src/UI/Dialogs/OutlineDialog.gd index 2bf74ffc3..e3e777f90 100644 --- a/src/UI/Dialogs/OutlineDialog.gd +++ b/src/UI/Dialogs/OutlineDialog.gd @@ -10,7 +10,7 @@ func _on_OutlineDialog_confirmed() -> void: var diagonal : bool = $OptionsContainer/DiagonalCheckBox.pressed var inside_image : bool = $OptionsContainer/InsideImageCheckBox.pressed - var image : Image = Global.canvas.layers[Global.current_layer].image + var image : Image = Global.frames[Global.current_frame].cels[Global.current_layer].image if image.is_invisible(): return var new_image := Image.new()