mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 17:19:50 +00:00
feat: Added option to trim sprites empty area while exporting (#1088)
* feat: Added trim sprite option works like charm * fix: format issue * ran working gdformat
This commit is contained in:
parent
702197c639
commit
613dd5d7f6
|
@ -48,6 +48,7 @@ var current_tab := ExportTab.IMAGE
|
||||||
var processed_images: Array[ProcessedImage] = []
|
var processed_images: Array[ProcessedImage] = []
|
||||||
var export_json := false
|
var export_json := false
|
||||||
var split_layers := false
|
var split_layers := false
|
||||||
|
var trim_sprite := false
|
||||||
|
|
||||||
# Spritesheet options
|
# Spritesheet options
|
||||||
var orientation := Orientation.COLUMNS
|
var orientation := Orientation.COLUMNS
|
||||||
|
@ -270,6 +271,8 @@ func process_animation(project := Global.current_project) -> void:
|
||||||
else:
|
else:
|
||||||
var image := Image.create(project.size.x, project.size.y, false, Image.FORMAT_RGBA8)
|
var image := Image.create(project.size.x, project.size.y, false, Image.FORMAT_RGBA8)
|
||||||
_blend_layers(image, frame)
|
_blend_layers(image, frame)
|
||||||
|
if trim_sprite:
|
||||||
|
image = image.get_region(image.get_used_rect())
|
||||||
var duration := frame.duration * (1.0 / project.fps)
|
var duration := frame.duration * (1.0 / project.fps)
|
||||||
processed_images.append(ProcessedImage.new(image, project.frames.find(frame), duration))
|
processed_images.append(ProcessedImage.new(image, project.frames.find(frame), duration))
|
||||||
|
|
||||||
|
|
|
@ -448,6 +448,12 @@ func _on_MultipleAnimationsDirectories_toggled(button_pressed: bool) -> void:
|
||||||
Export.new_dir_for_each_frame_tag = button_pressed
|
Export.new_dir_for_each_frame_tag = button_pressed
|
||||||
|
|
||||||
|
|
||||||
|
func _on_TrimSprite_toggled(toggled_on: bool) -> void:
|
||||||
|
Export.trim_sprite = toggled_on
|
||||||
|
Export.process_data()
|
||||||
|
set_preview()
|
||||||
|
|
||||||
|
|
||||||
func _on_Frames_item_selected(id: int) -> void:
|
func _on_Frames_item_selected(id: int) -> void:
|
||||||
Export.frame_current_tag = id
|
Export.frame_current_tag = id
|
||||||
Export.process_data()
|
Export.process_data()
|
||||||
|
|
|
@ -301,6 +301,12 @@ tooltip_text = "Creates multiple files but every file is stored in different fol
|
||||||
mouse_default_cursor_shape = 2
|
mouse_default_cursor_shape = 2
|
||||||
text = "Create new folder for each frame tag"
|
text = "Create new folder for each frame tag"
|
||||||
|
|
||||||
|
[node name="TrimSprite" type="CheckBox" parent="VBoxContainer/VSplitContainer/VBoxContainer/AdvancedOptions/GridContainer" groups=["ExportImageOptions", "ExportMultipleFilesOptions"]]
|
||||||
|
layout_mode = 2
|
||||||
|
tooltip_text = "Trims sprite to visible portion of the spirte, considering each pixel with a non-zero alpha channel as visible."
|
||||||
|
mouse_default_cursor_shape = 2
|
||||||
|
text = "Trim Sprite"
|
||||||
|
|
||||||
[node name="PathDialog" type="FileDialog" parent="." groups=["FileDialogs"]]
|
[node name="PathDialog" type="FileDialog" parent="." groups=["FileDialogs"]]
|
||||||
mode = 2
|
mode = 2
|
||||||
title = "Open a Directory"
|
title = "Open a Directory"
|
||||||
|
@ -354,6 +360,7 @@ size_flags_horizontal = 3
|
||||||
[connection signal="toggled" from="VBoxContainer/VSplitContainer/VBoxContainer/AdvancedOptions/GridContainer/SplitLayers" to="." method="_on_split_layers_toggled"]
|
[connection signal="toggled" from="VBoxContainer/VSplitContainer/VBoxContainer/AdvancedOptions/GridContainer/SplitLayers" to="." method="_on_split_layers_toggled"]
|
||||||
[connection signal="toggled" from="VBoxContainer/VSplitContainer/VBoxContainer/AdvancedOptions/GridContainer/IncludeTagsInFilename" to="." method="_on_IncludeTagsInFilename_toggled"]
|
[connection signal="toggled" from="VBoxContainer/VSplitContainer/VBoxContainer/AdvancedOptions/GridContainer/IncludeTagsInFilename" to="." method="_on_IncludeTagsInFilename_toggled"]
|
||||||
[connection signal="toggled" from="VBoxContainer/VSplitContainer/VBoxContainer/AdvancedOptions/GridContainer/MultipleAnimationsDirectories" to="." method="_on_MultipleAnimationsDirectories_toggled"]
|
[connection signal="toggled" from="VBoxContainer/VSplitContainer/VBoxContainer/AdvancedOptions/GridContainer/MultipleAnimationsDirectories" to="." method="_on_MultipleAnimationsDirectories_toggled"]
|
||||||
|
[connection signal="toggled" from="VBoxContainer/VSplitContainer/VBoxContainer/AdvancedOptions/GridContainer/TrimSprite" to="." method="_on_TrimSprite_toggled"]
|
||||||
[connection signal="canceled" from="PathDialog" to="." method="_on_path_dialog_canceled"]
|
[connection signal="canceled" from="PathDialog" to="." method="_on_path_dialog_canceled"]
|
||||||
[connection signal="dir_selected" from="PathDialog" to="." method="_on_path_dialog_dir_selected"]
|
[connection signal="dir_selected" from="PathDialog" to="." method="_on_path_dialog_dir_selected"]
|
||||||
[connection signal="confirmed" from="FileExistsAlert" to="." method="_on_FileExistsAlert_confirmed"]
|
[connection signal="confirmed" from="FileExistsAlert" to="." method="_on_FileExistsAlert_confirmed"]
|
||||||
|
|
Loading…
Reference in a new issue