diff --git a/Main.tscn b/Main.tscn index 0d3b4a01b..e24945674 100644 --- a/Main.tscn +++ b/Main.tscn @@ -1402,18 +1402,17 @@ columns = 5 [node name="SplashDialog" parent="." instance=ExtResource( 43 )] [node name="CreateNewImage" parent="." instance=ExtResource( 44 )] -window_title = "Confirmá, por favor..." [node name="OpenSprite" type="FileDialog" parent="."] margin_right = 515.0 margin_bottom = 348.0 -window_title = "Abrir un Archivo" +window_title = "Open a File" resizable = true mode = 0 access = 2 filters = PoolStringArray( "*.pxo ; Pixelorama Project" ) -current_dir = "/home/azagaya/Documentos/VJ/Pixelorama" -current_path = "/home/azagaya/Documentos/VJ/Pixelorama/" +current_dir = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama" +current_path = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama/" [node name="SaveSprite" type="FileDialog" parent="."] anchor_left = 0.5 @@ -1428,32 +1427,29 @@ window_title = "Save Sprite as .pxo" resizable = true access = 2 filters = PoolStringArray( "*.pxo ; Pixelorama Project" ) -current_dir = "/home/azagaya/Documentos/VJ/Pixelorama" -current_path = "/home/azagaya/Documentos/VJ/Pixelorama/" +current_dir = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama" +current_path = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama/" [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 )] -current_dir = "/home/azagaya/Documentos/VJ/Pixelorama" -current_path = "/home/azagaya/Documentos/VJ/Pixelorama/" [node name="ScaleImage" parent="." instance=ExtResource( 47 )] +resizable = true [node name="PreferencesDialog" parent="." instance=ExtResource( 48 )] +[node name="RotateImage" parent="." instance=ExtResource( 54 )] + [node name="OutlineDialog" parent="." instance=ExtResource( 49 )] visible = false -window_title = "Confirmá, por favor..." +resizable = true [node name="AboutDialog" parent="." instance=ExtResource( 50 )] [node name="QuitDialog" type="ConfirmationDialog" parent="."] margin_right = 200.0 margin_bottom = 70.0 -window_title = "Confirmá, por favor..." resizable = true dialog_text = "QUIT_LABEL" @@ -1469,19 +1465,15 @@ visible = false [node name="NewPaletteDialog" parent="." instance=ExtResource( 52 )] [node name="PaletteImportFileDialog" parent="." instance=ExtResource( 53 )] -window_title = "Abrir un Archivo" filters = PoolStringArray( "*.json ; JavaScript Object Notation", "*.gpl ; Gimp Palette Library" ) -current_dir = "/home/azagaya/Documentos/VJ/Pixelorama" -current_path = "/home/azagaya/Documentos/VJ/Pixelorama/" +current_dir = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama" +current_path = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama/" [node name="LeftCursor" type="Sprite" parent="."] visible = false [node name="RightCursor" type="Sprite" parent="."] 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="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"] diff --git a/Prefabs/Dialogs/RotateImage.gd b/Prefabs/Dialogs/RotateImage.gd index 506f3d680..c0be7096d 100644 --- a/Prefabs/Dialogs/RotateImage.gd +++ b/Prefabs/Dialogs/RotateImage.gd @@ -18,12 +18,12 @@ func set_sprite(sprite : Image): $VBoxContainer/TextureRect.texture = texture -func _on_HSlider_value_changed(value): +func _on_HSlider_value_changed(_value): rotate() $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 @@ -36,7 +36,7 @@ func _on_RotateImage_confirmed(): Global.nn_rotate(layer,$VBoxContainer/HBoxContainer/HSlider.value*PI/180) Global.canvas.handle_redo("Draw") $VBoxContainer/HBoxContainer/HSlider.value = 0 - + func rotate(): var sprite : Image = Image.new() sprite.copy_from(aux_img) @@ -48,7 +48,7 @@ func rotate(): texture.create_from_image(sprite, 0) -func _on_OptionButton_item_selected(id): +func _on_OptionButton_item_selected(_id): rotate() diff --git a/Prefabs/Dialogs/RotateImage.tscn b/Prefabs/Dialogs/RotateImage.tscn index 12302e362..6a05cd144 100644 --- a/Prefabs/Dialogs/RotateImage.tscn +++ b/Prefabs/Dialogs/RotateImage.tscn @@ -5,7 +5,7 @@ [node name="RotateImage" type="ConfirmationDialog"] margin_right = 245.0 margin_bottom = 241.0 -window_title = "Confirmá, por favor..." +resizable = true script = ExtResource( 1 ) __meta__ = { "_edit_use_anchors_": false @@ -44,6 +44,7 @@ text = "Type:" margin_left = 38.0 margin_right = 229.0 margin_bottom = 20.0 +mouse_default_cursor_shape = 2 size_flags_horizontal = 3 size_flags_vertical = 3 @@ -62,6 +63,7 @@ text = "Angle: " margin_left = 48.0 margin_right = 151.0 margin_bottom = 24.0 +mouse_default_cursor_shape = 2 size_flags_horizontal = 3 size_flags_vertical = 3 max_value = 359.0 @@ -73,6 +75,7 @@ __meta__ = { margin_left = 155.0 margin_right = 229.0 margin_bottom = 24.0 +mouse_default_cursor_shape = 2 max_value = 359.0 [connection signal="about_to_show" from="." to="." method="_on_RotateImage_about_to_show"] [connection signal="confirmed" from="." to="." method="_on_RotateImage_confirmed"] diff --git a/Scripts/Global.gd b/Scripts/Global.gd index 51e09bb14..69857c2cb 100644 --- a/Scripts/Global.gd +++ b/Scripts/Global.gd @@ -652,7 +652,7 @@ func scale3X(sprite : Image, tol : float = 50) -> Image: 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, 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) 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 @@ -670,13 +670,13 @@ func scale3X(sprite : Image, tol : float = 50) -> Image: return scaled func rotxel(sprite : Image, angle : float): - + # If angle is simple, then nn rotation is the best - + if angle == 0 || angle == PI/2 || angle == PI || angle == 2*PI: nn_rotate(sprite, angle) return - + var aux : Image = Image.new() aux.copy_from(sprite) var center : Vector2 = Vector2(sprite.get_width()/2, sprite.get_height()/2) @@ -698,24 +698,24 @@ func rotxel(sprite : Image, angle : float): dir -= angle ox = round(center.x*3 + 1 + mag*cos(dir)) oy = round(center.y*3 + 1 + mag*sin(dir)) - + if (sprite.get_width() % 2 != 0): ox += 1 oy += 1 - + if (ox >= 0 && ox < sprite.get_width()*3 && oy >= 0 && oy < sprite.get_height()*3): found_pixel = true break - + if !found_pixel: sprite.set_pixel(x, y, Color(0,0,0,0)) continue - + var fil : int = oy % 3 var col : int = ox % 3 var index : int = col + 3*fil - + ox = round((ox - 1)/3.0); oy = round((oy - 1)/3.0); var a : Color @@ -727,7 +727,7 @@ func rotxel(sprite : Image, angle : float): var g : Color var h : 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): p = aux.get_pixel(ox, oy) else: @@ -740,7 +740,7 @@ func rotxel(sprite : Image, angle : float): g = aux.get_pixel(ox-1,oy+1); h = aux.get_pixel(ox,oy+1); i = aux.get_pixel(ox+1,oy+1); - + match(index): 0: p = d if (similarColors(d,b) && !similarColors(d,h) @@ -748,7 +748,7 @@ func rotxel(sprite : Image, angle : float): 1: p = b if ((similarColors(d,b) && !similarColors(d,h) && !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; 2: p = f if (similarColors(b,f) && !similarColors(d,b) && @@ -756,17 +756,17 @@ func rotxel(sprite : Image, angle : float): 3: p = d if ((similarColors(d,h) && !similarColors(f,h) && !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; - 4: + 4: p = e 5: p = f if((similarColors(b,f) && !similarColors(d,b) && !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; 6: - p = d if (similarColors(d,h) && !similarColors(f,h) && + p = d if (similarColors(d,h) && !similarColors(f,h) && !similarColors(d,b)) else e; 7: 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.unlock() aux.unlock() - + func nn_rotate(sprite : Image, angle : float): var aux : Image = Image.new() 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.unlock() aux.unlock() - + func similarColors(c1 : Color, c2 : Color, tol : float = 100) -> bool: - var dist = colorDistance(c1, c2) + var dist = colorDistance(c1, c2) return dist <= tol func colorDistance(c1 : Color, c2 : Color) -> float: diff --git a/Scripts/Main.gd b/Scripts/Main.gd index a1caf1f24..2ec8ee3dd 100644 --- a/Scripts/Main.gd +++ b/Scripts/Main.gd @@ -67,10 +67,10 @@ func _ready() -> void: "Crop Image" : 0, "Flip Horizontal" : KEY_MASK_SHIFT + KEY_H, "Flip Vertical" : KEY_MASK_SHIFT + KEY_V, + "Rotate Image" : 0, "Invert colors" : 0, "Desaturation" : 0, - "Outline" : 0, - "Rotate Image" : 0 + "Outline" : 0 } var help_menu_items := { "View Splash Screen" : 0, @@ -121,7 +121,7 @@ func _ready() -> void: i = 0 for item in image_menu_items.keys(): image_menu.add_item(item, i, image_menu_items[item]) - if i == 3: + if i == 4: image_menu.add_separator() i += 1 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].lock() 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] Global.canvas.handle_undo("Draw") for xx in image.get_size().x: @@ -333,7 +337,7 @@ func image_menu_id_pressed(id : int) -> void: continue image.set_pixel(xx, yy, px_color) Global.canvas.handle_redo("Draw") - 5: # Desaturation + 6: # Desaturation var image : Image = Global.canvas.layers[Global.canvas.current_layer_index][0] Global.canvas.handle_undo("Draw") 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) image.set_pixel(xx, yy, px_color) Global.canvas.handle_redo("Draw") - 6: # Outline + 7: # Outline $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: match id: