mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 17:19:50 +00:00
commit
f27a3be6ae
21
Main.tscn
21
Main.tscn
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=54 format=2]
|
||||
[gd_scene load_steps=55 format=2]
|
||||
|
||||
[ext_resource path="res://Themes & Styles/Dark Theme/Dark Theme.tres" type="Theme" id=1]
|
||||
[ext_resource path="res://Scripts/Main.gd" type="Script" id=2]
|
||||
|
@ -43,6 +43,7 @@
|
|||
[ext_resource path="res://Assets/Graphics/Dark Themes/Tools/Vertical_Mirror_On.png" type="Texture" id=41]
|
||||
[ext_resource path="res://Assets/Graphics/Dark Themes/Tools/Vertical_Mirror_Off.png" type="Texture" id=42]
|
||||
[ext_resource path="res://Assets/Graphics/Dark Themes/Tools/Zoom.png" type="Texture" id=43]
|
||||
[ext_resource path="res://Prefabs/Dialogs/HSVDialog.tscn" type="PackedScene" id=44]
|
||||
|
||||
[sub_resource type="InputEventKey" id=1]
|
||||
scancode = 88
|
||||
|
@ -1295,8 +1296,8 @@ resizable = true
|
|||
mode = 0
|
||||
access = 2
|
||||
filters = PoolStringArray( "*.pxo ; Pixelorama Project" )
|
||||
current_dir = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama"
|
||||
current_path = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama/"
|
||||
current_dir = "D:/libDev/git/Pixelorama-git"
|
||||
current_path = "D:/libDev/git/Pixelorama-git/"
|
||||
|
||||
[node name="SaveSprite" type="FileDialog" parent="."]
|
||||
anchor_left = 0.5
|
||||
|
@ -1311,10 +1312,12 @@ window_title = "Save Sprite as .pxo"
|
|||
resizable = true
|
||||
access = 2
|
||||
filters = PoolStringArray( "*.pxo ; Pixelorama Project" )
|
||||
current_dir = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama"
|
||||
current_path = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama/"
|
||||
current_dir = "D:/libDev/git/Pixelorama-git"
|
||||
current_path = "D:/libDev/git/Pixelorama-git/"
|
||||
|
||||
[node name="ImportSprites" parent="." instance=ExtResource( 29 )]
|
||||
current_dir = "D:/libDev/git/Pixelorama-git"
|
||||
current_path = "D:/libDev/git/Pixelorama-git/"
|
||||
|
||||
[node name="ExportDialog" parent="." instance=ExtResource( 39 )]
|
||||
|
||||
|
@ -1363,8 +1366,11 @@ dialog_text = "This is an error message!"
|
|||
|
||||
[node name="PaletteImportFileDialog" parent="." instance=ExtResource( 37 )]
|
||||
filters = PoolStringArray( "*.json ; JavaScript Object Notation", "*.gpl ; Gimp Palette Library", "*.png; Portable Network Graphics" )
|
||||
current_dir = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama"
|
||||
current_path = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama/"
|
||||
current_dir = "D:/libDev/git/Pixelorama-git"
|
||||
current_path = "D:/libDev/git/Pixelorama-git/"
|
||||
|
||||
[node name="HSVDialog" parent="." instance=ExtResource( 44 )]
|
||||
visible = false
|
||||
|
||||
[node name="LeftCursor" type="Sprite" parent="."]
|
||||
visible = false
|
||||
|
@ -1441,6 +1447,7 @@ visible = false
|
|||
[connection signal="confirmed" from="NewPaletteDialog" to="MenuAndUI/UI/RightPanel/PreviewAndPalettes/ToolAndPaletteVSplit/PaletteVBoxContainer/ScrollPalette/CenterPalette/PaletteContainer" method="on_new_palette_confirmed"]
|
||||
[connection signal="popup_hide" from="NewPaletteDialog" to="MenuAndUI/UI/RightPanel/PreviewAndPalettes/ToolAndPaletteVSplit/PaletteVBoxContainer/ScrollPalette/CenterPalette/PaletteContainer" method="_on_NewPaletteDialog_popup_hide"]
|
||||
[connection signal="file_selected" from="PaletteImportFileDialog" to="MenuAndUI/UI/RightPanel/PreviewAndPalettes/ToolAndPaletteVSplit/PaletteVBoxContainer/ScrollPalette/CenterPalette/PaletteContainer" method="on_palette_import_file_selected"]
|
||||
[connection signal="popup_hide" from="HSVDialog" to="." method="_can_draw_true"]
|
||||
|
||||
[editable path="BrushesPopup/TabContainer/File/FileBrushContainer/CircleBrushButton"]
|
||||
|
||||
|
|
165
Prefabs/Dialogs/HSVDialog.tscn
Normal file
165
Prefabs/Dialogs/HSVDialog.tscn
Normal file
|
@ -0,0 +1,165 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://Scripts/Dialogs/HSVDialog.gd" type="Script" id=1]
|
||||
|
||||
[node name="HSVDialog" type="WindowDialog"]
|
||||
margin_left = 1.0
|
||||
margin_top = -1.0
|
||||
margin_right = 464.0
|
||||
margin_bottom = 318.0
|
||||
window_title = "Adjust HSV"
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
custom_constants/margin_right = 5
|
||||
custom_constants/margin_top = 5
|
||||
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
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Names" type="VBoxContainer" parent="MarginContainer/VBoxContainer/HBoxContainer"]
|
||||
margin_right = 82.0
|
||||
margin_bottom = 84.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_stretch_ratio = 0.9
|
||||
custom_constants/separation = 8
|
||||
|
||||
[node name="Hue" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer/Names"]
|
||||
margin_right = 82.0
|
||||
margin_bottom = 14.0
|
||||
text = "Hue"
|
||||
align = 2
|
||||
|
||||
[node name="Saturation" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer/Names"]
|
||||
margin_top = 22.0
|
||||
margin_right = 82.0
|
||||
margin_bottom = 36.0
|
||||
text = "Saturation"
|
||||
align = 2
|
||||
|
||||
[node name="Value" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer/Names"]
|
||||
margin_top = 44.0
|
||||
margin_right = 82.0
|
||||
margin_bottom = 58.0
|
||||
text = "Value"
|
||||
align = 2
|
||||
|
||||
[node name="Sliders" type="VBoxContainer" parent="MarginContainer/VBoxContainer/HBoxContainer"]
|
||||
margin_left = 92.0
|
||||
margin_right = 368.0
|
||||
margin_bottom = 84.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_stretch_ratio = 3.0
|
||||
custom_constants/separation = 7
|
||||
|
||||
[node name="Hue" type="HSlider" parent="MarginContainer/VBoxContainer/HBoxContainer/Sliders"]
|
||||
margin_right = 276.0
|
||||
margin_bottom = 16.0
|
||||
mouse_default_cursor_shape = 2
|
||||
min_value = -180.0
|
||||
max_value = 180.0
|
||||
|
||||
[node name="Saturation" type="HSlider" parent="MarginContainer/VBoxContainer/HBoxContainer/Sliders"]
|
||||
margin_top = 23.0
|
||||
margin_right = 276.0
|
||||
margin_bottom = 39.0
|
||||
mouse_default_cursor_shape = 2
|
||||
min_value = -100.0
|
||||
|
||||
[node name="Value" type="HSlider" parent="MarginContainer/VBoxContainer/HBoxContainer/Sliders"]
|
||||
margin_top = 46.0
|
||||
margin_right = 276.0
|
||||
margin_bottom = 62.0
|
||||
mouse_default_cursor_shape = 2
|
||||
min_value = -100.0
|
||||
|
||||
[node name="TextBoxes" type="VBoxContainer" parent="MarginContainer/VBoxContainer/HBoxContainer"]
|
||||
margin_left = 378.0
|
||||
margin_right = 452.0
|
||||
margin_bottom = 84.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_stretch_ratio = 0.0
|
||||
custom_constants/separation = 6
|
||||
|
||||
[node name="Hue" type="SpinBox" parent="MarginContainer/VBoxContainer/HBoxContainer/TextBoxes"]
|
||||
margin_right = 74.0
|
||||
margin_bottom = 24.0
|
||||
mouse_default_cursor_shape = 1
|
||||
min_value = -180.0
|
||||
max_value = 180.0
|
||||
|
||||
[node name="Saturation" type="SpinBox" parent="MarginContainer/VBoxContainer/HBoxContainer/TextBoxes"]
|
||||
margin_top = 30.0
|
||||
margin_right = 74.0
|
||||
margin_bottom = 54.0
|
||||
mouse_default_cursor_shape = 1
|
||||
min_value = -100.0
|
||||
|
||||
[node name="Value" type="SpinBox" parent="MarginContainer/VBoxContainer/HBoxContainer/TextBoxes"]
|
||||
margin_top = 60.0
|
||||
margin_right = 74.0
|
||||
margin_bottom = 84.0
|
||||
mouse_default_cursor_shape = 1
|
||||
min_value = -100.0
|
||||
|
||||
[node name="HBoxContainer2" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
|
||||
margin_top = 289.0
|
||||
margin_right = 453.0
|
||||
margin_bottom = 309.0
|
||||
custom_constants/separation = 16
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Apply" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer2"]
|
||||
margin_right = 218.0
|
||||
margin_bottom = 20.0
|
||||
mouse_default_cursor_shape = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Apply"
|
||||
|
||||
[node name="Cancel" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer2"]
|
||||
margin_left = 234.0
|
||||
margin_right = 453.0
|
||||
margin_bottom = 20.0
|
||||
mouse_default_cursor_shape = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Cancel"
|
||||
[connection signal="about_to_show" from="." to="." method="_on_HSVDialog_about_to_show"]
|
||||
[connection signal="value_changed" from="MarginContainer/VBoxContainer/HBoxContainer/Sliders/Hue" to="." method="_on_Hue_value_changed"]
|
||||
[connection signal="value_changed" from="MarginContainer/VBoxContainer/HBoxContainer/Sliders/Saturation" to="." method="_on_Saturation_value_changed"]
|
||||
[connection signal="value_changed" from="MarginContainer/VBoxContainer/HBoxContainer/Sliders/Value" to="." method="_on_Value_value_changed"]
|
||||
[connection signal="value_changed" from="MarginContainer/VBoxContainer/HBoxContainer/TextBoxes/Hue" to="." method="_on_Hue_value_changed"]
|
||||
[connection signal="value_changed" from="MarginContainer/VBoxContainer/HBoxContainer/TextBoxes/Saturation" to="." method="_on_Saturation_value_changed"]
|
||||
[connection signal="value_changed" from="MarginContainer/VBoxContainer/HBoxContainer/TextBoxes/Value" to="." method="_on_Value_value_changed"]
|
||||
[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer2/Apply" to="." method="_on_Apply_pressed"]
|
||||
[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer2/Cancel" to="." method="_on_Cancel_pressed"]
|
|
@ -1010,3 +1010,85 @@ func blend_rect(bg : Image, brush : Image, src_rect : Rect2, dst : Vector2) -> v
|
|||
if out_color.a != 0:
|
||||
bg.set_pixel(dst_x, dst_y, out_color)
|
||||
brush.unlock()
|
||||
|
||||
func adjust_hsv(img: Image, id : int, delta : float)->void:
|
||||
var selection_only:bool = !Global.selected_pixels.empty()
|
||||
var layer:Image = img
|
||||
layer.lock()
|
||||
match id:
|
||||
#Hue
|
||||
0:
|
||||
for i in range(layer.get_width()):
|
||||
for j in range(layer.get_height()):
|
||||
if(selection_only and Global.selected_pixels.has(Vector2(i,j))):
|
||||
var c: Color = layer.get_pixel(i,j)
|
||||
var hue = range_lerp(c.h,0,1,-180,180)
|
||||
hue = hue + delta
|
||||
|
||||
while(hue >= 180):
|
||||
hue -= 360
|
||||
while(hue < -180):
|
||||
hue += 360
|
||||
c.h = range_lerp(hue,-180,180,0,1)
|
||||
layer.set_pixel(i,j,c)
|
||||
elif(!selection_only):
|
||||
var c: Color = layer.get_pixel(i,j)
|
||||
var hue = range_lerp(c.h,0,1,-180,180)
|
||||
hue = hue + delta
|
||||
|
||||
while(hue >= 180):
|
||||
hue -= 360
|
||||
while(hue < -180):
|
||||
hue += 360
|
||||
c.h = range_lerp(hue,-180,180,0,1)
|
||||
layer.set_pixel(i,j,c)
|
||||
|
||||
#Saturation
|
||||
1:
|
||||
for i in range(layer.get_width()):
|
||||
for j in range(layer.get_height()):
|
||||
if(selection_only and Global.selected_pixels.has(Vector2(i,j))):
|
||||
var c: Color = layer.get_pixel(i,j)
|
||||
var sat = c.s
|
||||
if delta > 0:
|
||||
sat = range_lerp(delta,0,100,c.s,1)
|
||||
elif delta < 0:
|
||||
sat = range_lerp(delta,-100,0,0,c.s)
|
||||
c.s = sat
|
||||
layer.set_pixel(i,j,c)
|
||||
elif(!selection_only):
|
||||
var c: Color = layer.get_pixel(i,j)
|
||||
var sat = c.s
|
||||
if delta > 0:
|
||||
sat = range_lerp(delta,0,100,c.s,1)
|
||||
elif delta < 0:
|
||||
sat = range_lerp(delta,-100,0,0,c.s)
|
||||
c.s = sat
|
||||
layer.set_pixel(i,j,c)
|
||||
|
||||
#value
|
||||
2:
|
||||
for i in range(layer.get_width()):
|
||||
for j in range(layer.get_height()):
|
||||
if(selection_only and Global.selected_pixels.has(Vector2(i,j))):
|
||||
var c: Color = layer.get_pixel(i,j)
|
||||
var val = c.v
|
||||
if delta > 0:
|
||||
val = range_lerp(delta,0,100,c.v,1)
|
||||
elif delta < 0:
|
||||
val = range_lerp(delta,-100,0,0,c.v)
|
||||
|
||||
c.v = val
|
||||
layer.set_pixel(i,j,c)
|
||||
elif(!selection_only):
|
||||
var c: Color = layer.get_pixel(i,j)
|
||||
var val = c.v
|
||||
if delta > 0:
|
||||
val = range_lerp(delta,0,100,c.v,1)
|
||||
elif delta < 0:
|
||||
val = range_lerp(delta,-100,0,0,c.v)
|
||||
|
||||
c.v = val
|
||||
layer.set_pixel(i,j,c)
|
||||
layer.unlock()
|
||||
pass
|
||||
|
|
96
Scripts/Dialogs/HSVDialog.gd
Normal file
96
Scripts/Dialogs/HSVDialog.gd
Normal file
|
@ -0,0 +1,96 @@
|
|||
extends WindowDialog
|
||||
|
||||
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 = $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 preview = $MarginContainer/VBoxContainer/TextureRect
|
||||
|
||||
var current_layer:Image
|
||||
var preview_image:Image
|
||||
var preview_texture:ImageTexture
|
||||
|
||||
func _ready():
|
||||
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():
|
||||
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() -> void:
|
||||
disconnect_signals()
|
||||
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() -> void:
|
||||
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() -> void:
|
||||
hue_slider.disconnect("value_changed",self,"_on_Hue_value_changed")
|
||||
sat_slider.disconnect("value_changed",self,"_on_Saturation_value_changed")
|
||||
val_slider.disconnect("value_changed",self,"_on_Value_value_changed")
|
||||
hue_spinbox.disconnect("value_changed",self,"_on_Hue_value_changed")
|
||||
sat_spinbox.disconnect("value_changed",self,"_on_Saturation_value_changed")
|
||||
val_spinbox.disconnect("value_changed",self,"_on_Value_value_changed")
|
||||
|
||||
func reconnect_signals() -> void:
|
||||
hue_slider.connect("value_changed",self,"_on_Hue_value_changed")
|
||||
sat_slider.connect("value_changed",self,"_on_Saturation_value_changed")
|
||||
val_slider.connect("value_changed",self,"_on_Value_value_changed")
|
||||
hue_spinbox.connect("value_changed",self,"_on_Hue_value_changed")
|
||||
sat_spinbox.connect("value_changed",self,"_on_Saturation_value_changed")
|
||||
val_spinbox.connect("value_changed",self,"_on_Value_value_changed")
|
||||
|
||||
func _on_Hue_value_changed(value):
|
||||
hue_spinbox.value = value
|
||||
hue_slider.value = value
|
||||
update_preview()
|
||||
|
||||
func _on_Saturation_value_changed(value):
|
||||
sat_spinbox.value = value
|
||||
sat_slider.value = value
|
||||
update_preview()
|
||||
|
||||
func _on_Value_value_changed(value):
|
||||
val_spinbox.value = value
|
||||
val_slider.value = value
|
||||
update_preview()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -70,7 +70,8 @@ func _ready() -> void:
|
|||
"Rotate Image" : 0,
|
||||
"Invert colors" : 0,
|
||||
"Desaturation" : 0,
|
||||
"Outline" : 0
|
||||
"Outline" : 0,
|
||||
"Adjust Hue/Saturation/Value":0
|
||||
}
|
||||
var help_menu_items := {
|
||||
"View Splash Screen" : 0,
|
||||
|
@ -387,6 +388,9 @@ func image_menu_id_pressed(id : int) -> void:
|
|||
7: # Outline
|
||||
$OutlineDialog.popup_centered()
|
||||
Global.can_draw = false
|
||||
8: # HSV
|
||||
$HSVDialog.popup_centered()
|
||||
Global.can_draw = false
|
||||
|
||||
func help_menu_id_pressed(id : int) -> void:
|
||||
match id:
|
||||
|
|
|
@ -320,6 +320,9 @@ msgstr ""
|
|||
msgid "Outline"
|
||||
msgstr ""
|
||||
|
||||
msgid "Adjust Hue/Saturation/Value"
|
||||
msgstr ""
|
||||
|
||||
msgid "Diagonal"
|
||||
msgstr ""
|
||||
|
||||
|
|
Loading…
Reference in a new issue