From eb28fd3d143a80f1f8cf00785a18f0baca92cb0a Mon Sep 17 00:00:00 2001 From: OverloadedOrama <35376950+OverloadedOrama@users.noreply.github.com> Date: Sat, 4 Jan 2020 01:22:23 +0200 Subject: [PATCH] Added "Place inside image" option for outline generation And this concludes outlines for v0.6 --- Prefabs/Dialogs/OutlineDialog.tscn | 31 ++++--- Scripts/Dialogs/AboutDialog.gd | 3 +- Scripts/Dialogs/OutlineDialog.gd | 126 ++++++++++++++++++++++------- Translations/zh_TW.po | 2 +- 4 files changed, 119 insertions(+), 43 deletions(-) diff --git a/Prefabs/Dialogs/OutlineDialog.tscn b/Prefabs/Dialogs/OutlineDialog.tscn index 832c15e97..f6a3a1ed4 100644 --- a/Prefabs/Dialogs/OutlineDialog.tscn +++ b/Prefabs/Dialogs/OutlineDialog.tscn @@ -3,6 +3,7 @@ [ext_resource path="res://Scripts/Dialogs/OutlineDialog.gd" type="Script" id=1] [node name="OutlineDialog" type="ConfirmationDialog"] +visible = true margin_right = 200.0 margin_bottom = 70.0 script = ExtResource( 1 ) @@ -12,23 +13,23 @@ anchor_left = 0.5 anchor_top = 0.5 anchor_right = 0.5 anchor_bottom = 0.5 -margin_left = -92.0 -margin_top = -27.0 -margin_right = 92.0 -margin_bottom = -1.0 +margin_left = -121.0 +margin_top = -52.0 +margin_right = 121.0 +margin_bottom = 24.0 custom_constants/vseparation = 4 custom_constants/hseparation = 4 columns = 2 [node name="ThickLabel" type="Label" parent="OptionsContainer"] margin_top = 5.0 -margin_right = 139.0 +margin_right = 90.0 margin_bottom = 19.0 text = "Thickness:" [node name="ThickValue" type="SpinBox" parent="OptionsContainer"] -margin_left = 143.0 -margin_right = 217.0 +margin_left = 94.0 +margin_right = 242.0 margin_bottom = 24.0 mouse_default_cursor_shape = 2 min_value = 1.0 @@ -38,22 +39,30 @@ suffix = "px" [node name="OutlineColorLabel" type="Label" parent="OptionsContainer"] margin_top = 31.0 -margin_right = 139.0 +margin_right = 90.0 margin_bottom = 45.0 text = "Fill with color:" [node name="OutlineColor" type="ColorPickerButton" parent="OptionsContainer"] -margin_left = 143.0 +margin_left = 94.0 margin_top = 28.0 -margin_right = 217.0 +margin_right = 242.0 margin_bottom = 48.0 rect_min_size = Vector2( 64, 20 ) color = Color( 1, 0, 0, 1 ) [node name="DiagonalCheckBox" type="CheckBox" parent="OptionsContainer"] margin_top = 52.0 -margin_right = 139.0 +margin_right = 90.0 margin_bottom = 76.0 mouse_default_cursor_shape = 2 text = "Diagonal" + +[node name="InsideImageCheckBox" type="CheckBox" parent="OptionsContainer"] +margin_left = 94.0 +margin_top = 52.0 +margin_right = 242.0 +margin_bottom = 76.0 +mouse_default_cursor_shape = 2 +text = "Place inside image" [connection signal="confirmed" from="." to="." method="_on_OutlineDialog_confirmed"] diff --git a/Scripts/Dialogs/AboutDialog.gd b/Scripts/Dialogs/AboutDialog.gd index b048841bf..fbed4b6ff 100644 --- a/Scripts/Dialogs/AboutDialog.gd +++ b/Scripts/Dialogs/AboutDialog.gd @@ -73,5 +73,4 @@ func _on_GitHub_pressed() -> void: OS.shell_open("https://github.com/Orama-Interactive/Pixelorama") func _on_Donate_pressed() -> void: - OS.shell_open("https://paypal.me/OverloadedOrama") - OS.shell_open("https://ko-fi.com/overloadedorama") + OS.shell_open("https://www.patreon.com/OramaInteractive") diff --git a/Scripts/Dialogs/OutlineDialog.gd b/Scripts/Dialogs/OutlineDialog.gd index 41c263ea6..50254c363 100644 --- a/Scripts/Dialogs/OutlineDialog.gd +++ b/Scripts/Dialogs/OutlineDialog.gd @@ -4,6 +4,7 @@ func _on_OutlineDialog_confirmed() -> void: var outline_color : Color = $OptionsContainer/OutlineColor.color var thickness : int = $OptionsContainer/ThickValue.value var diagonal : bool = $OptionsContainer/DiagonalCheckBox.pressed + var inside_image : bool = $OptionsContainer/InsideImageCheckBox.pressed var image : Image = Global.canvas.layers[Global.canvas.current_layer_index][0] if image.is_invisible(): @@ -21,54 +22,121 @@ func _on_OutlineDialog_confirmed() -> void: continue for i in range(1, thickness + 1): - var new_pos : Vector2 = pos + Vector2.LEFT * i # Left - if new_pos.x >= 0: - var new_pixel = image.get_pixelv(new_pos) - if new_pixel.a == 0: - new_image.set_pixelv(new_pos, outline_color) + if inside_image: + var outline_pos : Vector2 = pos + Vector2.LEFT # Left + var outline_pixel = image.get_pixelv(outline_pos) + if outline_pixel.a == 0: + var new_pos : Vector2 = pos + Vector2.RIGHT * (i - 1) + var new_pixel = image.get_pixelv(new_pos) + if new_pixel.a > 0 && new_pos.x < Global.canvas.size.x: + new_image.set_pixelv(new_pos, outline_color) - new_pos = pos + Vector2.RIGHT * i # Right - if new_pos.x < Global.canvas.size.x: - var new_pixel = image.get_pixelv(new_pos) - if new_pixel.a == 0: - new_image.set_pixelv(new_pos, outline_color) + outline_pos = pos + Vector2.RIGHT # Right + outline_pixel = image.get_pixelv(outline_pos) + if outline_pixel.a == 0: + var new_pos : Vector2 = pos + Vector2.LEFT * (i - 1) + var new_pixel = image.get_pixelv(new_pos) + if new_pixel.a > 0 && new_pos.x >= 0: + new_image.set_pixelv(new_pos, outline_color) - new_pos = pos + Vector2.UP * i # Up - if new_pos.y >= 0: - var new_pixel = image.get_pixelv(new_pos) - if new_pixel.a == 0: - new_image.set_pixelv(new_pos, outline_color) + outline_pos = pos + Vector2.UP # Up + outline_pixel = image.get_pixelv(outline_pos) + if outline_pixel.a == 0: + var new_pos : Vector2 = pos + Vector2.DOWN * (i - 1) + var new_pixel = image.get_pixelv(new_pos) + if new_pixel.a > 0 && new_pos.y < Global.canvas.size.y: + new_image.set_pixelv(new_pos, outline_color) - new_pos = pos + Vector2.DOWN * i # Down - if new_pos.y < Global.canvas.size.y: - var new_pixel = image.get_pixelv(new_pos) - if new_pixel.a == 0: - new_image.set_pixelv(new_pos, outline_color) + outline_pos = pos + Vector2.DOWN # Down + outline_pixel = image.get_pixelv(outline_pos) + if outline_pixel.a == 0: + var new_pos : Vector2 = pos + Vector2.UP * (i - 1) + var new_pixel = image.get_pixelv(new_pos) + if new_pixel.a > 0 && new_pos.y >= 0: + new_image.set_pixelv(new_pos, outline_color) - if diagonal: - new_pos = pos + (Vector2.LEFT + Vector2.UP) * i # Top left - if new_pos.x >= 0 && new_pos.y >= 0: + if diagonal: + outline_pos = pos + (Vector2.LEFT + Vector2.UP) # Top left + outline_pixel = image.get_pixelv(outline_pos) + if outline_pixel.a == 0: + var new_pos : Vector2 = pos + (Vector2.RIGHT + Vector2.DOWN) * (i - 1) + var new_pixel = image.get_pixelv(new_pos) + if new_pixel.a > 0 && new_pos.x < Global.canvas.size.x && new_pos.y < Global.canvas.size.y: + new_image.set_pixelv(new_pos, outline_color) + + outline_pos = pos + (Vector2.LEFT + Vector2.DOWN) # Bottom left + outline_pixel = image.get_pixelv(outline_pos) + if outline_pixel.a == 0: + var new_pos : Vector2 = pos + (Vector2.RIGHT + Vector2.UP) * (i - 1) + var new_pixel = image.get_pixelv(new_pos) + if new_pixel.a > 0 && new_pos.x < Global.canvas.size.x && new_pos.y >= 0: + new_image.set_pixelv(new_pos, outline_color) + + outline_pos = pos + (Vector2.RIGHT + Vector2.UP) # Top right + outline_pixel = image.get_pixelv(outline_pos) + if outline_pixel.a == 0: + var new_pos : Vector2 = pos + (Vector2.LEFT + Vector2.DOWN) * (i - 1) + var new_pixel = image.get_pixelv(new_pos) + if new_pixel.a > 0 && new_pos.x >= 0 && new_pos.y < Global.canvas.size.y: + new_image.set_pixelv(new_pos, outline_color) + + outline_pos = pos + (Vector2.RIGHT + Vector2.DOWN) # Bottom right + outline_pixel = image.get_pixelv(outline_pos) + if outline_pixel.a == 0: + var new_pos : Vector2 = pos + (Vector2.LEFT + Vector2.UP) * (i - 1) + var new_pixel = image.get_pixelv(new_pos) + if new_pixel.a > 0 && new_pos.x >= 0 && new_pos.y >= 0: + new_image.set_pixelv(new_pos, outline_color) + + else: + var new_pos : Vector2 = pos + Vector2.LEFT * i # Left + if new_pos.x >= 0: var new_pixel = image.get_pixelv(new_pos) if new_pixel.a == 0: new_image.set_pixelv(new_pos, outline_color) - new_pos = pos + (Vector2.LEFT + Vector2.DOWN) * i # Bottom left - if new_pos.x >= 0 && new_pos.y < Global.canvas.size.y: + new_pos = pos + Vector2.RIGHT * i # Right + if new_pos.x < Global.canvas.size.x: var new_pixel = image.get_pixelv(new_pos) if new_pixel.a == 0: new_image.set_pixelv(new_pos, outline_color) - new_pos = pos + (Vector2.RIGHT + Vector2.UP) * i # Top right - if new_pos.x < Global.canvas.size.x && new_pos.y >= 0: + new_pos = pos + Vector2.UP * i # Up + if new_pos.y >= 0: var new_pixel = image.get_pixelv(new_pos) if new_pixel.a == 0: new_image.set_pixelv(new_pos, outline_color) - new_pos = pos + (Vector2.RIGHT + Vector2.DOWN) * i # Bottom right - if new_pos.x < Global.canvas.size.x && new_pos.y < Global.canvas.size.y: + new_pos = pos + Vector2.DOWN * i # Down + if new_pos.y < Global.canvas.size.y: var new_pixel = image.get_pixelv(new_pos) if new_pixel.a == 0: new_image.set_pixelv(new_pos, outline_color) + if diagonal: + new_pos = pos + (Vector2.LEFT + Vector2.UP) * i # Top left + if new_pos.x >= 0 && new_pos.y >= 0: + var new_pixel = image.get_pixelv(new_pos) + if new_pixel.a == 0: + new_image.set_pixelv(new_pos, outline_color) + + new_pos = pos + (Vector2.LEFT + Vector2.DOWN) * i # Bottom left + if new_pos.x >= 0 && new_pos.y < Global.canvas.size.y: + var new_pixel = image.get_pixelv(new_pos) + if new_pixel.a == 0: + new_image.set_pixelv(new_pos, outline_color) + + new_pos = pos + (Vector2.RIGHT + Vector2.UP) * i # Top right + if new_pos.x < Global.canvas.size.x && new_pos.y >= 0: + var new_pixel = image.get_pixelv(new_pos) + if new_pixel.a == 0: + new_image.set_pixelv(new_pos, outline_color) + + new_pos = pos + (Vector2.RIGHT + Vector2.DOWN) * i # Bottom right + if new_pos.x < Global.canvas.size.x && new_pos.y < Global.canvas.size.y: + var new_pixel = image.get_pixelv(new_pos) + if new_pixel.a == 0: + new_image.set_pixelv(new_pos, outline_color) + image.copy_from(new_image) Global.canvas.handle_redo("Draw") diff --git a/Translations/zh_TW.po b/Translations/zh_TW.po index fa649d145..fa9bc7891 100644 --- a/Translations/zh_TW.po +++ b/Translations/zh_TW.po @@ -279,7 +279,7 @@ msgid "GitHub Contributors" msgstr "GitHub 貢獻者" msgid "Art by" -msgstr "作者:" +msgstr "作者" msgid "untitled" msgstr "未命名"