1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-02-13 01:03:07 +00:00
Pixelorama/src/UI/Dialogs/ImageEffects/RotateImage.gd

56 lines
1.9 KiB
GDScript3
Raw Normal View History

extends ImageEffect
2020-01-27 15:23:52 +00:00
func _ready() -> void:
2020-01-27 15:23:52 +00:00
$VBoxContainer/HBoxContainer2/OptionButton.add_item("Rotxel")
2020-04-03 11:20:59 +00:00
$VBoxContainer/HBoxContainer2/OptionButton.add_item("Upscale, Rotate and Downscale")
2020-02-03 16:55:55 +00:00
$VBoxContainer/HBoxContainer2/OptionButton.add_item("Nearest neighbour")
2020-01-27 15:23:52 +00:00
func set_nodes() -> void:
preview = $VBoxContainer/Preview
2020-01-27 15:23:52 +00:00
func _about_to_show() -> void:
._about_to_show()
$VBoxContainer/HBoxContainer/HSlider.value = 0
2020-01-27 15:23:52 +00:00
func _confirmed() -> void:
2020-01-27 15:23:52 +00:00
Global.canvas.handle_undo("Draw")
match $VBoxContainer/HBoxContainer2/OptionButton.text:
"Rotxel":
DrawingAlgos.rotxel(current_cel,$VBoxContainer/HBoxContainer/HSlider.value*PI/180)
"Nearest neighbour":
DrawingAlgos.nn_rotate(current_cel,$VBoxContainer/HBoxContainer/HSlider.value*PI/180)
2020-04-03 11:20:59 +00:00
"Upscale, Rotate and Downscale":
DrawingAlgos.fake_rotsprite(current_cel,$VBoxContainer/HBoxContainer/HSlider.value*PI/180)
2020-01-27 15:23:52 +00:00
Global.canvas.handle_redo("Draw")
$VBoxContainer/HBoxContainer/HSlider.value = 0
2020-02-03 16:55:55 +00:00
func _on_HSlider_value_changed(_value : float) -> void:
update_preview()
$VBoxContainer/HBoxContainer/SpinBox.value = $VBoxContainer/HBoxContainer/HSlider.value
2020-02-03 16:55:55 +00:00
func _on_SpinBox_value_changed(_value : float) -> void:
$VBoxContainer/HBoxContainer/HSlider.value = $VBoxContainer/HBoxContainer/SpinBox.value
func update_preview() -> void:
preview_image.copy_from(current_cel)
match $VBoxContainer/HBoxContainer2/OptionButton.text:
"Rotxel":
DrawingAlgos.rotxel(preview_image,$VBoxContainer/HBoxContainer/HSlider.value*PI/180)
"Nearest neighbour":
DrawingAlgos.nn_rotate(preview_image,$VBoxContainer/HBoxContainer/HSlider.value*PI/180)
"Upscale, Rotate and Downscale":
DrawingAlgos.fake_rotsprite(preview_image,$VBoxContainer/HBoxContainer/HSlider.value*PI/180)
preview_texture.create_from_image(preview_image, 0)
preview.texture = preview_texture
func _on_OptionButton_item_selected(_id : int) -> void:
update_preview()