mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 17:19:50 +00:00
Palettes can now be created from the colors of the selected sprite
This commit is contained in:
parent
5df25c21c6
commit
5ce061d793
|
@ -14,6 +14,7 @@ Darshan Phaldesai (luiq54), Igor Santarek (jegor377), rob-a-bolton, Kinwailo
|
||||||
- You can now drag & drop files into the program while it's running to open them. You can open .pxo files, image files and palette (json and gpl) files this way.
|
- You can now drag & drop files into the program while it's running to open them. You can open .pxo files, image files and palette (json and gpl) files this way.
|
||||||
- You can now draw on the tiling mode previews! ([#65](https://github.com/Orama-Interactive/Pixelorama/issues/65))
|
- You can now draw on the tiling mode previews! ([#65](https://github.com/Orama-Interactive/Pixelorama/issues/65))
|
||||||
- Added Resize Canvas option to Image menu.
|
- Added Resize Canvas option to Image menu.
|
||||||
|
- Palettes can now be created from the colors of the selected sprite.
|
||||||
- You can now preview how the frames of the spritesheet you are importing will look.
|
- You can now preview how the frames of the spritesheet you are importing will look.
|
||||||
- You can now import image files as layers. Their size will be cropped to the project's size.
|
- You can now import image files as layers. Their size will be cropped to the project's size.
|
||||||
- You can import image files as brushes, patterns and palettes.
|
- You can import image files as brushes, patterns and palettes.
|
||||||
|
|
|
@ -1014,6 +1014,9 @@ msgstr ""
|
||||||
msgid "Import Palette"
|
msgid "Import Palette"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Create Palette From Current Sprite"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Palette Name:"
|
msgid "Palette Name:"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|
|
@ -87,6 +87,8 @@ func add_palette_menu_id_pressed(id : int) -> void:
|
||||||
on_new_empty_palette()
|
on_new_empty_palette()
|
||||||
1: # Import Palette
|
1: # Import Palette
|
||||||
on_import_palette()
|
on_import_palette()
|
||||||
|
2: # Create Palette From Current Sprite
|
||||||
|
create_palette_from_sprite()
|
||||||
|
|
||||||
|
|
||||||
func create_new_palette(name : String, _from_palette : Palette) -> String: # Returns empty string, else error string
|
func create_new_palette(name : String, _from_palette : Palette) -> String: # Returns empty string, else error string
|
||||||
|
@ -149,6 +151,28 @@ func on_edit_palette() -> void:
|
||||||
Global.edit_palette_popup.open(current_palette)
|
Global.edit_palette_popup.open(current_palette)
|
||||||
|
|
||||||
|
|
||||||
|
func create_palette_from_sprite() -> void:
|
||||||
|
var current_project : Project = Global.current_project
|
||||||
|
var new_palette_name : String = current_project.name
|
||||||
|
var result : String = create_new_palette(new_palette_name, null)
|
||||||
|
if not result.empty():
|
||||||
|
Global.error_dialog.set_text(result)
|
||||||
|
Global.error_dialog.popup_centered()
|
||||||
|
Global.dialog_open(true)
|
||||||
|
else:
|
||||||
|
var current_cel : Cel = current_project.frames[current_project.current_frame].cels[current_project.current_layer]
|
||||||
|
var cel_image : Image = current_cel.image
|
||||||
|
var palette : Palette = Global.palettes[current_palette]
|
||||||
|
for x in cel_image.get_size().x:
|
||||||
|
for y in cel_image.get_size().y:
|
||||||
|
var color : Color = cel_image.get_pixel(x, y)
|
||||||
|
if color.a > 0 and !palette.has_color(color):
|
||||||
|
palette.add_color(color)
|
||||||
|
|
||||||
|
save_palette(current_palette, current_palette + ".json")
|
||||||
|
_display_palette(palette)
|
||||||
|
|
||||||
|
|
||||||
func _on_PaletteOptionButton_item_selected(ID : int) -> void:
|
func _on_PaletteOptionButton_item_selected(ID : int) -> void:
|
||||||
var palette_name = Global.palette_option_button.get_item_metadata(ID)
|
var palette_name = Global.palette_option_button.get_item_metadata(ID)
|
||||||
if palette_name != null:
|
if palette_name != null:
|
||||||
|
|
|
@ -58,7 +58,7 @@ mouse_default_cursor_shape = 2
|
||||||
[node name="PopupMenu" type="PopupMenu" parent="PaletteVBoxContainer/CenterContainer/PaletteButtons/AddPalette"]
|
[node name="PopupMenu" type="PopupMenu" parent="PaletteVBoxContainer/CenterContainer/PaletteButtons/AddPalette"]
|
||||||
margin_right = 115.0
|
margin_right = 115.0
|
||||||
margin_bottom = 54.0
|
margin_bottom = 54.0
|
||||||
items = [ "New Empty Palette", null, 0, false, false, 0, 0, null, "", false, "Import Palette", null, 0, false, false, 1, 0, null, "", false ]
|
items = [ "New Empty Palette", null, 0, false, false, 0, 0, null, "", false, "Import Palette", null, 0, false, false, 1, 0, null, "", false, "Create Palette From Current Sprite", null, 0, false, false, 2, 0, null, "", false ]
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue