mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-31 07:29:49 +00:00
Fix issue where shader-based effects were not respecting the selection bounds, when the selection was out of the canvas
This commit is contained in:
parent
c3bb85f6c9
commit
dc6efe02bb
|
@ -96,6 +96,17 @@ func invert() -> void:
|
||||||
func return_cropped_copy(size: Vector2i) -> SelectionMap:
|
func return_cropped_copy(size: Vector2i) -> SelectionMap:
|
||||||
var selection_map_copy := SelectionMap.new()
|
var selection_map_copy := SelectionMap.new()
|
||||||
selection_map_copy.copy_from(self)
|
selection_map_copy.copy_from(self)
|
||||||
|
var diff := Vector2i.ZERO
|
||||||
|
var selection_position: Vector2i = Global.canvas.selection.big_bounding_rectangle.position
|
||||||
|
if selection_position.x < 0:
|
||||||
|
diff.x += selection_position.x
|
||||||
|
if selection_position.y < 0:
|
||||||
|
diff.y += selection_position.y
|
||||||
|
if diff != Vector2i.ZERO:
|
||||||
|
# If there are pixels out of bounds on the negative side (left & up),
|
||||||
|
# move them before resizing
|
||||||
|
selection_map_copy.fill(Color(0))
|
||||||
|
selection_map_copy.blit_rect(self, Rect2i(Vector2i.ZERO, get_size()), diff)
|
||||||
selection_map_copy.crop(size.x, size.y)
|
selection_map_copy.crop(size.x, size.y)
|
||||||
return selection_map_copy
|
return selection_map_copy
|
||||||
|
|
||||||
|
|
|
@ -199,7 +199,7 @@ func fill_in_color(pos: Vector2i) -> void:
|
||||||
var selection: Image
|
var selection: Image
|
||||||
var selection_tex: ImageTexture
|
var selection_tex: ImageTexture
|
||||||
if project.has_selection:
|
if project.has_selection:
|
||||||
selection = project.selection_map
|
selection = project.selection_map.return_cropped_copy(project.size)
|
||||||
else:
|
else:
|
||||||
selection = Image.create(project.size.x, project.size.y, false, Image.FORMAT_RGBA8)
|
selection = Image.create(project.size.x, project.size.y, false, Image.FORMAT_RGBA8)
|
||||||
selection.fill(Color(1, 1, 1, 1))
|
selection.fill(Color(1, 1, 1, 1))
|
||||||
|
@ -263,7 +263,7 @@ func fill_in_selection() -> void:
|
||||||
var selection: Image
|
var selection: Image
|
||||||
var selection_tex: ImageTexture
|
var selection_tex: ImageTexture
|
||||||
if project.has_selection:
|
if project.has_selection:
|
||||||
selection = project.selection_map
|
selection = project.selection_map.return_cropped_copy(project.size)
|
||||||
else:
|
else:
|
||||||
selection = Image.create(project.size.x, project.size.y, false, Image.FORMAT_RGBA8)
|
selection = Image.create(project.size.x, project.size.y, false, Image.FORMAT_RGBA8)
|
||||||
selection.fill(Color(1, 1, 1, 1))
|
selection.fill(Color(1, 1, 1, 1))
|
||||||
|
|
|
@ -49,8 +49,6 @@ popup/item_2/id = 2
|
||||||
[node name="SimilaritySlider" parent="." index="4" instance=ExtResource("1")]
|
[node name="SimilaritySlider" parent="." index="4" instance=ExtResource("1")]
|
||||||
visible = false
|
visible = false
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
focus_mode = 2
|
|
||||||
theme_type_variation = &"ValueSlider"
|
|
||||||
value = 100.0
|
value = 100.0
|
||||||
prefix = "Similarity:"
|
prefix = "Similarity:"
|
||||||
|
|
||||||
|
@ -96,14 +94,10 @@ stretch_mode = 6
|
||||||
|
|
||||||
[node name="OffsetX" parent="FillPattern" index="1" instance=ExtResource("1")]
|
[node name="OffsetX" parent="FillPattern" index="1" instance=ExtResource("1")]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
focus_mode = 2
|
|
||||||
theme_type_variation = &"ValueSlider"
|
|
||||||
prefix = "Offset X:"
|
prefix = "Offset X:"
|
||||||
|
|
||||||
[node name="OffsetY" parent="FillPattern" index="2" instance=ExtResource("1")]
|
[node name="OffsetY" parent="FillPattern" index="2" instance=ExtResource("1")]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
focus_mode = 2
|
|
||||||
theme_type_variation = &"ValueSlider"
|
|
||||||
prefix = "Offset Y:"
|
prefix = "Offset Y:"
|
||||||
|
|
||||||
[connection signal="item_selected" from="FillAreaOptions" to="." method="_on_FillAreaOptions_item_selected"]
|
[connection signal="item_selected" from="FillAreaOptions" to="." method="_on_FillAreaOptions_item_selected"]
|
||||||
|
|
|
@ -18,7 +18,8 @@ func _ready() -> void:
|
||||||
func commit_action(cel: Image, project := Global.current_project) -> void:
|
func commit_action(cel: Image, project := Global.current_project) -> void:
|
||||||
var selection_tex: ImageTexture
|
var selection_tex: ImageTexture
|
||||||
if selection_checkbox.button_pressed and project.has_selection:
|
if selection_checkbox.button_pressed and project.has_selection:
|
||||||
selection_tex = ImageTexture.create_from_image(project.selection_map)
|
var selection := project.selection_map.return_cropped_copy(project.size)
|
||||||
|
selection_tex = ImageTexture.create_from_image(selection)
|
||||||
|
|
||||||
var params := {
|
var params := {
|
||||||
"red": red, "blue": blue, "green": green, "alpha": alpha, "selection": selection_tex
|
"red": red, "blue": blue, "green": green, "alpha": alpha, "selection": selection_tex
|
||||||
|
|
|
@ -29,7 +29,8 @@ func commit_action(cel: Image, project := Global.current_project) -> void:
|
||||||
var offset_y := animate_panel.get_animated_value(commit_idx, Animate.OFFSET_Y)
|
var offset_y := animate_panel.get_animated_value(commit_idx, Animate.OFFSET_Y)
|
||||||
var selection_tex: ImageTexture
|
var selection_tex: ImageTexture
|
||||||
if selection_checkbox.button_pressed and project.has_selection:
|
if selection_checkbox.button_pressed and project.has_selection:
|
||||||
selection_tex = ImageTexture.create_from_image(project.selection_map)
|
var selection := project.selection_map.return_cropped_copy(project.size)
|
||||||
|
selection_tex = ImageTexture.create_from_image(selection)
|
||||||
|
|
||||||
var params := {
|
var params := {
|
||||||
"offset": Vector2(offset_x, offset_y), "shadow_color": color, "selection": selection_tex
|
"offset": Vector2(offset_x, offset_y), "shadow_color": color, "selection": selection_tex
|
||||||
|
|
|
@ -58,7 +58,8 @@ func _ready() -> void:
|
||||||
func commit_action(cel: Image, project := Global.current_project) -> void:
|
func commit_action(cel: Image, project := Global.current_project) -> void:
|
||||||
var selection_tex: ImageTexture
|
var selection_tex: ImageTexture
|
||||||
if selection_checkbox.button_pressed and project.has_selection:
|
if selection_checkbox.button_pressed and project.has_selection:
|
||||||
selection_tex = ImageTexture.create_from_image(project.selection_map)
|
var selection := project.selection_map.return_cropped_copy(project.size)
|
||||||
|
selection_tex = ImageTexture.create_from_image(selection)
|
||||||
|
|
||||||
var dither_texture := selected_dither_matrix.texture
|
var dither_texture := selected_dither_matrix.texture
|
||||||
var gradient := gradient_edit.gradient
|
var gradient := gradient_edit.gradient
|
||||||
|
|
|
@ -13,7 +13,8 @@ func _ready() -> void:
|
||||||
func commit_action(cel: Image, project := Global.current_project) -> void:
|
func commit_action(cel: Image, project := Global.current_project) -> void:
|
||||||
var selection_tex: ImageTexture
|
var selection_tex: ImageTexture
|
||||||
if selection_checkbox.button_pressed and project.has_selection:
|
if selection_checkbox.button_pressed and project.has_selection:
|
||||||
selection_tex = ImageTexture.create_from_image(project.selection_map)
|
var selection := project.selection_map.return_cropped_copy(project.size)
|
||||||
|
selection_tex = ImageTexture.create_from_image(selection)
|
||||||
|
|
||||||
var params := {"selection": selection_tex, "gradient_map": $VBoxContainer/GradientEdit.texture}
|
var params := {"selection": selection_tex, "gradient_map": $VBoxContainer/GradientEdit.texture}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,8 @@ func commit_action(cel: Image, project := Global.current_project) -> void:
|
||||||
var val = animate_panel.get_animated_value(commit_idx, Animate.VALUE) / 100
|
var val = animate_panel.get_animated_value(commit_idx, Animate.VALUE) / 100
|
||||||
var selection_tex: ImageTexture
|
var selection_tex: ImageTexture
|
||||||
if selection_checkbox.button_pressed and project.has_selection:
|
if selection_checkbox.button_pressed and project.has_selection:
|
||||||
selection_tex = ImageTexture.create_from_image(project.selection_map)
|
var selection := project.selection_map.return_cropped_copy(project.size)
|
||||||
|
selection_tex = ImageTexture.create_from_image(selection)
|
||||||
|
|
||||||
var params := {"hue": hue, "saturation": sat, "value": val, "selection": selection_tex}
|
var params := {"hue": hue, "saturation": sat, "value": val, "selection": selection_tex}
|
||||||
if !has_been_confirmed:
|
if !has_been_confirmed:
|
||||||
|
|
|
@ -18,7 +18,8 @@ func _ready() -> void:
|
||||||
func commit_action(cel: Image, project := Global.current_project) -> void:
|
func commit_action(cel: Image, project := Global.current_project) -> void:
|
||||||
var selection_tex: ImageTexture
|
var selection_tex: ImageTexture
|
||||||
if selection_checkbox.button_pressed and project.has_selection:
|
if selection_checkbox.button_pressed and project.has_selection:
|
||||||
selection_tex = ImageTexture.create_from_image(project.selection_map)
|
var selection := project.selection_map.return_cropped_copy(project.size)
|
||||||
|
selection_tex = ImageTexture.create_from_image(selection)
|
||||||
|
|
||||||
var params := {
|
var params := {
|
||||||
"red": red, "blue": blue, "green": green, "alpha": alpha, "selection": selection_tex
|
"red": red, "blue": blue, "green": green, "alpha": alpha, "selection": selection_tex
|
||||||
|
|
|
@ -34,7 +34,8 @@ func commit_action(cel: Image, project := Global.current_project) -> void:
|
||||||
var offset := Vector2(offset_x, offset_y)
|
var offset := Vector2(offset_x, offset_y)
|
||||||
var selection_tex: ImageTexture
|
var selection_tex: ImageTexture
|
||||||
if selection_checkbox.button_pressed and project.has_selection:
|
if selection_checkbox.button_pressed and project.has_selection:
|
||||||
selection_tex = ImageTexture.create_from_image(project.selection_map)
|
var selection := project.selection_map.return_cropped_copy(project.size)
|
||||||
|
selection_tex = ImageTexture.create_from_image(selection)
|
||||||
|
|
||||||
var params := {"offset": offset, "wrap_around": wrap_around, "selection": selection_tex}
|
var params := {"offset": offset, "wrap_around": wrap_around, "selection": selection_tex}
|
||||||
if !has_been_confirmed:
|
if !has_been_confirmed:
|
||||||
|
|
|
@ -25,7 +25,8 @@ func commit_action(cel: Image, project := Global.current_project) -> void:
|
||||||
var anim_thickness := animate_panel.get_animated_value(commit_idx, Animate.THICKNESS)
|
var anim_thickness := animate_panel.get_animated_value(commit_idx, Animate.THICKNESS)
|
||||||
var selection_tex: ImageTexture
|
var selection_tex: ImageTexture
|
||||||
if selection_checkbox.button_pressed and project.has_selection:
|
if selection_checkbox.button_pressed and project.has_selection:
|
||||||
selection_tex = ImageTexture.create_from_image(project.selection_map)
|
var selection := project.selection_map.return_cropped_copy(project.size)
|
||||||
|
selection_tex = ImageTexture.create_from_image(selection)
|
||||||
|
|
||||||
var params := {
|
var params := {
|
||||||
"color": color,
|
"color": color,
|
||||||
|
|
|
@ -13,7 +13,8 @@ func _ready() -> void:
|
||||||
func commit_action(cel: Image, project := Global.current_project) -> void:
|
func commit_action(cel: Image, project := Global.current_project) -> void:
|
||||||
var selection_tex: ImageTexture
|
var selection_tex: ImageTexture
|
||||||
if selection_checkbox.button_pressed and project.has_selection:
|
if selection_checkbox.button_pressed and project.has_selection:
|
||||||
selection_tex = ImageTexture.create_from_image(project.selection_map)
|
var selection := project.selection_map.return_cropped_copy(project.size)
|
||||||
|
selection_tex = ImageTexture.create_from_image(selection)
|
||||||
|
|
||||||
if not is_instance_valid(Palettes.current_palette):
|
if not is_instance_valid(Palettes.current_palette):
|
||||||
return
|
return
|
||||||
|
|
|
@ -14,7 +14,8 @@ func _ready() -> void:
|
||||||
func commit_action(cel: Image, project := Global.current_project) -> void:
|
func commit_action(cel: Image, project := Global.current_project) -> void:
|
||||||
var selection_tex: ImageTexture
|
var selection_tex: ImageTexture
|
||||||
if selection_checkbox.button_pressed and project.has_selection:
|
if selection_checkbox.button_pressed and project.has_selection:
|
||||||
selection_tex = ImageTexture.create_from_image(project.selection_map)
|
var selection := project.selection_map.return_cropped_copy(project.size)
|
||||||
|
selection_tex = ImageTexture.create_from_image(selection)
|
||||||
|
|
||||||
var params := {"pixel_size": pixel_size, "selection": selection_tex}
|
var params := {"pixel_size": pixel_size, "selection": selection_tex}
|
||||||
if !has_been_confirmed:
|
if !has_been_confirmed:
|
||||||
|
|
|
@ -15,7 +15,8 @@ func _ready() -> void:
|
||||||
func commit_action(cel: Image, project := Global.current_project) -> void:
|
func commit_action(cel: Image, project := Global.current_project) -> void:
|
||||||
var selection_tex: ImageTexture
|
var selection_tex: ImageTexture
|
||||||
if selection_checkbox.button_pressed and project.has_selection:
|
if selection_checkbox.button_pressed and project.has_selection:
|
||||||
selection_tex = ImageTexture.create_from_image(project.selection_map)
|
var selection := project.selection_map.return_cropped_copy(project.size)
|
||||||
|
selection_tex = ImageTexture.create_from_image(selection)
|
||||||
|
|
||||||
var params := {"colors": levels, "dither_intensity": dither, "selection": selection_tex}
|
var params := {"colors": levels, "dither_intensity": dither, "selection": selection_tex}
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ func commit_action(cel: Image, _project := Global.current_project) -> void:
|
||||||
var image := Image.new()
|
var image := Image.new()
|
||||||
image.copy_from(cel)
|
image.copy_from(cel)
|
||||||
if _project.has_selection and selection_checkbox.button_pressed:
|
if _project.has_selection and selection_checkbox.button_pressed:
|
||||||
var selection := _project.selection_map
|
var selection := _project.selection_map.return_cropped_copy(_project.size)
|
||||||
selection_tex = ImageTexture.create_from_image(selection)
|
selection_tex = ImageTexture.create_from_image(selection)
|
||||||
|
|
||||||
if !_type_is_shader():
|
if !_type_is_shader():
|
||||||
|
|
Loading…
Reference in a new issue