mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-02-20 12:33:14 +00:00
Export palettes as images on the Web version
This commit is contained in:
parent
33ffa88a5b
commit
e377813a73
2 changed files with 14 additions and 5 deletions
|
@ -90,7 +90,10 @@ func _on_EditPaletteDialog_custom_action(action: StringName) -> void:
|
|||
if action == DELETE_ACTION:
|
||||
delete_confirmation.popup_centered()
|
||||
elif action == EXPORT_ACTION:
|
||||
export_file_dialog.popup_centered()
|
||||
if OS.has_feature("web"):
|
||||
exported.emit()
|
||||
else:
|
||||
export_file_dialog.popup_centered()
|
||||
|
||||
|
||||
func _on_delete_confirmation_confirmed() -> void:
|
||||
|
|
|
@ -252,15 +252,21 @@ func _color_changed(_color: Color, button: int) -> void:
|
|||
palette_grid.unselect_swatch(button, swatch_to_unselect)
|
||||
|
||||
|
||||
func _on_edit_palette_dialog_exported(path: String) -> void:
|
||||
func _on_edit_palette_dialog_exported(path := "") -> void:
|
||||
var image := Palettes.current_palette.convert_to_image()
|
||||
if OS.has_feature("web"):
|
||||
JavaScriptBridge.download_buffer(
|
||||
image.save_png_to_buffer(),
|
||||
Palettes.current_palette.name,
|
||||
"image/png"
|
||||
)
|
||||
if path.is_empty():
|
||||
return
|
||||
var extension := path.get_extension()
|
||||
match extension:
|
||||
"png":
|
||||
var image := Palettes.current_palette.convert_to_image()
|
||||
image.save_png(path)
|
||||
"jpg", "jpeg":
|
||||
var image := Palettes.current_palette.convert_to_image()
|
||||
image.save_jpg(path)
|
||||
"webp":
|
||||
var image := Palettes.current_palette.convert_to_image()
|
||||
image.save_webp(path)
|
||||
|
|
Loading…
Add table
Reference in a new issue