color.palette.builtin¶
Summary¶
color.palette.builtin returns a shared nearest-filtered map for categorical colors. Use the matching convenience method for a fixed palette or swatch to obtain one linear RGBA color by index.
Syntax¶
builtin(name: BuiltinPaletteName): Colormap
tab10(): Colormap
okabeito(): Colormap
chartjs(): Colormap
const palette = WasmGPU.color.palette.okabeito();
Parameters¶
| Name | Type | Required | Description |
|---|---|---|---|
name |
BuiltinPaletteName |
For builtin |
Registered palette name. Unknown names throw. |
Returns¶
Colormap - Shared map with one texel per swatch in palette order. The equivalent class method is Colormap.palette(name). The convenience methods color.palette.tab10(), color.palette.okabeito() and color.palette.chartjs() return the same objects as the corresponding named lookup.
Type Details¶
To sample swatch index i through the map, use its texel center, (i + 0.5) / palette.width, with 0 <= i < palette.width. swatch accepts the integer index directly and wraps indices outside the palette range.
Example¶
const palette = WasmGPU.color.palette.tab10();
const second = palette.sampleCPU((1 + 0.5) / palette.width);
console.log(second);