Skip to content

@jsvision/core / rgb256

Function: rgb256()

rgb256(index): Rgb

Defined in: color/palette.ts:84

Reference RGB for xterm-256 palette index n (0–255): the 16 base colors (0–15), the 6×6×6 cube (16–231), then the 24-step gray ramp (232–255).

Pair it with nearest256 to preview how a truecolor value looks once downsampled to the 256-color palette.

Parameters

index

number

An integer 0–255.

Returns

Rgb

The reference RGB for that palette entry.

Example

ts
import { rgb256, nearest256 } from '@jsvision/core';

const rgb = rgb256(nearest256({ r: 59, g: 130, b: 246 })); // the 256-color stand-in for #3b82f6