list_palette_usage
Count which palette indices an indexed sprite uses and how many pixels each covers. Also list unused indices, cycling runs, and out-of-range pixels.
Instructions
Which palette indices the art is drawn with, how many pixels each covers, and which runs of them are worth cycling.
Indexed sprites only: an RGB or grayscale pixel carries its own colour rather than an
offset into a palette, so there is no index to count. `extract_palette` lists the
colours such a sprite uses and `assess_sprite` counts them.
The answer `cycle_palette` needs and the answer `get_palette` cannot give. A palette
says what colours exist; this says which of them the picture actually uses, so a
256-entry palette on a sprite painted in nine colours stops being a wall of hex. The
only way to work this out before was to read every pixel through `get_pixels` and
count them by hand.
Args:
frame: Count only this frame. Default: every frame.
layer: Count only this layer. Default: every pixel layer, groups walked through.
Tilemap layers are skipped, because the numbers in their cels are tile
references rather than palette offsets.
Returns `used` (index, colour and pixel count, most pixels first), `unused`, `runs`
(the contiguous spans of used indices, longest first, which is what a cycle rotates),
the transparent index and how many pixels sit on it, and `out_of_range`: pixels
carrying an index past the end of the palette, which is what a palette resized
smaller than its art leaves behind and which no colour can be read for at all.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| frame | No | ||
| layer | No | ||
| filename | Yes |