mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-19 01:29:49 +00:00
Added Previews and Better Saturation/Value Lerping
This commit is contained in:
parent
2b8796aacc
commit
cb051239dc
|
@ -3,135 +3,160 @@
|
||||||
[ext_resource path="res://Scripts/Dialogs/HSVDialog.gd" type="Script" id=1]
|
[ext_resource path="res://Scripts/Dialogs/HSVDialog.gd" type="Script" id=1]
|
||||||
|
|
||||||
[node name="HSVDialog" type="WindowDialog"]
|
[node name="HSVDialog" type="WindowDialog"]
|
||||||
|
visible = true
|
||||||
margin_left = 1.0
|
margin_left = 1.0
|
||||||
margin_top = -1.0
|
margin_top = -1.0
|
||||||
margin_right = 464.0
|
margin_right = 464.0
|
||||||
margin_bottom = 151.0
|
margin_bottom = 318.0
|
||||||
window_title = "Adjust HSV"
|
window_title = "Adjust HSV"
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
[node name="HBoxContainer" type="HBoxContainer" parent="."]
|
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
margin_top = 17.0
|
custom_constants/margin_right = 5
|
||||||
margin_right = -8.0
|
custom_constants/margin_top = 5
|
||||||
margin_bottom = -44.0
|
custom_constants/margin_left = 5
|
||||||
|
custom_constants/margin_bottom = 5
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
|
||||||
|
margin_left = 5.0
|
||||||
|
margin_top = 5.0
|
||||||
|
margin_right = 458.0
|
||||||
|
margin_bottom = 314.0
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="TextureRect" type="TextureRect" parent="MarginContainer/VBoxContainer"]
|
||||||
|
margin_right = 453.0
|
||||||
|
margin_bottom = 197.0
|
||||||
|
size_flags_vertical = 3
|
||||||
|
expand = true
|
||||||
|
stretch_mode = 6
|
||||||
|
|
||||||
|
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
|
||||||
|
margin_top = 201.0
|
||||||
|
margin_right = 453.0
|
||||||
|
margin_bottom = 285.0
|
||||||
custom_constants/separation = 10
|
custom_constants/separation = 10
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="Names" type="VBoxContainer" parent="HBoxContainer"]
|
[node name="Names" type="VBoxContainer" parent="MarginContainer/VBoxContainer/HBoxContainer"]
|
||||||
margin_right = 83.0
|
margin_right = 82.0
|
||||||
margin_bottom = 91.0
|
margin_bottom = 84.0
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
size_flags_stretch_ratio = 0.9
|
size_flags_stretch_ratio = 0.9
|
||||||
custom_constants/separation = 8
|
custom_constants/separation = 8
|
||||||
|
|
||||||
[node name="Hue" type="Label" parent="HBoxContainer/Names"]
|
[node name="Hue" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer/Names"]
|
||||||
margin_right = 83.0
|
margin_right = 82.0
|
||||||
margin_bottom = 14.0
|
margin_bottom = 14.0
|
||||||
text = "Hue"
|
text = "Hue"
|
||||||
align = 2
|
align = 2
|
||||||
|
|
||||||
[node name="Saturation" type="Label" parent="HBoxContainer/Names"]
|
[node name="Saturation" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer/Names"]
|
||||||
margin_top = 22.0
|
margin_top = 22.0
|
||||||
margin_right = 83.0
|
margin_right = 82.0
|
||||||
margin_bottom = 36.0
|
margin_bottom = 36.0
|
||||||
text = "Saturation"
|
text = "Saturation"
|
||||||
align = 2
|
align = 2
|
||||||
|
|
||||||
[node name="Value" type="Label" parent="HBoxContainer/Names"]
|
[node name="Value" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer/Names"]
|
||||||
margin_top = 44.0
|
margin_top = 44.0
|
||||||
margin_right = 83.0
|
margin_right = 82.0
|
||||||
margin_bottom = 58.0
|
margin_bottom = 58.0
|
||||||
text = "Value"
|
text = "Value"
|
||||||
align = 2
|
align = 2
|
||||||
|
|
||||||
[node name="Sliders" type="VBoxContainer" parent="HBoxContainer"]
|
[node name="Sliders" type="VBoxContainer" parent="MarginContainer/VBoxContainer/HBoxContainer"]
|
||||||
margin_left = 93.0
|
margin_left = 92.0
|
||||||
margin_right = 370.0
|
margin_right = 368.0
|
||||||
margin_bottom = 91.0
|
margin_bottom = 84.0
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
size_flags_stretch_ratio = 3.0
|
size_flags_stretch_ratio = 3.0
|
||||||
custom_constants/separation = 7
|
custom_constants/separation = 7
|
||||||
|
|
||||||
[node name="Hue" type="HSlider" parent="HBoxContainer/Sliders"]
|
[node name="Hue" type="HSlider" parent="MarginContainer/VBoxContainer/HBoxContainer/Sliders"]
|
||||||
margin_right = 277.0
|
margin_right = 276.0
|
||||||
margin_bottom = 16.0
|
margin_bottom = 16.0
|
||||||
max_value = 359.0
|
min_value = -180.0
|
||||||
value = 180.0
|
max_value = 180.0
|
||||||
|
|
||||||
[node name="Saturation" type="HSlider" parent="HBoxContainer/Sliders"]
|
[node name="Saturation" type="HSlider" parent="MarginContainer/VBoxContainer/HBoxContainer/Sliders"]
|
||||||
margin_top = 23.0
|
margin_top = 23.0
|
||||||
margin_right = 277.0
|
margin_right = 276.0
|
||||||
margin_bottom = 39.0
|
margin_bottom = 39.0
|
||||||
max_value = 99.0
|
min_value = -100.0
|
||||||
value = 50.0
|
max_value = 100.0
|
||||||
|
|
||||||
[node name="Value" type="HSlider" parent="HBoxContainer/Sliders"]
|
[node name="Value" type="HSlider" parent="MarginContainer/VBoxContainer/HBoxContainer/Sliders"]
|
||||||
margin_top = 46.0
|
margin_top = 46.0
|
||||||
margin_right = 277.0
|
margin_right = 276.0
|
||||||
margin_bottom = 62.0
|
margin_bottom = 62.0
|
||||||
max_value = 99.0
|
min_value = -100.0
|
||||||
value = 50.0
|
max_value = 100.0
|
||||||
|
|
||||||
[node name="TextBoxes" type="VBoxContainer" parent="HBoxContainer"]
|
[node name="TextBoxes" type="VBoxContainer" parent="MarginContainer/VBoxContainer/HBoxContainer"]
|
||||||
margin_left = 380.0
|
margin_left = 378.0
|
||||||
margin_right = 454.0
|
margin_right = 452.0
|
||||||
margin_bottom = 91.0
|
margin_bottom = 84.0
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
size_flags_stretch_ratio = 0.0
|
size_flags_stretch_ratio = 0.0
|
||||||
custom_constants/separation = 6
|
custom_constants/separation = 6
|
||||||
|
|
||||||
[node name="Hue" type="SpinBox" parent="HBoxContainer/TextBoxes"]
|
[node name="Hue" type="SpinBox" parent="MarginContainer/VBoxContainer/HBoxContainer/TextBoxes"]
|
||||||
margin_right = 74.0
|
margin_right = 74.0
|
||||||
margin_bottom = 24.0
|
margin_bottom = 24.0
|
||||||
max_value = 359.0
|
min_value = -180.0
|
||||||
value = 180.0
|
max_value = 180.0
|
||||||
|
|
||||||
[node name="Saturation" type="SpinBox" parent="HBoxContainer/TextBoxes"]
|
[node name="Saturation" type="SpinBox" parent="MarginContainer/VBoxContainer/HBoxContainer/TextBoxes"]
|
||||||
margin_top = 30.0
|
margin_top = 30.0
|
||||||
margin_right = 74.0
|
margin_right = 74.0
|
||||||
margin_bottom = 54.0
|
margin_bottom = 54.0
|
||||||
max_value = 359.0
|
min_value = -100.0
|
||||||
value = 50.0
|
max_value = 100.0
|
||||||
|
|
||||||
[node name="Value" type="SpinBox" parent="HBoxContainer/TextBoxes"]
|
[node name="Value" type="SpinBox" parent="MarginContainer/VBoxContainer/HBoxContainer/TextBoxes"]
|
||||||
margin_top = 60.0
|
margin_top = 60.0
|
||||||
margin_right = 74.0
|
margin_right = 74.0
|
||||||
margin_bottom = 84.0
|
margin_bottom = 84.0
|
||||||
max_value = 359.0
|
min_value = -100.0
|
||||||
value = 50.0
|
max_value = 100.0
|
||||||
|
|
||||||
[node name="HBoxContainer2" type="HBoxContainer" parent="."]
|
[node name="HBoxContainer2" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
|
||||||
margin_left = 117.0
|
margin_top = 289.0
|
||||||
margin_top = 97.9999
|
margin_right = 453.0
|
||||||
margin_right = 359.0
|
margin_bottom = 309.0
|
||||||
margin_bottom = 138.0
|
|
||||||
custom_constants/separation = 16
|
custom_constants/separation = 16
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="Apply" type="Button" parent="HBoxContainer2"]
|
[node name="Apply" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer2"]
|
||||||
margin_right = 113.0
|
margin_right = 218.0
|
||||||
margin_bottom = 40.0
|
margin_bottom = 20.0
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
text = "Apply"
|
text = "Apply"
|
||||||
|
|
||||||
[node name="Cancel" type="Button" parent="HBoxContainer2"]
|
[node name="Cancel" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer2"]
|
||||||
margin_left = 129.0
|
margin_left = 234.0
|
||||||
margin_right = 242.0
|
margin_right = 453.0
|
||||||
margin_bottom = 40.0
|
margin_bottom = 20.0
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
text = "Cancel"
|
text = "Cancel"
|
||||||
[connection signal="about_to_show" from="." to="." method="_on_HSVDialog_about_to_show"]
|
[connection signal="about_to_show" from="." to="." method="_on_HSVDialog_about_to_show"]
|
||||||
[connection signal="value_changed" from="HBoxContainer/Sliders/Hue" to="." method="_on_Hue_value_changed"]
|
[connection signal="value_changed" from="MarginContainer/VBoxContainer/HBoxContainer/Sliders/Hue" to="." method="_on_Hue_value_changed"]
|
||||||
[connection signal="value_changed" from="HBoxContainer/Sliders/Saturation" to="." method="_on_Saturation_value_changed"]
|
[connection signal="value_changed" from="MarginContainer/VBoxContainer/HBoxContainer/Sliders/Saturation" to="." method="_on_Saturation_value_changed"]
|
||||||
[connection signal="value_changed" from="HBoxContainer/Sliders/Value" to="." method="_on_Value_value_changed"]
|
[connection signal="value_changed" from="MarginContainer/VBoxContainer/HBoxContainer/Sliders/Value" to="." method="_on_Value_value_changed"]
|
||||||
[connection signal="value_changed" from="HBoxContainer/TextBoxes/Hue" to="." method="_on_Hue_value_changed"]
|
[connection signal="value_changed" from="MarginContainer/VBoxContainer/HBoxContainer/TextBoxes/Hue" to="." method="_on_Hue_value_changed"]
|
||||||
[connection signal="value_changed" from="HBoxContainer/TextBoxes/Saturation" to="." method="_on_Saturation_value_changed"]
|
[connection signal="value_changed" from="MarginContainer/VBoxContainer/HBoxContainer/TextBoxes/Saturation" to="." method="_on_Saturation_value_changed"]
|
||||||
[connection signal="value_changed" from="HBoxContainer/TextBoxes/Value" to="." method="_on_Value_value_changed"]
|
[connection signal="value_changed" from="MarginContainer/VBoxContainer/HBoxContainer/TextBoxes/Value" to="." method="_on_Value_value_changed"]
|
||||||
[connection signal="pressed" from="HBoxContainer2/Apply" to="." method="_on_Apply_pressed"]
|
[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer2/Apply" to="." method="_on_Apply_pressed"]
|
||||||
[connection signal="pressed" from="HBoxContainer2/Cancel" to="." method="_on_Cancel_pressed"]
|
[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer2/Cancel" to="." method="_on_Cancel_pressed"]
|
||||||
|
|
|
@ -1011,9 +1011,9 @@ func blend_rect(bg : Image, brush : Image, src_rect : Rect2, dst : Vector2) -> v
|
||||||
bg.set_pixel(dst_x, dst_y, out_color)
|
bg.set_pixel(dst_x, dst_y, out_color)
|
||||||
brush.unlock()
|
brush.unlock()
|
||||||
|
|
||||||
func adjust_hsv(id,delta)->void:
|
func adjust_hsv(img: Image, id, delta)->void:
|
||||||
var selection_only:bool = !Global.selected_pixels.empty()
|
var selection_only:bool = !Global.selected_pixels.empty()
|
||||||
var layer:Image = layers[Global.current_layer][0]
|
var layer:Image = img
|
||||||
layer.lock()
|
layer.lock()
|
||||||
match id:
|
match id:
|
||||||
#Hue
|
#Hue
|
||||||
|
@ -1022,25 +1022,25 @@ func adjust_hsv(id,delta)->void:
|
||||||
for j in range(layer.get_height()):
|
for j in range(layer.get_height()):
|
||||||
if(selection_only and Global.selected_pixels.has(Vector2(i,j))):
|
if(selection_only and Global.selected_pixels.has(Vector2(i,j))):
|
||||||
var c: Color = layer.get_pixel(i,j)
|
var c: Color = layer.get_pixel(i,j)
|
||||||
var hue = range_lerp(c.h,0,1,0,360)
|
var hue = range_lerp(c.h,0,1,-180,180)
|
||||||
hue = hue + delta
|
hue = hue + delta
|
||||||
|
|
||||||
while(hue >= 360):
|
while(hue >= 180):
|
||||||
hue -= 360
|
hue -= 360
|
||||||
while(hue < 0):
|
while(hue < -180):
|
||||||
hue += 360
|
hue += 360
|
||||||
c.h = range_lerp(hue,0,360,0,1)
|
c.h = range_lerp(hue,-180,180,0,1)
|
||||||
layer.set_pixel(i,j,c)
|
layer.set_pixel(i,j,c)
|
||||||
elif(!selection_only):
|
elif(!selection_only):
|
||||||
var c: Color = layer.get_pixel(i,j)
|
var c: Color = layer.get_pixel(i,j)
|
||||||
var hue = range_lerp(c.h,0,1,0,360)
|
var hue = range_lerp(c.h,0,1,-180,180)
|
||||||
hue = hue + delta
|
hue = hue + delta
|
||||||
|
|
||||||
while(hue >= 360):
|
while(hue >= 180):
|
||||||
hue -= 360
|
hue -= 360
|
||||||
while(hue < 0):
|
while(hue < -180):
|
||||||
hue += 360
|
hue += 360
|
||||||
c.h = range_lerp(hue,0,360,0,1)
|
c.h = range_lerp(hue,-180,180,0,1)
|
||||||
layer.set_pixel(i,j,c)
|
layer.set_pixel(i,j,c)
|
||||||
|
|
||||||
#Saturation
|
#Saturation
|
||||||
|
@ -1049,19 +1049,21 @@ func adjust_hsv(id,delta)->void:
|
||||||
for j in range(layer.get_height()):
|
for j in range(layer.get_height()):
|
||||||
if(selection_only and Global.selected_pixels.has(Vector2(i,j))):
|
if(selection_only and Global.selected_pixels.has(Vector2(i,j))):
|
||||||
var c: Color = layer.get_pixel(i,j)
|
var c: Color = layer.get_pixel(i,j)
|
||||||
var sat = range_lerp(c.s,0,1,0,100)
|
var sat = c.s
|
||||||
sat = sat + delta
|
if delta > 0:
|
||||||
|
sat = range_lerp(delta,0,100,c.s,1)
|
||||||
sat = clamp(sat,0,100)
|
elif delta < 0:
|
||||||
c.s = range_lerp(sat,0,100,0,1)
|
sat = range_lerp(delta,-100,0,0,c.s)
|
||||||
layer.set_pixel(i,j,c)
|
c.s = sat
|
||||||
elif(!selection_only):
|
elif(!selection_only):
|
||||||
var c: Color = layer.get_pixel(i,j)
|
var c: Color = layer.get_pixel(i,j)
|
||||||
var sat = range_lerp(c.s,0,1,0,100)
|
var sat = c.s
|
||||||
sat = sat + delta
|
if delta > 0:
|
||||||
|
sat = range_lerp(delta,0,100,c.s,1)
|
||||||
sat = clamp(sat,0,100)
|
elif delta < 0:
|
||||||
c.s = range_lerp(sat,0,100,0,1)
|
sat = range_lerp(delta,-100,0,0,c.s)
|
||||||
|
c.s = sat
|
||||||
|
print(sat)
|
||||||
layer.set_pixel(i,j,c)
|
layer.set_pixel(i,j,c)
|
||||||
|
|
||||||
#value
|
#value
|
||||||
|
@ -1070,21 +1072,23 @@ func adjust_hsv(id,delta)->void:
|
||||||
for j in range(layer.get_height()):
|
for j in range(layer.get_height()):
|
||||||
if(selection_only and Global.selected_pixels.has(Vector2(i,j))):
|
if(selection_only and Global.selected_pixels.has(Vector2(i,j))):
|
||||||
var c: Color = layer.get_pixel(i,j)
|
var c: Color = layer.get_pixel(i,j)
|
||||||
var val = range_lerp(c.v,0,1,0,100)
|
var val = c.v
|
||||||
val = val + delta
|
if delta > 0:
|
||||||
|
val = range_lerp(delta,0,100,c.v,1)
|
||||||
|
elif delta < 0:
|
||||||
|
val = range_lerp(delta,-100,0,0,c.v)
|
||||||
|
|
||||||
val = clamp(val,0,100)
|
c.s = val
|
||||||
c.v = range_lerp(val,0,100,0,1)
|
|
||||||
layer.set_pixel(i,j,c)
|
layer.set_pixel(i,j,c)
|
||||||
elif(!selection_only):
|
elif(!selection_only):
|
||||||
var c: Color = layer.get_pixel(i,j)
|
var c: Color = layer.get_pixel(i,j)
|
||||||
var val = range_lerp(c.v,0,1,0,100)
|
var val = c.v
|
||||||
val = val + delta
|
if delta > 0:
|
||||||
|
val = range_lerp(delta,0,100,c.v,1)
|
||||||
|
elif delta < 0:
|
||||||
|
val = range_lerp(delta,-100,0,0,c.v)
|
||||||
|
|
||||||
val = clamp(val,0,100)
|
c.v = val
|
||||||
c.v = range_lerp(val,0,100,0,1)
|
|
||||||
layer.set_pixel(i,j,c)
|
layer.set_pixel(i,j,c)
|
||||||
|
|
||||||
layer.unlock()
|
layer.unlock()
|
||||||
update_texture(Global.current_layer)
|
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -1,45 +1,62 @@
|
||||||
extends WindowDialog
|
extends WindowDialog
|
||||||
|
|
||||||
onready var hue_slider = $ HBoxContainer/Sliders/Hue
|
onready var hue_slider = $MarginContainer/VBoxContainer/HBoxContainer/Sliders/Hue
|
||||||
onready var sat_slider = $ HBoxContainer/Sliders/Saturation
|
onready var sat_slider = $MarginContainer/VBoxContainer/HBoxContainer/Sliders/Saturation
|
||||||
onready var val_slider = $ HBoxContainer/Sliders/Value
|
onready var val_slider = $MarginContainer/VBoxContainer/HBoxContainer/Sliders/Value
|
||||||
|
|
||||||
onready var hue_spinbox = $ HBoxContainer/TextBoxes/Hue
|
onready var hue_spinbox = $MarginContainer/VBoxContainer/HBoxContainer/TextBoxes/Hue
|
||||||
onready var sat_spinbox = $ HBoxContainer/TextBoxes/Saturation
|
onready var sat_spinbox = $MarginContainer/VBoxContainer/HBoxContainer/TextBoxes/Saturation
|
||||||
onready var val_spinbox = $ HBoxContainer/TextBoxes/Value
|
onready var val_spinbox = $MarginContainer/VBoxContainer/HBoxContainer/TextBoxes/Value
|
||||||
|
|
||||||
onready var hue_text = $ HBoxContainer/TextBoxes/Hue.get_line_edit()
|
onready var preview = $MarginContainer/VBoxContainer/TextureRect
|
||||||
onready var sat_text = $ HBoxContainer/TextBoxes/Saturation.get_line_edit()
|
|
||||||
onready var val_text = $ HBoxContainer/TextBoxes/Value.get_line_edit()
|
|
||||||
|
|
||||||
var oldHue = 180
|
var current_layer:Image
|
||||||
var oldSat = 50
|
var preview_image:Image
|
||||||
var oldVal = 50
|
var preview_texture:ImageTexture
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
get_close_button().connect("pressed",self,"_on_Cancel_pressed")
|
current_layer = Image.new()
|
||||||
|
preview_image = Image.new()
|
||||||
|
preview_texture = ImageTexture.new()
|
||||||
|
preview_texture.flags = 0
|
||||||
|
|
||||||
|
func _on_HSVDialog_about_to_show():
|
||||||
|
current_layer = Global.canvas.layers[Global.current_layer][0]
|
||||||
|
preview_image.copy_from(current_layer)
|
||||||
|
update_preview()
|
||||||
|
|
||||||
func _on_Cancel_pressed():
|
func _on_Cancel_pressed():
|
||||||
Global.undo_redo.undo()
|
|
||||||
visible = false
|
visible = false
|
||||||
reset()
|
reset()
|
||||||
|
|
||||||
func _on_Apply_pressed():
|
func _on_Apply_pressed():
|
||||||
|
Global.canvas.handle_undo("Draw")
|
||||||
|
Global.canvas.adjust_hsv(current_layer,0,hue_slider.value)
|
||||||
|
Global.canvas.adjust_hsv(current_layer,1,sat_slider.value)
|
||||||
|
Global.canvas.adjust_hsv(current_layer,2,val_slider.value)
|
||||||
|
Global.canvas.update_texture(Global.current_layer)
|
||||||
Global.canvas.handle_redo("Draw")
|
Global.canvas.handle_redo("Draw")
|
||||||
reset()
|
reset()
|
||||||
visible = false
|
visible = false
|
||||||
|
|
||||||
|
|
||||||
func reset():
|
func reset():
|
||||||
disconnect_signals()
|
disconnect_signals()
|
||||||
hue_slider.value = 180
|
hue_slider.value = 0
|
||||||
sat_slider.value = 50
|
sat_slider.value = 0
|
||||||
val_slider.value = 50
|
val_slider.value = 0
|
||||||
hue_text.text = str(180)
|
hue_spinbox.value = 0
|
||||||
sat_text.text = str(50)
|
sat_spinbox.value = 0
|
||||||
val_text.text = str(50)
|
val_spinbox.value = 0
|
||||||
reconnect_signals()
|
reconnect_signals()
|
||||||
|
|
||||||
|
func update_preview():
|
||||||
|
preview_image.copy_from(current_layer)
|
||||||
|
Global.canvas.adjust_hsv(preview_image,0,hue_slider.value)
|
||||||
|
Global.canvas.adjust_hsv(preview_image,1,sat_slider.value)
|
||||||
|
Global.canvas.adjust_hsv(preview_image,2,val_slider.value)
|
||||||
|
preview_texture.create_from_image(preview_image, 0)
|
||||||
|
preview.texture = preview_texture
|
||||||
|
|
||||||
func disconnect_signals():
|
func disconnect_signals():
|
||||||
hue_slider.disconnect("value_changed",self,"_on_Hue_value_changed")
|
hue_slider.disconnect("value_changed",self,"_on_Hue_value_changed")
|
||||||
sat_slider.disconnect("value_changed",self,"_on_Saturation_value_changed")
|
sat_slider.disconnect("value_changed",self,"_on_Saturation_value_changed")
|
||||||
|
@ -56,32 +73,20 @@ func reconnect_signals():
|
||||||
sat_spinbox.connect("value_changed",self,"_on_Saturation_value_changed")
|
sat_spinbox.connect("value_changed",self,"_on_Saturation_value_changed")
|
||||||
val_spinbox.connect("value_changed",self,"_on_Value_value_changed")
|
val_spinbox.connect("value_changed",self,"_on_Value_value_changed")
|
||||||
|
|
||||||
|
|
||||||
func _on_HSVDialog_about_to_show():
|
|
||||||
Global.canvas.handle_undo("Draw")
|
|
||||||
|
|
||||||
func _on_Hue_value_changed(value):
|
func _on_Hue_value_changed(value):
|
||||||
hue_text.text = str(value)
|
hue_spinbox.value = value
|
||||||
hue_slider.value = int(value)
|
hue_slider.value = value
|
||||||
var delta = value - oldHue
|
update_preview()
|
||||||
oldHue = value
|
|
||||||
Global.canvas.adjust_hsv(0,delta)
|
|
||||||
|
|
||||||
func _on_Saturation_value_changed(value):
|
func _on_Saturation_value_changed(value):
|
||||||
sat_text.text = str(value)
|
sat_spinbox.value = value
|
||||||
sat_slider.value = int(value)
|
sat_slider.value = value
|
||||||
var delta = value - oldSat
|
update_preview()
|
||||||
oldSat = value
|
|
||||||
Global.canvas.adjust_hsv(1,delta)
|
|
||||||
|
|
||||||
|
|
||||||
func _on_Value_value_changed(value):
|
func _on_Value_value_changed(value):
|
||||||
val_text.text = str(value)
|
val_spinbox.value = value
|
||||||
val_slider.value = int(value)
|
val_slider.value = value
|
||||||
var delta = value - oldVal
|
update_preview()
|
||||||
oldVal = value
|
|
||||||
Global.canvas.adjust_hsv(2,delta)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue