Moved Rotate Image selection up, fixed some warnings

And minor UI changes, like changing default cursor shape to pointing hand when hovering on some UI elements in RotateImage.tscn
This commit is contained in:
OverloadedOrama 2020-02-04 18:29:34 +02:00
parent c4229e1759
commit 155b77b514
5 changed files with 48 additions and 53 deletions

View file

@ -1402,18 +1402,17 @@ columns = 5
[node name="SplashDialog" parent="." instance=ExtResource( 43 )] [node name="SplashDialog" parent="." instance=ExtResource( 43 )]
[node name="CreateNewImage" parent="." instance=ExtResource( 44 )] [node name="CreateNewImage" parent="." instance=ExtResource( 44 )]
window_title = "Confirmá, por favor..."
[node name="OpenSprite" type="FileDialog" parent="."] [node name="OpenSprite" type="FileDialog" parent="."]
margin_right = 515.0 margin_right = 515.0
margin_bottom = 348.0 margin_bottom = 348.0
window_title = "Abrir un Archivo" window_title = "Open a File"
resizable = true resizable = true
mode = 0 mode = 0
access = 2 access = 2
filters = PoolStringArray( "*.pxo ; Pixelorama Project" ) filters = PoolStringArray( "*.pxo ; Pixelorama Project" )
current_dir = "/home/azagaya/Documentos/VJ/Pixelorama" current_dir = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama"
current_path = "/home/azagaya/Documentos/VJ/Pixelorama/" current_path = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama/"
[node name="SaveSprite" type="FileDialog" parent="."] [node name="SaveSprite" type="FileDialog" parent="."]
anchor_left = 0.5 anchor_left = 0.5
@ -1428,32 +1427,29 @@ window_title = "Save Sprite as .pxo"
resizable = true resizable = true
access = 2 access = 2
filters = PoolStringArray( "*.pxo ; Pixelorama Project" ) filters = PoolStringArray( "*.pxo ; Pixelorama Project" )
current_dir = "/home/azagaya/Documentos/VJ/Pixelorama" current_dir = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama"
current_path = "/home/azagaya/Documentos/VJ/Pixelorama/" current_path = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama/"
[node name="ImportSprites" parent="." instance=ExtResource( 45 )] [node name="ImportSprites" parent="." instance=ExtResource( 45 )]
window_title = "Abrir Archivo(s)"
current_dir = "/home/azagaya/Documentos/VJ/Pixelorama"
current_path = "/home/azagaya/Documentos/VJ/Pixelorama/"
[node name="ExportSprites" parent="." instance=ExtResource( 46 )] [node name="ExportSprites" parent="." instance=ExtResource( 46 )]
current_dir = "/home/azagaya/Documentos/VJ/Pixelorama"
current_path = "/home/azagaya/Documentos/VJ/Pixelorama/"
[node name="ScaleImage" parent="." instance=ExtResource( 47 )] [node name="ScaleImage" parent="." instance=ExtResource( 47 )]
resizable = true
[node name="PreferencesDialog" parent="." instance=ExtResource( 48 )] [node name="PreferencesDialog" parent="." instance=ExtResource( 48 )]
[node name="RotateImage" parent="." instance=ExtResource( 54 )]
[node name="OutlineDialog" parent="." instance=ExtResource( 49 )] [node name="OutlineDialog" parent="." instance=ExtResource( 49 )]
visible = false visible = false
window_title = "Confirmá, por favor..." resizable = true
[node name="AboutDialog" parent="." instance=ExtResource( 50 )] [node name="AboutDialog" parent="." instance=ExtResource( 50 )]
[node name="QuitDialog" type="ConfirmationDialog" parent="."] [node name="QuitDialog" type="ConfirmationDialog" parent="."]
margin_right = 200.0 margin_right = 200.0
margin_bottom = 70.0 margin_bottom = 70.0
window_title = "Confirmá, por favor..."
resizable = true resizable = true
dialog_text = "QUIT_LABEL" dialog_text = "QUIT_LABEL"
@ -1469,19 +1465,15 @@ visible = false
[node name="NewPaletteDialog" parent="." instance=ExtResource( 52 )] [node name="NewPaletteDialog" parent="." instance=ExtResource( 52 )]
[node name="PaletteImportFileDialog" parent="." instance=ExtResource( 53 )] [node name="PaletteImportFileDialog" parent="." instance=ExtResource( 53 )]
window_title = "Abrir un Archivo"
filters = PoolStringArray( "*.json ; JavaScript Object Notation", "*.gpl ; Gimp Palette Library" ) filters = PoolStringArray( "*.json ; JavaScript Object Notation", "*.gpl ; Gimp Palette Library" )
current_dir = "/home/azagaya/Documentos/VJ/Pixelorama" current_dir = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama"
current_path = "/home/azagaya/Documentos/VJ/Pixelorama/" current_path = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama/"
[node name="LeftCursor" type="Sprite" parent="."] [node name="LeftCursor" type="Sprite" parent="."]
visible = false visible = false
[node name="RightCursor" type="Sprite" parent="."] [node name="RightCursor" type="Sprite" parent="."]
visible = false visible = false
[node name="RotateImage" parent="." instance=ExtResource( 54 )]
visible = false
[connection signal="pressed" from="MenuAndUI/UI/ToolPanel/Tools/ColorAndToolOptions/ColorButtonsVertical/ColorSwitchCenter/ColorSwitch" to="." method="_on_ColorSwitch_pressed"] [connection signal="pressed" from="MenuAndUI/UI/ToolPanel/Tools/ColorAndToolOptions/ColorButtonsVertical/ColorSwitchCenter/ColorSwitch" to="." method="_on_ColorSwitch_pressed"]
[connection signal="color_changed" from="MenuAndUI/UI/ToolPanel/Tools/ColorAndToolOptions/ColorButtonsVertical/ColorPickersCenter/ColorPickersHorizontal/LeftColorPickerButton" to="." method="_on_LeftColorPickerButton_color_changed"] [connection signal="color_changed" from="MenuAndUI/UI/ToolPanel/Tools/ColorAndToolOptions/ColorButtonsVertical/ColorPickersCenter/ColorPickersHorizontal/LeftColorPickerButton" to="." method="_on_LeftColorPickerButton_color_changed"]
[connection signal="popup_closed" from="MenuAndUI/UI/ToolPanel/Tools/ColorAndToolOptions/ColorButtonsVertical/ColorPickersCenter/ColorPickersHorizontal/LeftColorPickerButton" to="." method="_can_draw_true"] [connection signal="popup_closed" from="MenuAndUI/UI/ToolPanel/Tools/ColorAndToolOptions/ColorButtonsVertical/ColorPickersCenter/ColorPickersHorizontal/LeftColorPickerButton" to="." method="_can_draw_true"]

View file

@ -18,12 +18,12 @@ func set_sprite(sprite : Image):
$VBoxContainer/TextureRect.texture = texture $VBoxContainer/TextureRect.texture = texture
func _on_HSlider_value_changed(value): func _on_HSlider_value_changed(_value):
rotate() rotate()
$VBoxContainer/HBoxContainer/SpinBox.value = $VBoxContainer/HBoxContainer/HSlider.value $VBoxContainer/HBoxContainer/SpinBox.value = $VBoxContainer/HBoxContainer/HSlider.value
func _on_SpinBox_value_changed(value): func _on_SpinBox_value_changed(_value):
$VBoxContainer/HBoxContainer/HSlider.value = $VBoxContainer/HBoxContainer/SpinBox.value $VBoxContainer/HBoxContainer/HSlider.value = $VBoxContainer/HBoxContainer/SpinBox.value
@ -36,7 +36,7 @@ func _on_RotateImage_confirmed():
Global.nn_rotate(layer,$VBoxContainer/HBoxContainer/HSlider.value*PI/180) Global.nn_rotate(layer,$VBoxContainer/HBoxContainer/HSlider.value*PI/180)
Global.canvas.handle_redo("Draw") Global.canvas.handle_redo("Draw")
$VBoxContainer/HBoxContainer/HSlider.value = 0 $VBoxContainer/HBoxContainer/HSlider.value = 0
func rotate(): func rotate():
var sprite : Image = Image.new() var sprite : Image = Image.new()
sprite.copy_from(aux_img) sprite.copy_from(aux_img)
@ -48,7 +48,7 @@ func rotate():
texture.create_from_image(sprite, 0) texture.create_from_image(sprite, 0)
func _on_OptionButton_item_selected(id): func _on_OptionButton_item_selected(_id):
rotate() rotate()

View file

@ -5,7 +5,7 @@
[node name="RotateImage" type="ConfirmationDialog"] [node name="RotateImage" type="ConfirmationDialog"]
margin_right = 245.0 margin_right = 245.0
margin_bottom = 241.0 margin_bottom = 241.0
window_title = "Confirmá, por favor..." resizable = true
script = ExtResource( 1 ) script = ExtResource( 1 )
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
@ -44,6 +44,7 @@ text = "Type:"
margin_left = 38.0 margin_left = 38.0
margin_right = 229.0 margin_right = 229.0
margin_bottom = 20.0 margin_bottom = 20.0
mouse_default_cursor_shape = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
size_flags_vertical = 3 size_flags_vertical = 3
@ -62,6 +63,7 @@ text = "Angle: "
margin_left = 48.0 margin_left = 48.0
margin_right = 151.0 margin_right = 151.0
margin_bottom = 24.0 margin_bottom = 24.0
mouse_default_cursor_shape = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
size_flags_vertical = 3 size_flags_vertical = 3
max_value = 359.0 max_value = 359.0
@ -73,6 +75,7 @@ __meta__ = {
margin_left = 155.0 margin_left = 155.0
margin_right = 229.0 margin_right = 229.0
margin_bottom = 24.0 margin_bottom = 24.0
mouse_default_cursor_shape = 2
max_value = 359.0 max_value = 359.0
[connection signal="about_to_show" from="." to="." method="_on_RotateImage_about_to_show"] [connection signal="about_to_show" from="." to="." method="_on_RotateImage_about_to_show"]
[connection signal="confirmed" from="." to="." method="_on_RotateImage_confirmed"] [connection signal="confirmed" from="." to="." method="_on_RotateImage_confirmed"]

View file

@ -652,7 +652,7 @@ func scale3X(sprite : Image, tol : float = 50) -> Image:
var ei : bool = similarColors(e, i, tol) var ei : bool = similarColors(e, i, tol)
scaled.set_pixel(xs-1, ys-1, d if (db and !dh and !bf) else e ) scaled.set_pixel(xs-1, ys-1, d if (db and !dh and !bf) else e )
scaled.set_pixel(xs, ys-1, b if (db and !dh and !bf and !ec) or scaled.set_pixel(xs, ys-1, b if (db and !dh and !bf and !ec) or
(bf and !db and !fh and !ea) else e) (bf and !db and !fh and !ea) else e)
scaled.set_pixel(xs+1, ys-1, f if (bf and !db and !fh) else e) scaled.set_pixel(xs+1, ys-1, f if (bf and !db and !fh) else e)
scaled.set_pixel(xs-1, ys, d if (dh and !fh and !db and !ea) or scaled.set_pixel(xs-1, ys, d if (dh and !fh and !db and !ea) or
@ -670,13 +670,13 @@ func scale3X(sprite : Image, tol : float = 50) -> Image:
return scaled return scaled
func rotxel(sprite : Image, angle : float): func rotxel(sprite : Image, angle : float):
# If angle is simple, then nn rotation is the best # If angle is simple, then nn rotation is the best
if angle == 0 || angle == PI/2 || angle == PI || angle == 2*PI: if angle == 0 || angle == PI/2 || angle == PI || angle == 2*PI:
nn_rotate(sprite, angle) nn_rotate(sprite, angle)
return return
var aux : Image = Image.new() var aux : Image = Image.new()
aux.copy_from(sprite) aux.copy_from(sprite)
var center : Vector2 = Vector2(sprite.get_width()/2, sprite.get_height()/2) var center : Vector2 = Vector2(sprite.get_width()/2, sprite.get_height()/2)
@ -698,24 +698,24 @@ func rotxel(sprite : Image, angle : float):
dir -= angle dir -= angle
ox = round(center.x*3 + 1 + mag*cos(dir)) ox = round(center.x*3 + 1 + mag*cos(dir))
oy = round(center.y*3 + 1 + mag*sin(dir)) oy = round(center.y*3 + 1 + mag*sin(dir))
if (sprite.get_width() % 2 != 0): if (sprite.get_width() % 2 != 0):
ox += 1 ox += 1
oy += 1 oy += 1
if (ox >= 0 && ox < sprite.get_width()*3 if (ox >= 0 && ox < sprite.get_width()*3
&& oy >= 0 && oy < sprite.get_height()*3): && oy >= 0 && oy < sprite.get_height()*3):
found_pixel = true found_pixel = true
break break
if !found_pixel: if !found_pixel:
sprite.set_pixel(x, y, Color(0,0,0,0)) sprite.set_pixel(x, y, Color(0,0,0,0))
continue continue
var fil : int = oy % 3 var fil : int = oy % 3
var col : int = ox % 3 var col : int = ox % 3
var index : int = col + 3*fil var index : int = col + 3*fil
ox = round((ox - 1)/3.0); ox = round((ox - 1)/3.0);
oy = round((oy - 1)/3.0); oy = round((oy - 1)/3.0);
var a : Color var a : Color
@ -727,7 +727,7 @@ func rotxel(sprite : Image, angle : float):
var g : Color var g : Color
var h : Color var h : Color
var i : Color var i : Color
if (ox == 0 || ox == sprite.get_width() - 1 || if (ox == 0 || ox == sprite.get_width() - 1 ||
oy == 0 || oy == sprite.get_height() - 1): oy == 0 || oy == sprite.get_height() - 1):
p = aux.get_pixel(ox, oy) p = aux.get_pixel(ox, oy)
else: else:
@ -740,7 +740,7 @@ func rotxel(sprite : Image, angle : float):
g = aux.get_pixel(ox-1,oy+1); g = aux.get_pixel(ox-1,oy+1);
h = aux.get_pixel(ox,oy+1); h = aux.get_pixel(ox,oy+1);
i = aux.get_pixel(ox+1,oy+1); i = aux.get_pixel(ox+1,oy+1);
match(index): match(index):
0: 0:
p = d if (similarColors(d,b) && !similarColors(d,h) p = d if (similarColors(d,b) && !similarColors(d,h)
@ -748,7 +748,7 @@ func rotxel(sprite : Image, angle : float):
1: 1:
p = b if ((similarColors(d,b) && !similarColors(d,h) && p = b if ((similarColors(d,b) && !similarColors(d,h) &&
!similarColors(b,f) && !similarColors(e,c)) || !similarColors(b,f) && !similarColors(e,c)) ||
(similarColors(b,f) && !similarColors(d,b) && (similarColors(b,f) && !similarColors(d,b) &&
!similarColors(f,h) && !similarColors(e,a))) else e; !similarColors(f,h) && !similarColors(e,a))) else e;
2: 2:
p = f if (similarColors(b,f) && !similarColors(d,b) && p = f if (similarColors(b,f) && !similarColors(d,b) &&
@ -756,17 +756,17 @@ func rotxel(sprite : Image, angle : float):
3: 3:
p = d if ((similarColors(d,h) && !similarColors(f,h) && p = d if ((similarColors(d,h) && !similarColors(f,h) &&
!similarColors(d,b) && !similarColors(e,a)) || !similarColors(d,b) && !similarColors(e,a)) ||
(similarColors(d,b) && !similarColors(d,h) && (similarColors(d,b) && !similarColors(d,h) &&
!similarColors(b,f) && !similarColors(e,g))) else e; !similarColors(b,f) && !similarColors(e,g))) else e;
4: 4:
p = e p = e
5: 5:
p = f if((similarColors(b,f) && !similarColors(d,b) && p = f if((similarColors(b,f) && !similarColors(d,b) &&
!similarColors(f,h) && !similarColors(e,i)) !similarColors(f,h) && !similarColors(e,i))
|| (similarColors(f,h) && !similarColors(b,f) && || (similarColors(f,h) && !similarColors(b,f) &&
!similarColors(d,h) && !similarColors(e,c))) else e; !similarColors(d,h) && !similarColors(e,c))) else e;
6: 6:
p = d if (similarColors(d,h) && !similarColors(f,h) && p = d if (similarColors(d,h) && !similarColors(f,h) &&
!similarColors(d,b)) else e; !similarColors(d,b)) else e;
7: 7:
p = h if ((similarColors(f,h) && !similarColors(f,b) && p = h if ((similarColors(f,h) && !similarColors(f,b) &&
@ -779,7 +779,7 @@ func rotxel(sprite : Image, angle : float):
sprite.set_pixel(x, y, p) sprite.set_pixel(x, y, p)
sprite.unlock() sprite.unlock()
aux.unlock() aux.unlock()
func nn_rotate(sprite : Image, angle : float): func nn_rotate(sprite : Image, angle : float):
var aux : Image = Image.new() var aux : Image = Image.new()
aux.copy_from(sprite) aux.copy_from(sprite)
@ -798,9 +798,9 @@ func nn_rotate(sprite : Image, angle : float):
sprite.set_pixel(x, y, Color(0,0,0,0)) sprite.set_pixel(x, y, Color(0,0,0,0))
sprite.unlock() sprite.unlock()
aux.unlock() aux.unlock()
func similarColors(c1 : Color, c2 : Color, tol : float = 100) -> bool: func similarColors(c1 : Color, c2 : Color, tol : float = 100) -> bool:
var dist = colorDistance(c1, c2) var dist = colorDistance(c1, c2)
return dist <= tol return dist <= tol
func colorDistance(c1 : Color, c2 : Color) -> float: func colorDistance(c1 : Color, c2 : Color) -> float:

View file

@ -67,10 +67,10 @@ func _ready() -> void:
"Crop Image" : 0, "Crop Image" : 0,
"Flip Horizontal" : KEY_MASK_SHIFT + KEY_H, "Flip Horizontal" : KEY_MASK_SHIFT + KEY_H,
"Flip Vertical" : KEY_MASK_SHIFT + KEY_V, "Flip Vertical" : KEY_MASK_SHIFT + KEY_V,
"Rotate Image" : 0,
"Invert colors" : 0, "Invert colors" : 0,
"Desaturation" : 0, "Desaturation" : 0,
"Outline" : 0, "Outline" : 0
"Rotate Image" : 0
} }
var help_menu_items := { var help_menu_items := {
"View Splash Screen" : 0, "View Splash Screen" : 0,
@ -121,7 +121,7 @@ func _ready() -> void:
i = 0 i = 0
for item in image_menu_items.keys(): for item in image_menu_items.keys():
image_menu.add_item(item, i, image_menu_items[item]) image_menu.add_item(item, i, image_menu_items[item])
if i == 3: if i == 4:
image_menu.add_separator() image_menu.add_separator()
i += 1 i += 1
i = 0 i = 0
@ -323,7 +323,11 @@ func image_menu_id_pressed(id : int) -> void:
canvas.layers[canvas.current_layer_index][0].flip_y() canvas.layers[canvas.current_layer_index][0].flip_y()
canvas.layers[canvas.current_layer_index][0].lock() canvas.layers[canvas.current_layer_index][0].lock()
canvas.handle_redo("Draw") canvas.handle_redo("Draw")
4: # Invert Colors 4: # Rotate
var image : Image = Global.canvas.layers[Global.canvas.current_layer_index][0]
$RotateImage.set_sprite(image)
$RotateImage.popup_centered()
5: # Invert Colors
var image : Image = Global.canvas.layers[Global.canvas.current_layer_index][0] var image : Image = Global.canvas.layers[Global.canvas.current_layer_index][0]
Global.canvas.handle_undo("Draw") Global.canvas.handle_undo("Draw")
for xx in image.get_size().x: for xx in image.get_size().x:
@ -333,7 +337,7 @@ func image_menu_id_pressed(id : int) -> void:
continue continue
image.set_pixel(xx, yy, px_color) image.set_pixel(xx, yy, px_color)
Global.canvas.handle_redo("Draw") Global.canvas.handle_redo("Draw")
5: # Desaturation 6: # Desaturation
var image : Image = Global.canvas.layers[Global.canvas.current_layer_index][0] var image : Image = Global.canvas.layers[Global.canvas.current_layer_index][0]
Global.canvas.handle_undo("Draw") Global.canvas.handle_undo("Draw")
for xx in image.get_size().x: for xx in image.get_size().x:
@ -345,12 +349,8 @@ func image_menu_id_pressed(id : int) -> void:
px_color = Color(gray, gray, gray, px_color.a) px_color = Color(gray, gray, gray, px_color.a)
image.set_pixel(xx, yy, px_color) image.set_pixel(xx, yy, px_color)
Global.canvas.handle_redo("Draw") Global.canvas.handle_redo("Draw")
6: # Outline 7: # Outline
$OutlineDialog.popup_centered() $OutlineDialog.popup_centered()
7: # Rotate
var image : Image = Global.canvas.layers[Global.canvas.current_layer_index][0]
$RotateImage.set_sprite(image)
$RotateImage.popup_centered()
func help_menu_id_pressed(id : int) -> void: func help_menu_id_pressed(id : int) -> void:
match id: match id: