mirror of
https://github.com/tonytins/CozyPixelStudio.git
synced 2025-05-05 22:44:48 -04:00
Merge pull request #182 from luiq54/fake_rotsprite
Rotsprite-like Rotation
This commit is contained in:
commit
f2ed5ade8a
2 changed files with 10 additions and 0 deletions
|
@ -9,6 +9,7 @@ func _ready() -> void:
|
||||||
texture.flags = 0
|
texture.flags = 0
|
||||||
aux_img = Image.new()
|
aux_img = Image.new()
|
||||||
$VBoxContainer/HBoxContainer2/OptionButton.add_item("Rotxel")
|
$VBoxContainer/HBoxContainer2/OptionButton.add_item("Rotxel")
|
||||||
|
$VBoxContainer/HBoxContainer2/OptionButton.add_item("Upscale, Rotate and Downscale")
|
||||||
$VBoxContainer/HBoxContainer2/OptionButton.add_item("Nearest neighbour")
|
$VBoxContainer/HBoxContainer2/OptionButton.add_item("Nearest neighbour")
|
||||||
|
|
||||||
func set_sprite(sprite : Image) -> void:
|
func set_sprite(sprite : Image) -> void:
|
||||||
|
@ -34,6 +35,8 @@ func _on_RotateImage_confirmed() -> void:
|
||||||
Global.rotxel(layer,$VBoxContainer/HBoxContainer/HSlider.value*PI/180)
|
Global.rotxel(layer,$VBoxContainer/HBoxContainer/HSlider.value*PI/180)
|
||||||
"Nearest neighbour":
|
"Nearest neighbour":
|
||||||
Global.nn_rotate(layer,$VBoxContainer/HBoxContainer/HSlider.value*PI/180)
|
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")
|
Global.canvas.handle_redo("Draw")
|
||||||
$VBoxContainer/HBoxContainer/HSlider.value = 0
|
$VBoxContainer/HBoxContainer/HSlider.value = 0
|
||||||
|
|
||||||
|
@ -45,6 +48,8 @@ func rotate() -> void:
|
||||||
Global.rotxel(sprite,$VBoxContainer/HBoxContainer/HSlider.value*PI/180)
|
Global.rotxel(sprite,$VBoxContainer/HBoxContainer/HSlider.value*PI/180)
|
||||||
"Nearest neighbour":
|
"Nearest neighbour":
|
||||||
Global.nn_rotate(sprite,$VBoxContainer/HBoxContainer/HSlider.value*PI/180)
|
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)
|
texture.create_from_image(sprite, 0)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -936,6 +936,11 @@ func rotxel(sprite : Image, angle : float) -> void:
|
||||||
sprite.unlock()
|
sprite.unlock()
|
||||||
aux.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:
|
func nn_rotate(sprite : Image, angle : float) -> void:
|
||||||
var aux : Image = Image.new()
|
var aux : Image = Image.new()
|
||||||
aux.copy_from(sprite)
|
aux.copy_from(sprite)
|
||||||
|
|
Loading…
Add table
Reference in a new issue