mirror of
https://github.com/tonytins/CozyPixelStudio.git
synced 2025-06-25 12:04:43 -04:00
Added Previews and Better Saturation/Value Lerping
This commit is contained in:
parent
2b8796aacc
commit
cb051239dc
4 changed files with 186 additions and 149 deletions
|
@ -1,45 +1,62 @@
|
|||
extends WindowDialog
|
||||
|
||||
onready var hue_slider = $ HBoxContainer/Sliders/Hue
|
||||
onready var sat_slider = $ HBoxContainer/Sliders/Saturation
|
||||
onready var val_slider = $ HBoxContainer/Sliders/Value
|
||||
onready var hue_slider = $MarginContainer/VBoxContainer/HBoxContainer/Sliders/Hue
|
||||
onready var sat_slider = $MarginContainer/VBoxContainer/HBoxContainer/Sliders/Saturation
|
||||
onready var val_slider = $MarginContainer/VBoxContainer/HBoxContainer/Sliders/Value
|
||||
|
||||
onready var hue_spinbox = $ HBoxContainer/TextBoxes/Hue
|
||||
onready var sat_spinbox = $ HBoxContainer/TextBoxes/Saturation
|
||||
onready var val_spinbox = $ HBoxContainer/TextBoxes/Value
|
||||
onready var hue_spinbox = $MarginContainer/VBoxContainer/HBoxContainer/TextBoxes/Hue
|
||||
onready var sat_spinbox = $MarginContainer/VBoxContainer/HBoxContainer/TextBoxes/Saturation
|
||||
onready var val_spinbox = $MarginContainer/VBoxContainer/HBoxContainer/TextBoxes/Value
|
||||
|
||||
onready var hue_text = $ HBoxContainer/TextBoxes/Hue.get_line_edit()
|
||||
onready var sat_text = $ HBoxContainer/TextBoxes/Saturation.get_line_edit()
|
||||
onready var val_text = $ HBoxContainer/TextBoxes/Value.get_line_edit()
|
||||
onready var preview = $MarginContainer/VBoxContainer/TextureRect
|
||||
|
||||
var oldHue = 180
|
||||
var oldSat = 50
|
||||
var oldVal = 50
|
||||
var current_layer:Image
|
||||
var preview_image:Image
|
||||
var preview_texture:ImageTexture
|
||||
|
||||
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():
|
||||
Global.undo_redo.undo()
|
||||
visible = false
|
||||
reset()
|
||||
|
||||
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")
|
||||
reset()
|
||||
visible = false
|
||||
|
||||
|
||||
func reset():
|
||||
disconnect_signals()
|
||||
hue_slider.value = 180
|
||||
sat_slider.value = 50
|
||||
val_slider.value = 50
|
||||
hue_text.text = str(180)
|
||||
sat_text.text = str(50)
|
||||
val_text.text = str(50)
|
||||
hue_slider.value = 0
|
||||
sat_slider.value = 0
|
||||
val_slider.value = 0
|
||||
hue_spinbox.value = 0
|
||||
sat_spinbox.value = 0
|
||||
val_spinbox.value = 0
|
||||
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():
|
||||
hue_slider.disconnect("value_changed",self,"_on_Hue_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")
|
||||
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):
|
||||
hue_text.text = str(value)
|
||||
hue_slider.value = int(value)
|
||||
var delta = value - oldHue
|
||||
oldHue = value
|
||||
Global.canvas.adjust_hsv(0,delta)
|
||||
hue_spinbox.value = value
|
||||
hue_slider.value = value
|
||||
update_preview()
|
||||
|
||||
func _on_Saturation_value_changed(value):
|
||||
sat_text.text = str(value)
|
||||
sat_slider.value = int(value)
|
||||
var delta = value - oldSat
|
||||
oldSat = value
|
||||
Global.canvas.adjust_hsv(1,delta)
|
||||
|
||||
sat_spinbox.value = value
|
||||
sat_slider.value = value
|
||||
update_preview()
|
||||
|
||||
func _on_Value_value_changed(value):
|
||||
val_text.text = str(value)
|
||||
val_slider.value = int(value)
|
||||
var delta = value - oldVal
|
||||
oldVal = value
|
||||
Global.canvas.adjust_hsv(2,delta)
|
||||
|
||||
val_spinbox.value = value
|
||||
val_slider.value = value
|
||||
update_preview()
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue