From e92b2b3babdf3433af3917a7ee59410e61651228 Mon Sep 17 00:00:00 2001 From: luiq54 Date: Fri, 3 Apr 2020 16:50:59 +0530 Subject: [PATCH] Implement fake_rotsprite --- Prefabs/Dialogs/RotateImage.gd | 5 +++++ Scripts/Global.gd | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/Prefabs/Dialogs/RotateImage.gd b/Prefabs/Dialogs/RotateImage.gd index 2de59a5f3..23e6e7c99 100644 --- a/Prefabs/Dialogs/RotateImage.gd +++ b/Prefabs/Dialogs/RotateImage.gd @@ -9,6 +9,7 @@ func _ready() -> void: texture.flags = 0 aux_img = Image.new() $VBoxContainer/HBoxContainer2/OptionButton.add_item("Rotxel") + $VBoxContainer/HBoxContainer2/OptionButton.add_item("Upscale, Rotate and Downscale") $VBoxContainer/HBoxContainer2/OptionButton.add_item("Nearest neighbour") func set_sprite(sprite : Image) -> void: @@ -34,6 +35,8 @@ func _on_RotateImage_confirmed() -> void: Global.rotxel(layer,$VBoxContainer/HBoxContainer/HSlider.value*PI/180) "Nearest neighbour": Global.nn_rotate(layer,$VBoxContainer/HBoxContainer/HSlider.value*PI/180) + "Upscale, Rotate and Downscale": + Global.fake_rotsprite(layer,$VBoxContainer/HBoxContainer/HSlider.value*PI/180) Global.canvas.handle_redo("Draw") $VBoxContainer/HBoxContainer/HSlider.value = 0 @@ -45,6 +48,8 @@ func rotate() -> void: Global.rotxel(sprite,$VBoxContainer/HBoxContainer/HSlider.value*PI/180) "Nearest neighbour": Global.nn_rotate(sprite,$VBoxContainer/HBoxContainer/HSlider.value*PI/180) + "Upscale, Rotate and Downscale": + Global.fake_rotsprite(sprite,$VBoxContainer/HBoxContainer/HSlider.value*PI/180) texture.create_from_image(sprite, 0) diff --git a/Scripts/Global.gd b/Scripts/Global.gd index 50957ce3c..1fa918e0e 100644 --- a/Scripts/Global.gd +++ b/Scripts/Global.gd @@ -934,6 +934,11 @@ func rotxel(sprite : Image, angle : float) -> void: sprite.unlock() aux.unlock() +func fake_rotsprite(sprite : Image, angle : float) -> void: + sprite.copy_from(scale3X(sprite)) + nn_rotate(sprite,angle) + sprite.resize(sprite.get_width()/3,sprite.get_height()/3,0) + func nn_rotate(sprite : Image, angle : float) -> void: var aux : Image = Image.new() aux.copy_from(sprite)