@jsvision/core / nearest16
Function: nearest16()
nearest16(
rgb):number
Defined in: color/downsample.ts:80
Find the ANSI-16 palette index (0–15) closest to an RGB color, where 0–7 are the normal colors and 8–15 the bright variants.
Same lowest-index tie rule as nearest256.
Parameters
rgb
The source color (from toRgb).
Returns
number
The nearest ANSI-16 index, 0–15.
Example
ts
import { toRgb, nearest16 } from '@jsvision/core';
nearest16(toRgb('#000000')!); // → 0 (black)
nearest16(toRgb('#ffffff')!); // → 15 (bright white)