1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 09:09:47 +00:00

Add border selection, fix some missing translation strings

This commit is contained in:
Emmanouil Papadeas 2024-11-15 01:41:44 +02:00
parent dec698024c
commit 0d6b140dea
7 changed files with 74 additions and 17 deletions

View file

@ -205,6 +205,43 @@ msgstr ""
msgid "Invert"
msgstr ""
msgid "Modify"
msgstr ""
#. Found under the Select menu, in the Modify submenu. When selected, it shows a window that lets users expand the active selection.
msgid "Expand"
msgstr ""
#. Title of a window that lets users expand the active selection.
msgid "Expand Selection"
msgstr ""
#. Found under the Select menu, in the Modify submenu. When selected, it shows a window that lets users shrink the active selection.
msgid "Shrink"
msgstr ""
#. Title of a window that lets users shrink the active selection.
msgid "Shrink Selection"
msgstr ""
#. Found under the Select menu, in the Modify submenu. When selected, it shows a window that lets users create a border of the active selection.
msgid "Border"
msgstr ""
#. Title of a window that lets users create a border of the active selection.
msgid "Border Selection"
msgstr ""
#. Refers to a diamond-like shape.
msgid "Diamond"
msgstr ""
msgid "Circle"
msgstr ""
msgid "Square"
msgstr ""
msgid "Grayscale View"
msgstr ""

View file

@ -185,22 +185,34 @@ func resize_bitmap_values(
blit_rect(smaller_image, Rect2i(Vector2i.ZERO, new_bitmap_size), dst)
func expand(width: int, pattern: int) -> void:
func expand(width: int, brush: int) -> void:
var params := {
"color": Color(1, 1, 1, 1),
"width": width,
"pattern": pattern,
"brush": brush,
}
var gen := ShaderImageEffect.new()
gen.generate_image(self, OUTLINE_INLINE_SHADER, params, get_size())
func shrink(width: int, pattern: int) -> void:
func shrink(width: int, brush: int) -> void:
var params := {
"color": Color(0),
"inside": true,
"width": width,
"pattern": pattern,
"brush": brush,
"inside": true,
}
var gen := ShaderImageEffect.new()
gen.generate_image(self, OUTLINE_INLINE_SHADER, params, get_size())
func border(width: int, brush: int) -> void:
var params := {
"color": Color(1, 1, 1, 1),
"width": width,
"brush": brush,
"inside": true,
"keep_border_only": true,
}
var gen := ShaderImageEffect.new()
gen.generate_image(self, OUTLINE_INLINE_SHADER, params, get_size())

View file

@ -4,9 +4,10 @@ render_mode unshaded;
uniform vec4 color : source_color = vec4(1.0);
uniform float width : hint_range(0, 10, 1) = 1.0;
// uniform_data pattern type:: OptionButton [Diamond||Circle||Square]
uniform int pattern : hint_range(0, 2) = 0;
// uniform_data brush type:: OptionButton [Diamond||Circle||Square]
uniform int brush : hint_range(0, 2) = 0;
uniform bool inside = false;
uniform bool keep_border_only = false;
uniform sampler2D selection : filter_nearest;
bool is_zero_approx(float num) {
@ -17,11 +18,11 @@ bool has_contrary_neighbour(vec2 uv, vec2 texture_pixel_size, sampler2D tex) {
for (float i = -ceil(width); i <= ceil(width); i++) {
float offset;
if (pattern == 0) {
if (brush == 0) {
offset = width - abs(i);
} else if (pattern == 1) {
} else if (brush == 1) {
offset = floor(sqrt(pow(width + 0.5, 2) - i * i));
} else if (pattern == 2) {
} else if (brush == 2) {
offset = width;
}
@ -51,6 +52,9 @@ void fragment() {
output.a += (1.0 - output.a) * color.a;
}
}
else if (keep_border_only) {
output.a = 0.0;
}
COLOR = mix(original_color, output, selection_color.a);
}

View file

@ -31,7 +31,7 @@ func commit_action(cel: Image, project := Global.current_project) -> void:
var params := {
"color": color,
"width": anim_thickness,
"pattern": pattern,
"brush": pattern,
"inside": inside_image,
"selection": selection_tex
}

View file

@ -51,16 +51,15 @@ size_flags_horizontal = 3
[node name="PatternLabel" type="Label" parent="VBoxContainer/OutlineOptions" index="4"]
layout_mode = 2
size_flags_horizontal = 3
text = "Pattern:"
text = "Brush:"
[node name="PatternOptionButton" type="OptionButton" parent="VBoxContainer/OutlineOptions" index="5"]
layout_mode = 2
size_flags_horizontal = 3
mouse_default_cursor_shape = 2
item_count = 3
selected = 0
item_count = 3
popup/item_0/text = "Diamond"
popup/item_0/id = 0
popup/item_1/text = "Circle"
popup/item_1/id = 1
popup/item_2/text = "Square"

View file

@ -1,14 +1,16 @@
extends ConfirmationDialog
enum Types { EXPAND, SHRINK }
enum Types { EXPAND, SHRINK, BORDER }
@export var type := Types.EXPAND:
set(value):
type = value
if type == Types.EXPAND:
title = "Expand Selection"
else:
elif type == Types.SHRINK:
title = "Shrink Selection"
else:
title = "Border Selection"
@onready var width_slider: ValueSlider = $GridContainer/WidthSlider
@onready var brush_option_button: OptionButton = $GridContainer/BrushOptionButton
@ -31,8 +33,10 @@ func _on_confirmed() -> void:
project.selection_map.crop(project.size.x, project.size.y)
if type == Types.EXPAND:
project.selection_map.expand(width, brush)
else:
elif type == Types.SHRINK:
project.selection_map.shrink(width, brush)
else:
project.selection_map.border(width, brush)
selection_node.big_bounding_rectangle = project.selection_map.get_used_rect()
project.selection_offset = Vector2.ZERO
selection_node.commit_undo("Modify Selection", undo_data_tmp)

View file

@ -460,6 +460,7 @@ func _setup_selection_modify_submenu(item: String) -> void:
selection_modify_submenu.set_name("selection_modify_submenu")
selection_modify_submenu.add_item("Expand")
selection_modify_submenu.add_item("Shrink")
selection_modify_submenu.add_item("Border")
selection_modify_submenu.id_pressed.connect(_selection_modify_submenu_id_pressed)
select_menu.add_child(selection_modify_submenu)
select_menu.add_submenu_item(item, selection_modify_submenu.get_name())