mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-19 01:29:49 +00:00
Use a ValueSliderV2 in the gradient dialog, and reverse the radius logic
The larger the radius value, the larger the circle, as it should be
This commit is contained in:
parent
b1f355702e
commit
72a7b277fb
|
@ -27,7 +27,7 @@ float modify_uv(vec2 uv) {
|
||||||
else { // Radial
|
else { // Radial
|
||||||
vec2 uv_offsetted = uv * 2.0 - 1.0;
|
vec2 uv_offsetted = uv * 2.0 - 1.0;
|
||||||
uv_offsetted -= (center * 2.0) - vec2(1.0);
|
uv_offsetted -= (center * 2.0) - vec2(1.0);
|
||||||
uv_offsetted *= radius;
|
uv_offsetted /= radius;
|
||||||
modified_uv = length(uv_offsetted);
|
modified_uv = length(uv_offsetted);
|
||||||
}
|
}
|
||||||
return modified_uv;
|
return modified_uv;
|
||||||
|
|
|
@ -32,7 +32,7 @@ float modify_uv(vec2 uv) {
|
||||||
else { // Radial
|
else { // Radial
|
||||||
vec2 uv_offsetted = uv * 2.0 - 1.0;
|
vec2 uv_offsetted = uv * 2.0 - 1.0;
|
||||||
uv_offsetted -= (center * 2.0) - vec2(1.0);
|
uv_offsetted -= (center * 2.0) - vec2(1.0);
|
||||||
uv_offsetted *= radius;
|
uv_offsetted /= radius;
|
||||||
modified_uv = length(uv_offsetted);
|
modified_uv = length(uv_offsetted);
|
||||||
}
|
}
|
||||||
return modified_uv;
|
return modified_uv;
|
||||||
|
|
|
@ -23,10 +23,8 @@ onready var repeat_option_button: OptionButton = $"%RepeatOptionButton"
|
||||||
onready var position: ValueSlider = $"%PositionSlider"
|
onready var position: ValueSlider = $"%PositionSlider"
|
||||||
onready var size_slider: ValueSlider = $"%SizeSlider"
|
onready var size_slider: ValueSlider = $"%SizeSlider"
|
||||||
onready var angle: ValueSlider = $"%AngleSlider"
|
onready var angle: ValueSlider = $"%AngleSlider"
|
||||||
onready var center_x: ValueSlider = $"%XCenterSlider"
|
onready var center_slider := $"%CenterSlider" as ValueSliderV2
|
||||||
onready var center_y: ValueSlider = $"%YCenterSlider"
|
onready var radius_slider := $"%RadiusSlider" as ValueSliderV2
|
||||||
onready var radius_x: ValueSlider = $"%XRadiusSlider"
|
|
||||||
onready var radius_y: ValueSlider = $"%YRadiusSlider"
|
|
||||||
|
|
||||||
|
|
||||||
class DitherMatrix:
|
class DitherMatrix:
|
||||||
|
@ -99,8 +97,8 @@ func commit_action(cel: Image, project: Project = Global.current_project) -> voi
|
||||||
"position": (position.value / 100.0) - 0.5,
|
"position": (position.value / 100.0) - 0.5,
|
||||||
"size": size_slider.value / 100.0,
|
"size": size_slider.value / 100.0,
|
||||||
"angle": angle.value,
|
"angle": angle.value,
|
||||||
"center": Vector2(center_x.value / 100.0, center_y.value / 100.0),
|
"center": center_slider.value / 100.0,
|
||||||
"radius": Vector2(radius_x.value, radius_y.value),
|
"radius": radius_slider.value,
|
||||||
"dither_texture": dither_texture,
|
"dither_texture": dither_texture,
|
||||||
"image_size": project.size,
|
"image_size": project.size,
|
||||||
"pixel_size": pixel_size,
|
"pixel_size": pixel_size,
|
||||||
|
@ -135,6 +133,10 @@ func _value_changed(_value: float) -> void:
|
||||||
update_preview()
|
update_preview()
|
||||||
|
|
||||||
|
|
||||||
|
func _value_v2_changed(_value: Vector2) -> void:
|
||||||
|
update_preview()
|
||||||
|
|
||||||
|
|
||||||
func _on_DitheringOptionButton_item_selected(index: int) -> void:
|
func _on_DitheringOptionButton_item_selected(index: int) -> void:
|
||||||
if index > 0:
|
if index > 0:
|
||||||
shader = shader_linear_dither
|
shader = shader_linear_dither
|
||||||
|
|
|
@ -1,16 +1,17 @@
|
||||||
[gd_scene load_steps=5 format=2]
|
[gd_scene load_steps=6 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://src/UI/Dialogs/ImageEffects/GradientDialog.gd" type="Script" id=1]
|
[ext_resource path="res://src/UI/Dialogs/ImageEffects/GradientDialog.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://src/UI/Dialogs/ImageEffects/ImageEffectParent.tscn" type="PackedScene" id=2]
|
[ext_resource path="res://src/UI/Dialogs/ImageEffects/ImageEffectParent.tscn" type="PackedScene" id=2]
|
||||||
[ext_resource path="res://src/UI/Nodes/GradientEdit.tscn" type="PackedScene" id=3]
|
[ext_resource path="res://src/UI/Nodes/GradientEdit.tscn" type="PackedScene" id=3]
|
||||||
[ext_resource path="res://src/UI/Nodes/ValueSlider.gd" type="Script" id=4]
|
[ext_resource path="res://src/UI/Nodes/ValueSlider.gd" type="Script" id=4]
|
||||||
|
[ext_resource path="res://src/UI/Nodes/ValueSliderV2.tscn" type="PackedScene" id=5]
|
||||||
|
|
||||||
[node name="GradientDialog" instance=ExtResource( 2 )]
|
[node name="GradientDialog" instance=ExtResource( 2 )]
|
||||||
window_title = "Gradient"
|
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="AspectRatioContainer" parent="VBoxContainer" index="0"]
|
[node name="AspectRatioContainer" parent="VBoxContainer" index="0"]
|
||||||
margin_right = 278.0
|
margin_right = 278.0
|
||||||
|
@ -85,13 +86,13 @@ text = "None"
|
||||||
items = [ "None", null, false, 0, null, "Repeat", null, false, 1, null, "Mirror", null, false, 2, null, "Truncate", null, false, 3, null ]
|
items = [ "None", null, false, 0, null, "Repeat", null, false, 1, null, "Mirror", null, false, 2, null, "Truncate", null, false, 3, null ]
|
||||||
selected = 0
|
selected = 0
|
||||||
|
|
||||||
[node name="PositionLabel" type="Label" parent="VBoxContainer/GradientOptions" index="6" groups=["gradient_dithering", "gradient_linear", "gradient_step"]]
|
[node name="PositionLabel" type="Label" parent="VBoxContainer/GradientOptions" index="6" groups=["gradient_linear"]]
|
||||||
margin_top = 72.0
|
margin_top = 72.0
|
||||||
margin_right = 137.0
|
margin_right = 137.0
|
||||||
margin_bottom = 86.0
|
margin_bottom = 86.0
|
||||||
text = "Position:"
|
text = "Position:"
|
||||||
|
|
||||||
[node name="PositionSlider" type="TextureProgress" parent="VBoxContainer/GradientOptions" index="7" groups=["gradient_dithering", "gradient_linear"]]
|
[node name="PositionSlider" type="TextureProgress" parent="VBoxContainer/GradientOptions" index="7" groups=["gradient_linear"]]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
margin_left = 141.0
|
margin_left = 141.0
|
||||||
margin_top = 72.0
|
margin_top = 72.0
|
||||||
|
@ -109,14 +110,15 @@ stretch_margin_right = 3
|
||||||
stretch_margin_bottom = 3
|
stretch_margin_bottom = 3
|
||||||
script = ExtResource( 4 )
|
script = ExtResource( 4 )
|
||||||
suffix = "%"
|
suffix = "%"
|
||||||
|
snap_step = 10.0
|
||||||
|
|
||||||
[node name="SizeLabel" type="Label" parent="VBoxContainer/GradientOptions" index="8" groups=["gradient_dithering", "gradient_linear", "gradient_step"]]
|
[node name="SizeLabel" type="Label" parent="VBoxContainer/GradientOptions" index="8" groups=["gradient_linear"]]
|
||||||
margin_top = 90.0
|
margin_top = 90.0
|
||||||
margin_right = 137.0
|
margin_right = 137.0
|
||||||
margin_bottom = 104.0
|
margin_bottom = 104.0
|
||||||
text = "Size:"
|
text = "Size:"
|
||||||
|
|
||||||
[node name="SizeSlider" type="TextureProgress" parent="VBoxContainer/GradientOptions" index="9" groups=["gradient_dithering", "gradient_linear"]]
|
[node name="SizeSlider" type="TextureProgress" parent="VBoxContainer/GradientOptions" index="9" groups=["gradient_linear"]]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
margin_left = 141.0
|
margin_left = 141.0
|
||||||
margin_top = 90.0
|
margin_top = 90.0
|
||||||
|
@ -135,14 +137,15 @@ stretch_margin_right = 3
|
||||||
stretch_margin_bottom = 3
|
stretch_margin_bottom = 3
|
||||||
script = ExtResource( 4 )
|
script = ExtResource( 4 )
|
||||||
suffix = "%"
|
suffix = "%"
|
||||||
|
snap_step = 10.0
|
||||||
|
|
||||||
[node name="AngleLabel" type="Label" parent="VBoxContainer/GradientOptions" index="10" groups=["gradient_dithering", "gradient_linear", "gradient_step"]]
|
[node name="AngleLabel" type="Label" parent="VBoxContainer/GradientOptions" index="10" groups=["gradient_linear"]]
|
||||||
margin_top = 108.0
|
margin_top = 108.0
|
||||||
margin_right = 137.0
|
margin_right = 137.0
|
||||||
margin_bottom = 122.0
|
margin_bottom = 122.0
|
||||||
text = "Angle:"
|
text = "Angle:"
|
||||||
|
|
||||||
[node name="AngleSlider" type="TextureProgress" parent="VBoxContainer/GradientOptions" index="11" groups=["gradient_dithering", "gradient_linear"]]
|
[node name="AngleSlider" type="TextureProgress" parent="VBoxContainer/GradientOptions" index="11" groups=["gradient_linear"]]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
margin_left = 141.0
|
margin_left = 141.0
|
||||||
margin_top = 108.0
|
margin_top = 108.0
|
||||||
|
@ -158,113 +161,44 @@ stretch_margin_right = 3
|
||||||
stretch_margin_bottom = 3
|
stretch_margin_bottom = 3
|
||||||
script = ExtResource( 4 )
|
script = ExtResource( 4 )
|
||||||
suffix = "°"
|
suffix = "°"
|
||||||
|
snap_step = 45.0
|
||||||
|
|
||||||
[node name="CenterLabel" type="Label" parent="VBoxContainer/GradientOptions" index="12" groups=["gradient_radial", "gradient_radial_dithering", "gradient_radial_step"]]
|
[node name="CenterLabel" type="Label" parent="VBoxContainer/GradientOptions" index="12" groups=["gradient_radial"]]
|
||||||
visible = false
|
visible = false
|
||||||
margin_top = 60.0
|
margin_top = 60.0
|
||||||
margin_right = 160.0
|
margin_right = 160.0
|
||||||
margin_bottom = 74.0
|
margin_bottom = 74.0
|
||||||
|
size_flags_vertical = 1
|
||||||
text = "Center:"
|
text = "Center:"
|
||||||
|
|
||||||
[node name="CenterContainer" type="HBoxContainer" parent="VBoxContainer/GradientOptions" index="13" groups=["gradient_radial", "gradient_radial_dithering", "gradient_radial_step"]]
|
[node name="CenterSlider" parent="VBoxContainer/GradientOptions" index="13" groups=["gradient_radial"] instance=ExtResource( 5 )]
|
||||||
|
unique_name_in_owner = true
|
||||||
visible = false
|
visible = false
|
||||||
margin_top = 60.0
|
value = Vector2( 50, 50 )
|
||||||
margin_right = 154.0
|
|
||||||
margin_bottom = 84.0
|
|
||||||
|
|
||||||
[node name="XCenterSlider" type="TextureProgress" parent="VBoxContainer/GradientOptions/CenterContainer" index="0"]
|
|
||||||
unique_name_in_owner = true
|
|
||||||
margin_right = 75.0
|
|
||||||
margin_bottom = 24.0
|
|
||||||
mouse_default_cursor_shape = 2
|
|
||||||
size_flags_horizontal = 3
|
|
||||||
theme_type_variation = "ValueSlider"
|
|
||||||
value = 50.0
|
|
||||||
allow_greater = true
|
allow_greater = true
|
||||||
allow_lesser = true
|
allow_lesser = true
|
||||||
nine_patch_stretch = true
|
snap_step = 10.0
|
||||||
stretch_margin_left = 3
|
suffix_x = "%"
|
||||||
stretch_margin_top = 3
|
suffix_y = "%"
|
||||||
stretch_margin_right = 3
|
|
||||||
stretch_margin_bottom = 3
|
|
||||||
script = ExtResource( 4 )
|
|
||||||
prefix = "X:"
|
|
||||||
suffix = "%"
|
|
||||||
|
|
||||||
[node name="YCenterSlider" type="TextureProgress" parent="VBoxContainer/GradientOptions/CenterContainer" index="1"]
|
[node name="RadiusLabel" type="Label" parent="VBoxContainer/GradientOptions" index="14" groups=["gradient_radial"]]
|
||||||
unique_name_in_owner = true
|
|
||||||
margin_left = 79.0
|
|
||||||
margin_right = 154.0
|
|
||||||
margin_bottom = 24.0
|
|
||||||
mouse_default_cursor_shape = 2
|
|
||||||
size_flags_horizontal = 3
|
|
||||||
theme_type_variation = "ValueSlider"
|
|
||||||
value = 50.0
|
|
||||||
allow_greater = true
|
|
||||||
allow_lesser = true
|
|
||||||
nine_patch_stretch = true
|
|
||||||
stretch_margin_left = 3
|
|
||||||
stretch_margin_top = 3
|
|
||||||
stretch_margin_right = 3
|
|
||||||
stretch_margin_bottom = 3
|
|
||||||
script = ExtResource( 4 )
|
|
||||||
prefix = "Y:"
|
|
||||||
suffix = "%"
|
|
||||||
|
|
||||||
[node name="RadiusLabel" type="Label" parent="VBoxContainer/GradientOptions" index="14" groups=["gradient_radial", "gradient_radial_dithering", "gradient_radial_step"]]
|
|
||||||
visible = false
|
visible = false
|
||||||
margin_top = 193.0
|
margin_top = 193.0
|
||||||
margin_right = 160.0
|
margin_right = 160.0
|
||||||
margin_bottom = 207.0
|
margin_bottom = 207.0
|
||||||
|
size_flags_vertical = 1
|
||||||
text = "Radius:"
|
text = "Radius:"
|
||||||
|
|
||||||
[node name="RadiusContainer" type="HBoxContainer" parent="VBoxContainer/GradientOptions" index="15" groups=["gradient_radial", "gradient_radial_dithering", "gradient_radial_step"]]
|
[node name="RadiusSlider" parent="VBoxContainer/GradientOptions" index="15" groups=["gradient_radial"] instance=ExtResource( 5 )]
|
||||||
|
unique_name_in_owner = true
|
||||||
visible = false
|
visible = false
|
||||||
margin_top = 60.0
|
margin_right = 52.0
|
||||||
margin_right = 154.0
|
value = Vector2( 1, 1 )
|
||||||
margin_bottom = 84.0
|
min_value = Vector2( 0.01, 0.01 )
|
||||||
size_flags_vertical = 3
|
max_value = Vector2( 10, 10 )
|
||||||
|
|
||||||
[node name="XRadiusSlider" type="TextureProgress" parent="VBoxContainer/GradientOptions/RadiusContainer" index="0"]
|
|
||||||
unique_name_in_owner = true
|
|
||||||
margin_right = 75.0
|
|
||||||
margin_bottom = 24.0
|
|
||||||
mouse_default_cursor_shape = 2
|
|
||||||
size_flags_horizontal = 3
|
|
||||||
theme_type_variation = "ValueSlider"
|
|
||||||
min_value = 0.01
|
|
||||||
max_value = 10.0
|
|
||||||
step = 0.01
|
step = 0.01
|
||||||
value = 1.0
|
|
||||||
allow_greater = true
|
allow_greater = true
|
||||||
nine_patch_stretch = true
|
show_ratio = true
|
||||||
stretch_margin_left = 3
|
|
||||||
stretch_margin_top = 3
|
|
||||||
stretch_margin_right = 3
|
|
||||||
stretch_margin_bottom = 3
|
|
||||||
script = ExtResource( 4 )
|
|
||||||
prefix = "X:"
|
|
||||||
|
|
||||||
[node name="YRadiusSlider" type="TextureProgress" parent="VBoxContainer/GradientOptions/RadiusContainer" index="1"]
|
|
||||||
unique_name_in_owner = true
|
|
||||||
margin_left = 79.0
|
|
||||||
margin_right = 154.0
|
|
||||||
margin_bottom = 24.0
|
|
||||||
mouse_default_cursor_shape = 2
|
|
||||||
size_flags_horizontal = 3
|
|
||||||
theme_type_variation = "ValueSlider"
|
|
||||||
min_value = 0.01
|
|
||||||
max_value = 10.0
|
|
||||||
step = 0.01
|
|
||||||
value = 1.0
|
|
||||||
allow_greater = true
|
|
||||||
nine_patch_stretch = true
|
|
||||||
stretch_margin_left = 3
|
|
||||||
stretch_margin_top = 3
|
|
||||||
stretch_margin_right = 3
|
|
||||||
stretch_margin_bottom = 3
|
|
||||||
script = ExtResource( 4 )
|
|
||||||
prefix = "Y:"
|
|
||||||
|
|
||||||
[node name="OptionsContainer" parent="VBoxContainer" index="3"]
|
[node name="OptionsContainer" parent="VBoxContainer" index="3"]
|
||||||
margin_top = 412.0
|
margin_top = 412.0
|
||||||
|
@ -298,7 +232,5 @@ margin_right = 278.0
|
||||||
[connection signal="value_changed" from="VBoxContainer/GradientOptions/PositionSlider" to="." method="_value_changed"]
|
[connection signal="value_changed" from="VBoxContainer/GradientOptions/PositionSlider" to="." method="_value_changed"]
|
||||||
[connection signal="value_changed" from="VBoxContainer/GradientOptions/SizeSlider" to="." method="_value_changed"]
|
[connection signal="value_changed" from="VBoxContainer/GradientOptions/SizeSlider" to="." method="_value_changed"]
|
||||||
[connection signal="value_changed" from="VBoxContainer/GradientOptions/AngleSlider" to="." method="_value_changed"]
|
[connection signal="value_changed" from="VBoxContainer/GradientOptions/AngleSlider" to="." method="_value_changed"]
|
||||||
[connection signal="value_changed" from="VBoxContainer/GradientOptions/CenterContainer/XCenterSlider" to="." method="_value_changed"]
|
[connection signal="value_changed" from="VBoxContainer/GradientOptions/CenterSlider" to="." method="_value_v2_changed"]
|
||||||
[connection signal="value_changed" from="VBoxContainer/GradientOptions/CenterContainer/YCenterSlider" to="." method="_value_changed"]
|
[connection signal="value_changed" from="VBoxContainer/GradientOptions/RadiusSlider" to="." method="_value_v2_changed"]
|
||||||
[connection signal="value_changed" from="VBoxContainer/GradientOptions/RadiusContainer/XRadiusSlider" to="." method="_value_changed"]
|
|
||||||
[connection signal="value_changed" from="VBoxContainer/GradientOptions/RadiusContainer/YRadiusSlider" to="." method="_value_changed"]
|
|
||||||
|
|
Loading…
Reference in a new issue