2020-08-26 14:49:46 +00:00
|
|
|
extends ImageEffect
|
2020-01-27 15:23:52 +00:00
|
|
|
|
|
|
|
|
2020-02-09 16:06:03 +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
|
|
|
|
|
|
|
|
2020-08-26 14:49:46 +00:00
|
|
|
func set_nodes() -> void:
|
|
|
|
preview = $VBoxContainer/Preview
|
2020-01-27 15:23:52 +00:00
|
|
|
|
|
|
|
|
2020-08-26 14:49:46 +00:00
|
|
|
func _about_to_show() -> void:
|
|
|
|
._about_to_show()
|
|
|
|
$VBoxContainer/HBoxContainer/HSlider.value = 0
|
2020-01-27 15:23:52 +00:00
|
|
|
|
2020-08-26 14:49:46 +00:00
|
|
|
|
|
|
|
func _confirmed() -> void:
|
2020-01-27 15:23:52 +00:00
|
|
|
Global.canvas.handle_undo("Draw")
|
2020-02-04 15:59:06 +00:00
|
|
|
match $VBoxContainer/HBoxContainer2/OptionButton.text:
|
|
|
|
"Rotxel":
|
2020-08-26 14:49:46 +00:00
|
|
|
DrawingAlgos.rotxel(current_cel,$VBoxContainer/HBoxContainer/HSlider.value*PI/180)
|
2020-02-04 15:59:06 +00:00
|
|
|
"Nearest neighbour":
|
2020-08-26 14:49:46 +00:00
|
|
|
DrawingAlgos.nn_rotate(current_cel,$VBoxContainer/HBoxContainer/HSlider.value*PI/180)
|
2020-04-03 11:20:59 +00:00
|
|
|
"Upscale, Rotate and Downscale":
|
2020-08-26 14:49:46 +00:00
|
|
|
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-04 16:29:34 +00:00
|
|
|
|
2020-02-03 16:55:55 +00:00
|
|
|
|
2020-08-26 14:49:46 +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
|
|
|
|
2020-02-03 17:01:59 +00:00
|
|
|
|
2020-08-26 14:49:46 +00:00
|
|
|
func _on_SpinBox_value_changed(_value : float) -> void:
|
|
|
|
$VBoxContainer/HBoxContainer/HSlider.value = $VBoxContainer/HBoxContainer/SpinBox.value
|
2020-02-03 17:01:59 +00:00
|
|
|
|
2020-08-26 14:49:46 +00:00
|
|
|
|
|
|
|
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
|
2020-07-29 17:06:20 +00:00
|
|
|
|
|
|
|
|
2020-08-26 14:49:46 +00:00
|
|
|
func _on_OptionButton_item_selected(_id : int) -> void:
|
|
|
|
update_preview()
|