mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-03-12 22:35:18 +00:00
Removed duplicate code from the image effects and put it into the parent ImageEffect class
This commit is contained in:
parent
b07545a3d1
commit
44ecf375fc
9 changed files with 91 additions and 301 deletions
|
@ -34,6 +34,7 @@ func _ready() -> void:
|
|||
|
||||
func _about_to_show() -> void:
|
||||
current_cel = Global.current_project.frames[Global.current_project.current_frame].cels[Global.current_project.current_layer].image
|
||||
current_frame.fill(Color(0, 0, 0, 0))
|
||||
var frame = Global.current_project.frames[Global.current_project.current_frame]
|
||||
Export.blend_layers(current_frame, frame)
|
||||
if selection_checkbox:
|
||||
|
@ -44,6 +45,41 @@ func _about_to_show() -> void:
|
|||
|
||||
|
||||
func _confirmed() -> void:
|
||||
if affect == CEL:
|
||||
Global.canvas.handle_undo("Draw")
|
||||
commit_action(current_cel, pixels)
|
||||
Global.canvas.handle_redo("Draw")
|
||||
elif affect == FRAME:
|
||||
Global.canvas.handle_undo("Draw", Global.current_project, -1)
|
||||
for cel in Global.current_project.frames[Global.current_project.current_frame].cels:
|
||||
commit_action(cel.image, pixels)
|
||||
Global.canvas.handle_redo("Draw", Global.current_project, -1)
|
||||
|
||||
elif affect == ALL_FRAMES:
|
||||
Global.canvas.handle_undo("Draw", Global.current_project, -1, -1)
|
||||
for frame in Global.current_project.frames:
|
||||
for cel in frame.cels:
|
||||
commit_action(cel.image, pixels)
|
||||
Global.canvas.handle_redo("Draw", Global.current_project, -1, -1)
|
||||
|
||||
elif affect == ALL_PROJECTS:
|
||||
for project in Global.projects:
|
||||
var _pixels := []
|
||||
if selection_checkbox.pressed:
|
||||
_pixels = project.selected_pixels.duplicate()
|
||||
else:
|
||||
for x in project.size.x:
|
||||
for y in project.size.y:
|
||||
_pixels.append(Vector2(x, y))
|
||||
|
||||
Global.canvas.handle_undo("Draw", project, -1, -1)
|
||||
for frame in project.frames:
|
||||
for cel in frame.cels:
|
||||
commit_action(cel.image, _pixels, project)
|
||||
Global.canvas.handle_redo("Draw", project, -1, -1)
|
||||
|
||||
|
||||
func commit_action(_cel : Image, _pixels : Array, _project : Project = Global.current_project) -> void:
|
||||
pass
|
||||
|
||||
|
||||
|
@ -69,7 +105,14 @@ func _on_AffectOptionButton_item_selected(index : int) -> void:
|
|||
|
||||
|
||||
func update_preview() -> void:
|
||||
pass
|
||||
match affect:
|
||||
CEL:
|
||||
preview_image.copy_from(current_cel)
|
||||
_:
|
||||
preview_image.copy_from(current_frame)
|
||||
commit_action(preview_image, pixels)
|
||||
preview_texture.create_from_image(preview_image, 0)
|
||||
preview.texture = preview_texture
|
||||
|
||||
|
||||
func update_transparent_background_size() -> void:
|
||||
|
|
|
@ -13,39 +13,8 @@ func set_nodes() -> void:
|
|||
affect_option_button = $VBoxContainer/OptionsContainer/AffectOptionButton
|
||||
|
||||
|
||||
func _confirmed() -> void:
|
||||
if affect == CEL:
|
||||
Global.canvas.handle_undo("Draw")
|
||||
DrawingAlgos.desaturate_image(current_cel, pixels, red, green, blue, alpha)
|
||||
Global.canvas.handle_redo("Draw")
|
||||
elif affect == FRAME:
|
||||
Global.canvas.handle_undo("Draw", Global.current_project, -1)
|
||||
for cel in Global.current_project.frames[Global.current_project.current_frame].cels:
|
||||
DrawingAlgos.desaturate_image(cel.image, pixels, red, green, blue, alpha)
|
||||
Global.canvas.handle_redo("Draw", Global.current_project, -1)
|
||||
|
||||
elif affect == ALL_FRAMES:
|
||||
Global.canvas.handle_undo("Draw", Global.current_project, -1, -1)
|
||||
for frame in Global.current_project.frames:
|
||||
for cel in frame.cels:
|
||||
DrawingAlgos.desaturate_image(cel.image, pixels, red, green, blue, alpha)
|
||||
Global.canvas.handle_redo("Draw", Global.current_project, -1, -1)
|
||||
|
||||
elif affect == ALL_PROJECTS:
|
||||
for project in Global.projects:
|
||||
var _pixels := []
|
||||
if selection_checkbox.pressed:
|
||||
_pixels = project.selected_pixels.duplicate()
|
||||
else:
|
||||
for x in project.size.x:
|
||||
for y in project.size.y:
|
||||
_pixels.append(Vector2(x, y))
|
||||
|
||||
Global.canvas.handle_undo("Draw", project, -1, -1)
|
||||
for frame in project.frames:
|
||||
for cel in frame.cels:
|
||||
DrawingAlgos.desaturate_image(cel.image, _pixels, red, green, blue, alpha)
|
||||
Global.canvas.handle_redo("Draw", project, -1, -1)
|
||||
func commit_action(_cel : Image, _pixels : Array, _project : Project = Global.current_project) -> void:
|
||||
DrawingAlgos.desaturate_image(_cel, _pixels, red, green, blue, alpha)
|
||||
|
||||
|
||||
func _on_RButton_toggled(button_pressed : bool) -> void:
|
||||
|
@ -66,15 +35,3 @@ func _on_BButton_toggled(button_pressed : bool) -> void:
|
|||
func _on_AButton_toggled(button_pressed : bool) -> void:
|
||||
alpha = button_pressed
|
||||
update_preview()
|
||||
|
||||
|
||||
func update_preview() -> void:
|
||||
match affect:
|
||||
CEL:
|
||||
preview_image.copy_from(current_cel)
|
||||
_:
|
||||
preview_image.copy_from(current_frame)
|
||||
DrawingAlgos.desaturate_image(preview_image, pixels, red, green, blue, alpha)
|
||||
preview_image.unlock()
|
||||
preview_texture.create_from_image(preview_image, 0)
|
||||
preview.texture = preview_texture
|
||||
|
|
|
@ -11,39 +11,8 @@ func set_nodes() -> void:
|
|||
affect_option_button = $VBoxContainer/OptionsContainer/AffectOptionButton
|
||||
|
||||
|
||||
func _confirmed() -> void:
|
||||
if affect == CEL:
|
||||
Global.canvas.handle_undo("Draw")
|
||||
flip_image(current_cel, pixels)
|
||||
Global.canvas.handle_redo("Draw")
|
||||
elif affect == FRAME:
|
||||
Global.canvas.handle_undo("Draw", Global.current_project, -1)
|
||||
for cel in Global.current_project.frames[Global.current_project.current_frame].cels:
|
||||
flip_image(cel.image, pixels)
|
||||
Global.canvas.handle_redo("Draw", Global.current_project, -1)
|
||||
|
||||
elif affect == ALL_FRAMES:
|
||||
Global.canvas.handle_undo("Draw", Global.current_project, -1, -1)
|
||||
for frame in Global.current_project.frames:
|
||||
for cel in frame.cels:
|
||||
flip_image(cel.image, pixels)
|
||||
Global.canvas.handle_redo("Draw", Global.current_project, -1, -1)
|
||||
|
||||
elif affect == ALL_PROJECTS:
|
||||
for project in Global.projects:
|
||||
var _pixels := []
|
||||
if selection_checkbox.pressed:
|
||||
_pixels = project.selected_pixels.duplicate()
|
||||
else:
|
||||
for x in project.size.x:
|
||||
for y in project.size.y:
|
||||
_pixels.append(Vector2(x, y))
|
||||
|
||||
Global.canvas.handle_undo("Draw", project, -1, -1)
|
||||
for frame in project.frames:
|
||||
for cel in frame.cels:
|
||||
flip_image(cel.image, _pixels, project)
|
||||
Global.canvas.handle_redo("Draw", project, -1, -1)
|
||||
func commit_action(_cel : Image, _pixels : Array, project : Project = Global.current_project) -> void:
|
||||
flip_image(_cel, _pixels, project)
|
||||
|
||||
|
||||
func _on_FlipHorizontal_toggled(_button_pressed : bool) -> void:
|
||||
|
@ -59,17 +28,6 @@ func _on_SelectionCheckBox_toggled(button_pressed : bool) -> void:
|
|||
update_preview()
|
||||
|
||||
|
||||
func update_preview() -> void:
|
||||
match affect:
|
||||
CEL:
|
||||
preview_image.copy_from(current_cel)
|
||||
_:
|
||||
preview_image.copy_from(current_frame)
|
||||
flip_image(preview_image, pixels)
|
||||
preview_texture.create_from_image(preview_image, 0)
|
||||
preview.texture = preview_texture
|
||||
|
||||
|
||||
func flip_image(image : Image, _pixels : Array, project : Project = Global.current_project) -> void:
|
||||
var entire_image_selected : bool = _pixels.size() == project.size.x * project.size.y
|
||||
if entire_image_selected:
|
||||
|
|
|
@ -18,11 +18,8 @@ func set_nodes() -> void:
|
|||
affect_option_button = $VBoxContainer/OptionsContainer/AffectOptionButton
|
||||
|
||||
|
||||
func update_preview() -> void:
|
||||
preview_image.copy_from(current_cel)
|
||||
DrawingAlgos.generate_gradient(preview_image, [color1.color, color2.color], steps.value, direction.selected, pixels)
|
||||
preview_texture.create_from_image(preview_image, 0)
|
||||
preview.texture = preview_texture
|
||||
func commit_action(_cel : Image, _pixels : Array, _project : Project = Global.current_project) -> void:
|
||||
DrawingAlgos.generate_gradient(_cel, [color1.color, color2.color], steps.value, direction.selected, _pixels)
|
||||
|
||||
|
||||
func _on_ColorPickerButton_color_changed(_color : Color) -> void:
|
||||
|
@ -39,38 +36,3 @@ func _on_StepSpinBox_value_changed(_value : int) -> void:
|
|||
|
||||
func _on_DirectionOptionButton_item_selected(_index : int) -> void:
|
||||
update_preview()
|
||||
|
||||
|
||||
func _confirmed() -> void:
|
||||
if affect == CEL:
|
||||
Global.canvas.handle_undo("Draw")
|
||||
DrawingAlgos.generate_gradient(current_cel, [color1.color, color2.color], steps.value, direction.selected, pixels)
|
||||
Global.canvas.handle_redo("Draw")
|
||||
elif affect == FRAME:
|
||||
Global.canvas.handle_undo("Draw", Global.current_project, -1)
|
||||
for cel in Global.current_project.frames[Global.current_project.current_frame].cels:
|
||||
DrawingAlgos.generate_gradient(cel.image, [color1.color, color2.color], steps.value, direction.selected, pixels)
|
||||
Global.canvas.handle_redo("Draw", Global.current_project, -1)
|
||||
|
||||
elif affect == ALL_FRAMES:
|
||||
Global.canvas.handle_undo("Draw", Global.current_project, -1, -1)
|
||||
for frame in Global.current_project.frames:
|
||||
for cel in frame.cels:
|
||||
DrawingAlgos.generate_gradient(cel.image, [color1.color, color2.color], steps.value, direction.selected, pixels)
|
||||
Global.canvas.handle_redo("Draw", Global.current_project, -1, -1)
|
||||
|
||||
elif affect == ALL_PROJECTS:
|
||||
for project in Global.projects:
|
||||
var _pixels := []
|
||||
if selection_checkbox.pressed:
|
||||
_pixels = project.selected_pixels.duplicate()
|
||||
else:
|
||||
for x in project.size.x:
|
||||
for y in project.size.y:
|
||||
_pixels.append(Vector2(x, y))
|
||||
|
||||
Global.canvas.handle_undo("Draw", project, -1, -1)
|
||||
for frame in project.frames:
|
||||
for cel in frame.cels:
|
||||
DrawingAlgos.generate_gradient(cel.image, [color1.color, color2.color], steps.value, direction.selected, _pixels)
|
||||
Global.canvas.handle_redo("Draw", project, -1, -1)
|
||||
|
|
|
@ -17,42 +17,14 @@ func set_nodes() -> void:
|
|||
|
||||
|
||||
func _confirmed() -> void:
|
||||
if affect == CEL:
|
||||
Global.canvas.handle_undo("Draw")
|
||||
DrawingAlgos.adjust_hsv(current_cel, hue_slider.value, sat_slider.value, val_slider.value, pixels)
|
||||
Global.canvas.handle_redo("Draw")
|
||||
|
||||
elif affect == FRAME:
|
||||
Global.canvas.handle_undo("Draw", Global.current_project, -1)
|
||||
for cel in Global.current_project.frames[Global.current_project.current_frame].cels:
|
||||
DrawingAlgos.adjust_hsv(cel.image, hue_slider.value, sat_slider.value, val_slider.value, pixels)
|
||||
Global.canvas.handle_redo("Draw", Global.current_project, -1)
|
||||
|
||||
elif affect == ALL_FRAMES:
|
||||
Global.canvas.handle_undo("Draw", Global.current_project, -1, -1)
|
||||
for frame in Global.current_project.frames:
|
||||
for cel in frame.cels:
|
||||
DrawingAlgos.adjust_hsv(cel.image, hue_slider.value, sat_slider.value, val_slider.value, pixels)
|
||||
Global.canvas.handle_redo("Draw", Global.current_project, -1, -1)
|
||||
|
||||
elif affect == ALL_PROJECTS:
|
||||
for project in Global.projects:
|
||||
var _pixels := []
|
||||
if selection_checkbox.pressed:
|
||||
_pixels = project.selected_pixels.duplicate()
|
||||
else:
|
||||
for x in project.size.x:
|
||||
for y in project.size.y:
|
||||
_pixels.append(Vector2(x, y))
|
||||
|
||||
Global.canvas.handle_undo("Draw", project, -1, -1)
|
||||
for frame in project.frames:
|
||||
for cel in frame.cels:
|
||||
DrawingAlgos.adjust_hsv(cel.image, hue_slider.value, sat_slider.value, val_slider.value, _pixels)
|
||||
Global.canvas.handle_redo("Draw", project, -1, -1)
|
||||
._confirmed()
|
||||
reset()
|
||||
|
||||
|
||||
func commit_action(_cel : Image, _pixels : Array, _project : Project = Global.current_project) -> void:
|
||||
DrawingAlgos.adjust_hsv(_cel, hue_slider.value, sat_slider.value, val_slider.value, _pixels)
|
||||
|
||||
|
||||
func reset() -> void:
|
||||
disconnect_signals()
|
||||
hue_slider.value = 0
|
||||
|
@ -64,17 +36,6 @@ func reset() -> void:
|
|||
reconnect_signals()
|
||||
|
||||
|
||||
func update_preview() -> void:
|
||||
match affect:
|
||||
CEL:
|
||||
preview_image.copy_from(current_cel)
|
||||
_:
|
||||
preview_image.copy_from(current_frame)
|
||||
DrawingAlgos.adjust_hsv(preview_image, hue_slider.value, sat_slider.value, val_slider.value, pixels)
|
||||
preview_texture.create_from_image(preview_image, 0)
|
||||
preview.texture = preview_texture
|
||||
|
||||
|
||||
func disconnect_signals() -> void:
|
||||
hue_slider.disconnect("value_changed",self,"_on_Hue_value_changed")
|
||||
sat_slider.disconnect("value_changed",self,"_on_Saturation_value_changed")
|
||||
|
|
|
@ -13,39 +13,8 @@ func set_nodes() -> void:
|
|||
affect_option_button = $VBoxContainer/OptionsContainer/AffectOptionButton
|
||||
|
||||
|
||||
func _confirmed() -> void:
|
||||
if affect == CEL:
|
||||
Global.canvas.handle_undo("Draw")
|
||||
DrawingAlgos.invert_image_colors(current_cel, pixels, red, green, blue, alpha)
|
||||
Global.canvas.handle_redo("Draw")
|
||||
elif affect == FRAME:
|
||||
Global.canvas.handle_undo("Draw", Global.current_project, -1)
|
||||
for cel in Global.current_project.frames[Global.current_project.current_frame].cels:
|
||||
DrawingAlgos.invert_image_colors(cel.image, pixels, red, green, blue, alpha)
|
||||
Global.canvas.handle_redo("Draw", Global.current_project, -1)
|
||||
|
||||
elif affect == ALL_FRAMES:
|
||||
Global.canvas.handle_undo("Draw", Global.current_project, -1, -1)
|
||||
for frame in Global.current_project.frames:
|
||||
for cel in frame.cels:
|
||||
DrawingAlgos.invert_image_colors(cel.image, pixels, red, green, blue, alpha)
|
||||
Global.canvas.handle_redo("Draw", Global.current_project, -1, -1)
|
||||
|
||||
elif affect == ALL_PROJECTS:
|
||||
for project in Global.projects:
|
||||
var _pixels := []
|
||||
if selection_checkbox.pressed:
|
||||
_pixels = project.selected_pixels.duplicate()
|
||||
else:
|
||||
for x in project.size.x:
|
||||
for y in project.size.y:
|
||||
_pixels.append(Vector2(x, y))
|
||||
|
||||
Global.canvas.handle_undo("Draw", project, -1, -1)
|
||||
for frame in project.frames:
|
||||
for cel in frame.cels:
|
||||
DrawingAlgos.invert_image_colors(cel.image, _pixels, red, green, blue, alpha)
|
||||
Global.canvas.handle_redo("Draw", project, -1, -1)
|
||||
func commit_action(_cel : Image, _pixels : Array, _project : Project = Global.current_project) -> void:
|
||||
DrawingAlgos.invert_image_colors(_cel, _pixels, red, green, blue, alpha)
|
||||
|
||||
|
||||
func _on_RButton_toggled(button_pressed : bool) -> void:
|
||||
|
@ -66,15 +35,3 @@ func _on_BButton_toggled(button_pressed : bool) -> void:
|
|||
func _on_AButton_toggled(button_pressed : bool) -> void:
|
||||
alpha = button_pressed
|
||||
update_preview()
|
||||
|
||||
|
||||
func update_preview() -> void:
|
||||
match affect:
|
||||
CEL:
|
||||
preview_image.copy_from(current_cel)
|
||||
_:
|
||||
preview_image.copy_from(current_frame)
|
||||
DrawingAlgos.invert_image_colors(preview_image, pixels, red, green, blue, alpha)
|
||||
preview_image.unlock()
|
||||
preview_texture.create_from_image(preview_image, 0)
|
||||
preview.texture = preview_texture
|
||||
|
|
|
@ -20,39 +20,8 @@ func set_nodes() -> void:
|
|||
affect_option_button = $VBoxContainer/OptionsContainer/AffectOptionButton
|
||||
|
||||
|
||||
func _confirmed() -> void:
|
||||
if affect == CEL:
|
||||
Global.canvas.handle_undo("Draw")
|
||||
DrawingAlgos.generate_outline(current_cel, pixels, color, thickness, diagonal, inside_image)
|
||||
Global.canvas.handle_redo("Draw")
|
||||
elif affect == FRAME:
|
||||
Global.canvas.handle_undo("Draw", Global.current_project, -1)
|
||||
for cel in Global.current_project.frames[Global.current_project.current_frame].cels:
|
||||
DrawingAlgos.generate_outline(cel.image, pixels, color, thickness, diagonal, inside_image)
|
||||
Global.canvas.handle_redo("Draw", Global.current_project, -1)
|
||||
|
||||
elif affect == ALL_FRAMES:
|
||||
Global.canvas.handle_undo("Draw", Global.current_project, -1, -1)
|
||||
for frame in Global.current_project.frames:
|
||||
for cel in frame.cels:
|
||||
DrawingAlgos.generate_outline(cel.image, pixels, color, thickness, diagonal, inside_image)
|
||||
Global.canvas.handle_redo("Draw", Global.current_project, -1, -1)
|
||||
|
||||
elif affect == ALL_PROJECTS:
|
||||
for project in Global.projects:
|
||||
var _pixels := []
|
||||
if selection_checkbox.pressed:
|
||||
_pixels = project.selected_pixels.duplicate()
|
||||
else:
|
||||
for x in project.size.x:
|
||||
for y in project.size.y:
|
||||
_pixels.append(Vector2(x, y))
|
||||
|
||||
Global.canvas.handle_undo("Draw", project, -1, -1)
|
||||
for frame in project.frames:
|
||||
for cel in frame.cels:
|
||||
DrawingAlgos.generate_outline(cel.image, _pixels, color, thickness, diagonal, inside_image)
|
||||
Global.canvas.handle_redo("Draw", project, -1, -1)
|
||||
func commit_action(_cel : Image, _pixels : Array, _project : Project = Global.current_project) -> void:
|
||||
DrawingAlgos.generate_outline(_cel, _pixels, color, thickness, diagonal, inside_image)
|
||||
|
||||
|
||||
func _on_ThickValue_value_changed(value : int) -> void:
|
||||
|
@ -73,14 +42,3 @@ func _on_DiagonalCheckBox_toggled(button_pressed : bool) -> void:
|
|||
func _on_InsideImageCheckBox_toggled(button_pressed : bool) -> void:
|
||||
inside_image = button_pressed
|
||||
update_preview()
|
||||
|
||||
|
||||
func update_preview() -> void:
|
||||
match affect:
|
||||
CEL:
|
||||
preview_image.copy_from(current_cel)
|
||||
_:
|
||||
preview_image.copy_from(current_frame)
|
||||
DrawingAlgos.generate_outline(preview_image, pixels, color, thickness, diagonal, inside_image)
|
||||
preview_texture.create_from_image(preview_image, 0)
|
||||
preview.texture = preview_texture
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
extends ImageEffect
|
||||
|
||||
|
||||
onready var type_option_button : OptionButton = $VBoxContainer/HBoxContainer2/TypeOptionButton
|
||||
onready var angle_hslider : HSlider = $VBoxContainer/AngleOptions/AngleHSlider
|
||||
onready var angle_spinbox : SpinBox = $VBoxContainer/AngleOptions/AngleSpinBox
|
||||
|
||||
|
||||
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")
|
||||
type_option_button.add_item("Rotxel")
|
||||
type_option_button.add_item("Upscale, Rotate and Downscale")
|
||||
type_option_button.add_item("Nearest neighbour")
|
||||
|
||||
|
||||
func set_nodes() -> void:
|
||||
|
@ -13,43 +18,32 @@ func set_nodes() -> void:
|
|||
|
||||
func _about_to_show() -> void:
|
||||
._about_to_show()
|
||||
$VBoxContainer/HBoxContainer/HSlider.value = 0
|
||||
angle_hslider.value = 0
|
||||
|
||||
|
||||
func commit_action(_cel : Image, _pixels : Array, _project : Project = Global.current_project) -> void:
|
||||
match type_option_button.text:
|
||||
"Rotxel":
|
||||
DrawingAlgos.rotxel(_cel,angle_hslider.value*PI/180)
|
||||
"Nearest neighbour":
|
||||
DrawingAlgos.nn_rotate(_cel,angle_hslider.value*PI/180)
|
||||
"Upscale, Rotate and Downscale":
|
||||
DrawingAlgos.fake_rotsprite(_cel,angle_hslider.value*PI/180)
|
||||
|
||||
|
||||
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
|
||||
._confirmed()
|
||||
angle_hslider.value = 0
|
||||
|
||||
|
||||
func _on_HSlider_value_changed(_value : float) -> void:
|
||||
update_preview()
|
||||
$VBoxContainer/HBoxContainer/SpinBox.value = $VBoxContainer/HBoxContainer/HSlider.value
|
||||
angle_spinbox.value = angle_hslider.value
|
||||
|
||||
|
||||
func _on_SpinBox_value_changed(_value : float) -> void:
|
||||
$VBoxContainer/HBoxContainer/HSlider.value = $VBoxContainer/HBoxContainer/SpinBox.value
|
||||
angle_hslider.value = angle_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:
|
||||
func _on_TypeOptionButton_item_selected(_id : int) -> void:
|
||||
update_preview()
|
||||
|
|
|
@ -48,7 +48,7 @@ margin_right = 34.0
|
|||
margin_bottom = 17.0
|
||||
text = "Type:"
|
||||
|
||||
[node name="OptionButton" type="OptionButton" parent="VBoxContainer/HBoxContainer2"]
|
||||
[node name="TypeOptionButton" type="OptionButton" parent="VBoxContainer/HBoxContainer2"]
|
||||
margin_left = 38.0
|
||||
margin_right = 229.0
|
||||
margin_bottom = 20.0
|
||||
|
@ -56,18 +56,18 @@ mouse_default_cursor_shape = 2
|
|||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
|
||||
[node name="AngleOptions" type="HBoxContainer" parent="VBoxContainer"]
|
||||
margin_top = 228.0
|
||||
margin_right = 229.0
|
||||
margin_bottom = 252.0
|
||||
|
||||
[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer"]
|
||||
[node name="Label" type="Label" parent="VBoxContainer/AngleOptions"]
|
||||
margin_top = 5.0
|
||||
margin_right = 40.0
|
||||
margin_bottom = 19.0
|
||||
text = "Angle:"
|
||||
|
||||
[node name="HSlider" type="HSlider" parent="VBoxContainer/HBoxContainer"]
|
||||
[node name="AngleHSlider" type="HSlider" parent="VBoxContainer/AngleOptions"]
|
||||
margin_left = 44.0
|
||||
margin_right = 151.0
|
||||
margin_bottom = 24.0
|
||||
|
@ -79,13 +79,13 @@ __meta__ = {
|
|||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="SpinBox" type="SpinBox" parent="VBoxContainer/HBoxContainer"]
|
||||
[node name="AngleSpinBox" type="SpinBox" parent="VBoxContainer/AngleOptions"]
|
||||
margin_left = 155.0
|
||||
margin_right = 229.0
|
||||
margin_bottom = 24.0
|
||||
mouse_default_cursor_shape = 2
|
||||
max_value = 359.0
|
||||
suffix = "°"
|
||||
[connection signal="item_selected" from="VBoxContainer/HBoxContainer2/OptionButton" to="." method="_on_OptionButton_item_selected"]
|
||||
[connection signal="value_changed" from="VBoxContainer/HBoxContainer/HSlider" to="." method="_on_HSlider_value_changed"]
|
||||
[connection signal="value_changed" from="VBoxContainer/HBoxContainer/SpinBox" to="." method="_on_SpinBox_value_changed"]
|
||||
[connection signal="item_selected" from="VBoxContainer/HBoxContainer2/TypeOptionButton" to="." method="_on_TypeOptionButton_item_selected"]
|
||||
[connection signal="value_changed" from="VBoxContainer/AngleOptions/AngleHSlider" to="." method="_on_HSlider_value_changed"]
|
||||
[connection signal="value_changed" from="VBoxContainer/AngleOptions/AngleSpinBox" to="." method="_on_SpinBox_value_changed"]
|
||||
|
|
Loading…
Add table
Reference in a new issue