From 60c5ec9ad54b1863296bc75f676333ae7eb7ac1b Mon Sep 17 00:00:00 2001 From: Darshan Phaldesai <51489635+luiq54@users.noreply.github.com> Date: Wed, 26 Aug 2020 16:59:49 +0530 Subject: [PATCH] Affect area now affects the previews. (#320) --- src/Classes/ImageEffect.gd | 6 ++++++ src/UI/Dialogs/ImageEffects/DesaturateDialog.gd | 6 +++++- src/UI/Dialogs/ImageEffects/FlipImageDialog.gd | 6 +++++- src/UI/Dialogs/ImageEffects/HSVDialog.gd | 6 +++++- src/UI/Dialogs/ImageEffects/InvertColorsDialog.gd | 6 +++++- src/UI/Dialogs/ImageEffects/OutlineDialog.gd | 6 +++++- 6 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/Classes/ImageEffect.gd b/src/Classes/ImageEffect.gd index 49f6d0e82..e4a90b81c 100644 --- a/src/Classes/ImageEffect.gd +++ b/src/Classes/ImageEffect.gd @@ -8,6 +8,7 @@ enum {CEL, FRAME, ALL_FRAMES, ALL_PROJECTS} var affect : int = CEL var pixels := [] var current_cel : Image +var current_frame : Image var preview_image : Image var preview_texture : ImageTexture var preview : TextureRect @@ -18,6 +19,8 @@ var affect_option_button : OptionButton func _ready() -> void: set_nodes() current_cel = Image.new() + current_frame = Image.new() + current_frame.create(Global.current_project.size.x, Global.current_project.size.y, false, Image.FORMAT_RGBA8) preview_image = Image.new() preview_texture = ImageTexture.new() connect("about_to_show", self, "_about_to_show") @@ -31,6 +34,8 @@ func _ready() -> void: func _about_to_show() -> void: current_cel = Global.current_project.frames[Global.current_project.current_frame].cels[Global.current_project.current_layer].image + var frame = Global.current_project.frames[Global.current_project.current_frame] + Export.blend_layers(current_frame, frame) if selection_checkbox: _on_SelectionCheckBox_toggled(selection_checkbox.pressed) update_transparent_background_size() @@ -58,6 +63,7 @@ func _on_SelectionCheckBox_toggled(button_pressed : bool) -> void: func _on_AffectOptionButton_item_selected(index : int) -> void: affect = index + update_preview() func update_preview() -> void: diff --git a/src/UI/Dialogs/ImageEffects/DesaturateDialog.gd b/src/UI/Dialogs/ImageEffects/DesaturateDialog.gd index 43a9e6266..6e26c8a37 100644 --- a/src/UI/Dialogs/ImageEffects/DesaturateDialog.gd +++ b/src/UI/Dialogs/ImageEffects/DesaturateDialog.gd @@ -69,7 +69,11 @@ func _on_AButton_toggled(button_pressed : bool) -> void: func update_preview() -> void: - preview_image.copy_from(current_cel) + match affect: + CEL: + preview_image.copy_from(current_cel) + _: + preview_image.copy_from(current_frame) DrawingAlgos.desaturate_image(preview_image, pixels, red, green, blue, alpha) preview_image.unlock() preview_texture.create_from_image(preview_image, 0) diff --git a/src/UI/Dialogs/ImageEffects/FlipImageDialog.gd b/src/UI/Dialogs/ImageEffects/FlipImageDialog.gd index 1b8584afa..d71e656a2 100644 --- a/src/UI/Dialogs/ImageEffects/FlipImageDialog.gd +++ b/src/UI/Dialogs/ImageEffects/FlipImageDialog.gd @@ -60,7 +60,11 @@ func _on_SelectionCheckBox_toggled(button_pressed : bool) -> void: func update_preview() -> void: - preview_image.copy_from(current_cel) + match affect: + CEL: + preview_image.copy_from(current_cel) + _: + preview_image.copy_from(current_frame) flip_image(preview_image, pixels) preview_texture.create_from_image(preview_image, 0) preview.texture = preview_texture diff --git a/src/UI/Dialogs/ImageEffects/HSVDialog.gd b/src/UI/Dialogs/ImageEffects/HSVDialog.gd index f664660b5..de763ebfa 100644 --- a/src/UI/Dialogs/ImageEffects/HSVDialog.gd +++ b/src/UI/Dialogs/ImageEffects/HSVDialog.gd @@ -65,7 +65,11 @@ func reset() -> void: func update_preview() -> void: - preview_image.copy_from(current_cel) + match affect: + CEL: + preview_image.copy_from(current_cel) + _: + preview_image.copy_from(current_frame) DrawingAlgos.adjust_hsv(preview_image, hue_slider.value, sat_slider.value, val_slider.value, pixels) preview_texture.create_from_image(preview_image, 0) preview.texture = preview_texture diff --git a/src/UI/Dialogs/ImageEffects/InvertColorsDialog.gd b/src/UI/Dialogs/ImageEffects/InvertColorsDialog.gd index ecefbae0c..89d9908d0 100644 --- a/src/UI/Dialogs/ImageEffects/InvertColorsDialog.gd +++ b/src/UI/Dialogs/ImageEffects/InvertColorsDialog.gd @@ -69,7 +69,11 @@ func _on_AButton_toggled(button_pressed : bool) -> void: func update_preview() -> void: - preview_image.copy_from(current_cel) + match affect: + CEL: + preview_image.copy_from(current_cel) + _: + preview_image.copy_from(current_frame) DrawingAlgos.invert_image_colors(preview_image, pixels, red, green, blue, alpha) preview_image.unlock() preview_texture.create_from_image(preview_image, 0) diff --git a/src/UI/Dialogs/ImageEffects/OutlineDialog.gd b/src/UI/Dialogs/ImageEffects/OutlineDialog.gd index 816c733ae..0a79c24ab 100644 --- a/src/UI/Dialogs/ImageEffects/OutlineDialog.gd +++ b/src/UI/Dialogs/ImageEffects/OutlineDialog.gd @@ -76,7 +76,11 @@ func _on_InsideImageCheckBox_toggled(button_pressed : bool) -> void: func update_preview() -> void: - preview_image.copy_from(current_cel) + match affect: + CEL: + preview_image.copy_from(current_cel) + _: + preview_image.copy_from(current_frame) DrawingAlgos.generate_outline(preview_image, pixels, color, thickness, diagonal, inside_image) preview_texture.create_from_image(preview_image, 0) preview.texture = preview_texture