Palette

Palette()

local palette = Palette()
local palette = Palette(numberOfColors)
local palette = Palette(otherPalette)
local palette = Palette{ fromFile=filename }
local palette = Palette{ fromResource=resourceID }

Creates a new palette. By default it will contain 256 colors, but you can specify a numberOfColors (integer value).

otherPalette can be another palette object to create a copy of it.

If fromFile is given, the palette is loaded from the file name.

If fromResource is given, the resourceID is an ID specified in one of the extensions palette (e.g. DB16, DB32, Solarized).

Palette

local ncolors = #palette

Returns the number of colors in the palette (remember that valid indexes in the palette go from 0 to ncolors-1).

Palette:resize()

palette:resize(ncolors)

Changes the number of the palette colors to ncolors (an integer value).

Palette:getColor()

local color = palette:getColor(index)

Returns the color in the given entry index (the index goes from 0 to #palette-1).

Palette:setColor()

palette:setColor(index, color)

Changes a palette color in the given entry index (the index goes from 0 to #palette-1). The color can be a Color object or an integer pixel value.

Palette.frame

At the moment it always return the first frame, but in a near future Aseprite will support palette changes over time (in different frames), so this field should be the frame number where this palette is displayed for first time in the sprite.

Palette:saveAs()

palette:saveAs(filename)

Saves the palette in the given filename.