← back to roto on ba3a.dev

PaletteQuantiser

Maps a raster onto a Palette: each pixel at least half opaque takes the palette colour nearest to it in OKLab, the first on a tie, written as a palette label (index plus one); every other pixel is 0, background. How a reference photo becomes something an indexed sprite can hold.

Functions

Link copied to clipboard
fun labels(raster: Raster, palette: Palette): IndexedRaster

The palette labels of raster against palette.

Link copied to clipboard
fun nearest(argb: Int, palette: Palette): Int

The colour of palette nearest to argb in OKLab, the first on a tie. Alpha is not compared.