mirror of
https://github.com/tonytins/CozyPixelStudio.git
synced 2025-05-05 12:24:48 -04:00
63 lines
2.1 KiB
GDScript
63 lines
2.1 KiB
GDScript
extends ImageEffect
|
|
|
|
|
|
func _ready() -> void:
|
|
$VBoxContainer/HBoxContainer2/OptionButton.add_item("Rotxel")
|
|
$VBoxContainer/HBoxContainer2/OptionButton.add_item("Upscale, Rotate and Downscale")
|
|
$VBoxContainer/HBoxContainer2/OptionButton.add_item("Nearest neighbour")
|
|
|
|
|
|
func set_nodes() -> void:
|
|
preview = $VBoxContainer/Preview
|
|
|
|
|
|
func set_sprite(sprite : Image) -> void:
|
|
preview_image.copy_from(sprite)
|
|
current_cel = sprite
|
|
preview_texture.create_from_image(preview_image, 0)
|
|
preview.texture = preview_texture
|
|
|
|
|
|
func _about_to_show() -> void:
|
|
._about_to_show()
|
|
$VBoxContainer/HBoxContainer/HSlider.value = 0
|
|
# set_sprite(current_cel)
|
|
|
|
|
|
func _confirmed() -> void:
|
|
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)
|
|
"Upscale, Rotate and Downscale":
|
|
DrawingAlgos.fake_rotsprite(current_cel,$VBoxContainer/HBoxContainer/HSlider.value*PI/180)
|
|
Global.canvas.handle_redo("Draw")
|
|
$VBoxContainer/HBoxContainer/HSlider.value = 0
|
|
|
|
|
|
func _on_HSlider_value_changed(_value : float) -> void:
|
|
update_preview()
|
|
$VBoxContainer/HBoxContainer/SpinBox.value = $VBoxContainer/HBoxContainer/HSlider.value
|
|
|
|
|
|
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()
|