Skip to content

Instantly share code, notes, and snippets.

@dacap
Created November 11, 2020 13:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dacap/cb52f101b58cc5201b9149c8b1f3dd3e to your computer and use it in GitHub Desktop.
Save dacap/cb52f101b58cc5201b9149c8b1f3dd3e to your computer and use it in GitHub Desktop.
Export the palette of the active sprite to STDOUT as a C array
-- Usage: aseprite.exe -b my-sprite.aseprite -script export-palette.lua
--
-- Or from the UI you will see the output in a console that you can copy with Ctrl+C
--
local spr = app.activeSprite
if not spr then return print("No active sprite") end
local pal = spr.palettes[1]
print("const char palette[] = {")
for i = 0,#pal-1 do
local c = pal:getColor(i)
print(string.format(" %d, %d, %d, %d,", c.red, c.green, c.blue, c.alpha))
end
print("}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment