mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-02-21 13:03:13 +00:00
Add animatable properties to the Gradient effect
This commit is contained in:
parent
eac7def5b4
commit
81c0b49c59
2 changed files with 27 additions and 17 deletions
|
@ -1,6 +1,7 @@
|
||||||
extends ImageEffect
|
extends ImageEffect
|
||||||
|
|
||||||
enum { LINEAR, RADIAL, LINEAR_DITHERING, RADIAL_DITHERING }
|
enum { LINEAR, RADIAL, LINEAR_DITHERING, RADIAL_DITHERING }
|
||||||
|
enum Animate { POSITION, SIZE, ANGLE, CENTER_X, CENTER_Y, RADIUS_X, RADIUS_Y }
|
||||||
|
|
||||||
var shader_linear: Shader = preload("res://src/Shaders/Gradients/Linear.gdshader")
|
var shader_linear: Shader = preload("res://src/Shaders/Gradients/Linear.gdshader")
|
||||||
var shader_linear_dither: Shader = preload("res://src/Shaders/Gradients/LinearDithering.gdshader")
|
var shader_linear_dither: Shader = preload("res://src/Shaders/Gradients/LinearDithering.gdshader")
|
||||||
|
@ -17,12 +18,11 @@ var selected_dither_matrix: DitherMatrix = dither_matrices[0]
|
||||||
onready var options_cont: Container = $VBoxContainer/GradientOptions
|
onready var options_cont: Container = $VBoxContainer/GradientOptions
|
||||||
onready var gradient_edit: GradientEditNode = $VBoxContainer/GradientEdit
|
onready var gradient_edit: GradientEditNode = $VBoxContainer/GradientEdit
|
||||||
onready var shape_option_button: OptionButton = $"%ShapeOptionButton"
|
onready var shape_option_button: OptionButton = $"%ShapeOptionButton"
|
||||||
onready var dithering_label: Label = $"%DitheringLabel"
|
|
||||||
onready var dithering_option_button: OptionButton = $"%DitheringOptionButton"
|
onready var dithering_option_button: OptionButton = $"%DitheringOptionButton"
|
||||||
onready var repeat_option_button: OptionButton = $"%RepeatOptionButton"
|
onready var repeat_option_button: OptionButton = $"%RepeatOptionButton"
|
||||||
onready var position: ValueSlider = $"%PositionSlider"
|
onready var position_slider: ValueSlider = $"%PositionSlider"
|
||||||
onready var size_slider: ValueSlider = $"%SizeSlider"
|
onready var size_slider: ValueSlider = $"%SizeSlider"
|
||||||
onready var angle: ValueSlider = $"%AngleSlider"
|
onready var angle_slider: ValueSlider = $"%AngleSlider"
|
||||||
onready var center_slider := $"%CenterSlider" as ValueSliderV2
|
onready var center_slider := $"%CenterSlider" as ValueSliderV2
|
||||||
onready var radius_slider := $"%RadiusSlider" as ValueSliderV2
|
onready var radius_slider := $"%RadiusSlider" as ValueSliderV2
|
||||||
|
|
||||||
|
@ -44,6 +44,15 @@ func _ready() -> void:
|
||||||
for matrix in dither_matrices:
|
for matrix in dither_matrices:
|
||||||
dithering_option_button.add_item(matrix.name)
|
dithering_option_button.add_item(matrix.name)
|
||||||
|
|
||||||
|
# Set as in the Animate enum
|
||||||
|
animate_panel.add_float_property("Position", position_slider)
|
||||||
|
animate_panel.add_float_property("Size", size_slider)
|
||||||
|
animate_panel.add_float_property("Angle", angle_slider)
|
||||||
|
animate_panel.add_float_property("Center X", center_slider.get_sliders()[0])
|
||||||
|
animate_panel.add_float_property("Center Y", center_slider.get_sliders()[1])
|
||||||
|
animate_panel.add_float_property("Radius X", radius_slider.get_sliders()[0])
|
||||||
|
animate_panel.add_float_property("Radius Y", radius_slider.get_sliders()[1])
|
||||||
|
|
||||||
|
|
||||||
func commit_action(cel: Image, project: Project = Global.current_project) -> void:
|
func commit_action(cel: Image, project: Project = Global.current_project) -> void:
|
||||||
var selection: Image
|
var selection: Image
|
||||||
|
@ -83,16 +92,24 @@ func commit_action(cel: Image, project: Project = Global.current_project) -> voi
|
||||||
else:
|
else:
|
||||||
gradient_tex = ImageTexture.new()
|
gradient_tex = ImageTexture.new()
|
||||||
gradient_tex.create_from_image(gradient_image, 0)
|
gradient_tex.create_from_image(gradient_image, 0)
|
||||||
|
var center := Vector2(
|
||||||
|
animate_panel.get_animated_value(commit_idx, Animate.CENTER_X),
|
||||||
|
animate_panel.get_animated_value(commit_idx, Animate.CENTER_Y)
|
||||||
|
)
|
||||||
|
var radius := Vector2(
|
||||||
|
animate_panel.get_animated_value(commit_idx, Animate.RADIUS_X),
|
||||||
|
animate_panel.get_animated_value(commit_idx, Animate.RADIUS_Y)
|
||||||
|
)
|
||||||
var params := {
|
var params := {
|
||||||
"gradient_texture": gradient_tex,
|
"gradient_texture": gradient_tex,
|
||||||
"offset_texture": offsets_tex,
|
"offset_texture": offsets_tex,
|
||||||
"selection": selection_tex,
|
"selection": selection_tex,
|
||||||
"repeat": repeat_option_button.selected,
|
"repeat": repeat_option_button.selected,
|
||||||
"position": (position.value / 100.0) - 0.5,
|
"position": (animate_panel.get_animated_value(commit_idx, Animate.POSITION) / 100.0) - 0.5,
|
||||||
"size": size_slider.value / 100.0,
|
"size": animate_panel.get_animated_value(commit_idx, Animate.SIZE) / 100.0,
|
||||||
"angle": angle.value,
|
"angle": animate_panel.get_animated_value(commit_idx, Animate.ANGLE),
|
||||||
"center": center_slider.value / 100.0,
|
"center": center / 100.0,
|
||||||
"radius": radius_slider.value,
|
"radius": radius,
|
||||||
"dither_texture": dither_texture,
|
"dither_texture": dither_texture,
|
||||||
"image_size": project.size,
|
"image_size": project.size,
|
||||||
"pixel_size": pixel_size,
|
"pixel_size": pixel_size,
|
||||||
|
|
|
@ -11,10 +11,7 @@ window_title = "Gradient"
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
[node name="VBoxContainer" parent="." index="3"]
|
[node name="VBoxContainer" parent="." index="3"]
|
||||||
margin_bottom = 468.0
|
margin_bottom = 444.0
|
||||||
|
|
||||||
[node name="ShowAnimate" parent="VBoxContainer" index="0"]
|
|
||||||
visible = false
|
|
||||||
|
|
||||||
[node name="AspectRatioContainer" parent="VBoxContainer" index="1"]
|
[node name="AspectRatioContainer" parent="VBoxContainer" index="1"]
|
||||||
margin_bottom = 224.0
|
margin_bottom = 224.0
|
||||||
|
@ -56,7 +53,6 @@ items = [ "Linear", null, false, 0, null, "Radial", null, false, 1, null ]
|
||||||
selected = 0
|
selected = 0
|
||||||
|
|
||||||
[node name="DitheringLabel" type="Label" parent="VBoxContainer/GradientOptions" index="2" groups=["gradient_common"]]
|
[node name="DitheringLabel" type="Label" parent="VBoxContainer/GradientOptions" index="2" groups=["gradient_common"]]
|
||||||
unique_name_in_owner = true
|
|
||||||
margin_top = 27.0
|
margin_top = 27.0
|
||||||
margin_right = 178.0
|
margin_right = 178.0
|
||||||
margin_bottom = 41.0
|
margin_bottom = 41.0
|
||||||
|
@ -208,11 +204,8 @@ show_ratio = true
|
||||||
margin_top = 436.0
|
margin_top = 436.0
|
||||||
margin_bottom = 460.0
|
margin_bottom = 460.0
|
||||||
|
|
||||||
[node name="AffectOptionButton" parent="VBoxContainer/OptionsContainer" index="1"]
|
|
||||||
items = [ "Selected cels", null, false, 0, null, "Current frame", null, false, 1, null, "All frames", null, false, 2, null, "All projects", null, false, 3, null ]
|
|
||||||
|
|
||||||
[node name="AnimateDialog" parent="." index="4"]
|
[node name="AnimateDialog" parent="." index="4"]
|
||||||
margin_bottom = 468.0
|
margin_bottom = 444.0
|
||||||
|
|
||||||
[connection signal="updated" from="VBoxContainer/GradientEdit" to="." method="_on_GradientEdit_updated"]
|
[connection signal="updated" from="VBoxContainer/GradientEdit" to="." method="_on_GradientEdit_updated"]
|
||||||
[connection signal="item_selected" from="VBoxContainer/GradientOptions/ShapeOptionButton" to="." method="_on_ShapeOptionButton_item_selected"]
|
[connection signal="item_selected" from="VBoxContainer/GradientOptions/ShapeOptionButton" to="." method="_on_ShapeOptionButton_item_selected"]
|
||||||
|
|
Loading…
Add table
Reference in a new issue