mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-31 07:29:49 +00:00
Use enums to check the rotation algorithm instead of strings in RotateImage.gd
This commit is contained in:
parent
7001f3a28b
commit
09ff22707b
|
@ -44,22 +44,22 @@ func set_nodes() -> void:
|
|||
func _about_to_show() -> void:
|
||||
drag_pivot = false
|
||||
if pivot == Vector2.INF:
|
||||
decide_pivot()
|
||||
_calculate_pivot()
|
||||
confirmed = false
|
||||
._about_to_show()
|
||||
wait_apply_timer.wait_time = wait_time_slider.value / 1000.0
|
||||
angle_slider.value = 0
|
||||
|
||||
|
||||
func decide_pivot() -> void:
|
||||
func _calculate_pivot() -> void:
|
||||
var size := Global.current_project.size
|
||||
pivot = size / 2
|
||||
|
||||
# Pivot correction in case of even size
|
||||
if (
|
||||
type_option_button.text != "Nearest neighbour (Shader)"
|
||||
and type_option_button.text != "cleanEdge"
|
||||
and type_option_button.text != "OmniScale"
|
||||
type_option_button.get_selected_id() != NNS
|
||||
and type_option_button.get_selected_id() != CLEANEDGE
|
||||
and type_option_button.get_selected_id() != OMNISCALE
|
||||
):
|
||||
if int(size.x) % 2 == 0:
|
||||
pivot.x -= 0.5
|
||||
|
@ -73,9 +73,9 @@ func decide_pivot() -> void:
|
|||
+ ((selection_rectangle.end - selection_rectangle.position) / 2)
|
||||
)
|
||||
if (
|
||||
type_option_button.text != "Nearest neighbour (Shader)"
|
||||
and type_option_button.text != "cleanEdge"
|
||||
and type_option_button.text != "OmniScale"
|
||||
type_option_button.get_selected_id() != NNS
|
||||
and type_option_button.get_selected_id() != CLEANEDGE
|
||||
and type_option_button.get_selected_id() != OMNISCALE
|
||||
):
|
||||
# Pivot correction in case of even size
|
||||
if int(selection_rectangle.end.x - selection_rectangle.position.x) % 2 == 0:
|
||||
|
@ -114,8 +114,8 @@ func commit_action(cel: Image, _project: Project = Global.current_project) -> vo
|
|||
cel.set_pixelv(pos, Color(0, 0, 0, 0))
|
||||
image.unlock()
|
||||
cel.unlock()
|
||||
match type_option_button.text:
|
||||
"Rotxel with Smear":
|
||||
match type_option_button.get_selected_id():
|
||||
ROTXEL_SMEAR:
|
||||
var params := {
|
||||
"initial_angle": init_angle_slider.value,
|
||||
"ending_angle": angle_slider.value,
|
||||
|
@ -132,7 +132,7 @@ func commit_action(cel: Image, _project: Project = Global.current_project) -> vo
|
|||
gen.generate_image(cel, rotxel_shader, params, _project.size)
|
||||
yield(gen, "done")
|
||||
|
||||
"cleanEdge":
|
||||
CLEANEDGE:
|
||||
var params := {
|
||||
"angle": angle,
|
||||
"selection_tex": selection_tex,
|
||||
|
@ -150,7 +150,7 @@ func commit_action(cel: Image, _project: Project = Global.current_project) -> vo
|
|||
var gen := ShaderImageEffect.new()
|
||||
gen.generate_image(cel, clean_edge_shader, params, _project.size)
|
||||
yield(gen, "done")
|
||||
"OmniScale":
|
||||
OMNISCALE:
|
||||
var params := {
|
||||
"angle": angle,
|
||||
"selection_tex": selection_tex,
|
||||
|
@ -166,7 +166,7 @@ func commit_action(cel: Image, _project: Project = Global.current_project) -> vo
|
|||
var gen := ShaderImageEffect.new()
|
||||
gen.generate_image(cel, DrawingAlgos.omniscale_shader, params, _project.size)
|
||||
yield(gen, "done")
|
||||
"Nearest neighbour (Shader)":
|
||||
NNS:
|
||||
var params := {
|
||||
"angle": angle,
|
||||
"selection_tex": selection_tex,
|
||||
|
@ -180,11 +180,11 @@ func commit_action(cel: Image, _project: Project = Global.current_project) -> vo
|
|||
var gen := ShaderImageEffect.new()
|
||||
gen.generate_image(cel, nn_shader, params, _project.size)
|
||||
yield(gen, "done")
|
||||
"Rotxel":
|
||||
ROTXEL:
|
||||
DrawingAlgos.rotxel(image, angle, pivot)
|
||||
"Nearest neighbour":
|
||||
NN:
|
||||
DrawingAlgos.nn_rotate(image, angle, pivot)
|
||||
"Upscale, Rotate and Downscale":
|
||||
URD:
|
||||
DrawingAlgos.fake_rotsprite(image, angle, pivot)
|
||||
|
||||
if _project.has_selection and selection_checkbox.pressed and !_type_is_shader():
|
||||
|
@ -194,38 +194,34 @@ func commit_action(cel: Image, _project: Project = Global.current_project) -> vo
|
|||
|
||||
|
||||
func _type_is_shader() -> bool:
|
||||
return (
|
||||
type_option_button.text == "Nearest neighbour (Shader)"
|
||||
or type_option_button.text == "Rotxel with Smear"
|
||||
or type_option_button.text == "cleanEdge"
|
||||
or type_option_button.text == "OmniScale"
|
||||
)
|
||||
return type_option_button.get_selected_id() <= NNS
|
||||
|
||||
|
||||
func _on_TypeOptionButton_item_selected(_id: int) -> void:
|
||||
if type_option_button.text == "Rotxel with Smear":
|
||||
var sm := ShaderMaterial.new()
|
||||
sm.shader = rotxel_shader
|
||||
preview.set_material(sm)
|
||||
smear_options.visible = true
|
||||
elif type_option_button.text == "cleanEdge":
|
||||
var sm := ShaderMaterial.new()
|
||||
sm.shader = clean_edge_shader
|
||||
preview.set_material(sm)
|
||||
smear_options.visible = false
|
||||
elif type_option_button.text == "OmniScale":
|
||||
var sm := ShaderMaterial.new()
|
||||
sm.shader = DrawingAlgos.omniscale_shader
|
||||
preview.set_material(sm)
|
||||
smear_options.visible = false
|
||||
elif type_option_button.text == "Nearest neighbour (Shader)":
|
||||
var sm := ShaderMaterial.new()
|
||||
sm.shader = nn_shader
|
||||
preview.set_material(sm)
|
||||
smear_options.visible = false
|
||||
else:
|
||||
preview.set_material(null)
|
||||
smear_options.visible = false
|
||||
match type_option_button.get_selected_id():
|
||||
ROTXEL_SMEAR:
|
||||
var sm := ShaderMaterial.new()
|
||||
sm.shader = rotxel_shader
|
||||
preview.set_material(sm)
|
||||
smear_options.visible = true
|
||||
CLEANEDGE:
|
||||
var sm := ShaderMaterial.new()
|
||||
sm.shader = clean_edge_shader
|
||||
preview.set_material(sm)
|
||||
smear_options.visible = false
|
||||
OMNISCALE:
|
||||
var sm := ShaderMaterial.new()
|
||||
sm.shader = DrawingAlgos.omniscale_shader
|
||||
preview.set_material(sm)
|
||||
smear_options.visible = false
|
||||
NNS:
|
||||
var sm := ShaderMaterial.new()
|
||||
sm.shader = nn_shader
|
||||
preview.set_material(sm)
|
||||
smear_options.visible = false
|
||||
_:
|
||||
preview.set_material(null)
|
||||
smear_options.visible = false
|
||||
update_preview()
|
||||
|
||||
|
||||
|
@ -280,7 +276,7 @@ func _on_quick_change_angle_pressed(angle_value: int) -> void:
|
|||
|
||||
|
||||
func _on_Centre_pressed() -> void:
|
||||
decide_pivot()
|
||||
_calculate_pivot()
|
||||
|
||||
|
||||
func _on_Pivot_value_changed(value: float, is_x: bool) -> void:
|
||||
|
|
Loading…
Reference in a new issue