Jazz2::Editor::PaletteSearch class

Finds the entries of a palette that look the closest to colors.

Only the entries 1 to 255 are searched, entry 0 is transparent. The entries are kept sorted by lightness, so a search compares only those of a lightness close enough to matter — far fewer than all of them for most colors. It finds the same entry as comparing all of them would, the lowest one of equally close ones.

Constructors, destructors, conversion operators

PaletteSearch() defaulted
Creates a search that finds nothing until Reset() is called.
PaletteSearch(const std::uint32_t* palette) explicit
Creates a search of the entries 1 to 255 of a palette as R | G << 8 | B << 16.

Public functions

void Reset(const std::uint32_t* palette)
Searches the entries 1 to 255 of another palette.
auto FindNearest(const OkLab& color) const -> std::uint8_t
Returns the entry closest to a color, 1 to 255.