palette-shader 0.14.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # palette-shader
2
2
 
3
- A dependency-free WebGL2 shader that maps any color palette across a 3-D perceptual color space and snaps each pixel to the nearest palette color. Visualize how a palette distributes across 20+ color models and eight distance metrics, all on the GPU. Includes 2-D cross-section views (`PaletteViz`) and an interactive 3-D cube/cylinder view (`PaletteViz3D`) with trackball rotation.
3
+ A dependency-free WebGL2 shader that maps any color palette across a 3-D perceptual color space and snaps each pixel to the nearest palette color. Visualize how a palette distributes across 30+ color models and ten distance metrics, all on the GPU. Includes 2-D cross-section views (`PaletteViz`) and an interactive 3-D cube/cylinder view (`PaletteViz3D`) with trackball rotation.
4
4
 
5
5
  [**Live demo →**](https://meodai.github.io/color-palette-shader/)
6
6
 
@@ -191,14 +191,16 @@ Controls the 3-D color space the visualization is rendered in. Polar variants (`
191
191
 
192
192
  **OK — Lab / LCH**
193
193
 
194
- | Value | Shape | Description |
195
- | --------------- | ----- | ------------------------------------------------------------------------------------ |
196
- | `'oklab'` | cube | Raw OKLab: x→a, y→b, z→L. |
197
- | `'oklch'` | cube | OKLab in cylindrical LCH coordinates. Ideal for chroma or lightness slices. |
198
- | `'oklchPolar'` | wheel | Polar form of OKLch. |
199
- | `'oklrab'` | cube | OKLab with toe-corrected lightness (Lr). Better perceptual uniformity in dark tones. |
200
- | `'oklrch'` | cube | OKLrab in cylindrical LCH coordinates. |
201
- | `'oklrchPolar'` | wheel | Polar form of OKLrch. |
194
+ | Value | Shape | Description |
195
+ | ---------------- | -------- | ------------------------------------------------------------------------------------ |
196
+ | `'oklab'` | cube | Raw OKLab: x→a, y→b, z→L. |
197
+ | `'oklch'` | cube | OKLab in cylindrical LCH coordinates. Ideal for chroma or lightness slices. |
198
+ | `'oklchPolar'` | wheel | Polar form of OKLch. |
199
+ | `'oklchDiag'` | diagonal | Complementary hue plane: lightness on the diagonal, signed chroma on the anti-diagonal. Two opposite hues share the same view — no gray band in the middle. |
200
+ | `'oklrab'` | cube | OKLab with toe-corrected lightness (Lr). Better perceptual uniformity in dark tones. |
201
+ | `'oklrch'` | cube | OKLrab in cylindrical LCH coordinates. |
202
+ | `'oklrchPolar'` | wheel | Polar form of OKLrch. |
203
+ | `'oklrchDiag'` | diagonal | Complementary hue plane in OKLrch. Same diagonal layout as `oklchDiag` with toe-corrected lightness. |
202
204
 
203
205
  **CIE Lab / LCH — D65**
204
206
 
@@ -228,6 +230,22 @@ Controls the 3-D color space the visualization is rendered in. Polar variants (`
228
230
  | `'hwbPolar'` | wheel | Polar form of HWB. |
229
231
  | `'rgb'` | cube | Raw sRGB cube. Useful as a baseline. |
230
232
 
233
+ **Quantized RGB**
234
+
235
+ | Value | Shape | Description |
236
+ | ------------ | ----- | ---------------------------------------------------------------- |
237
+ | `'rgb6bit'` | cube | 2-bit per channel (64 colors). Game Boy–era palettes. |
238
+ | `'rgb8bit'` | cube | 3-3-2 bit (256 colors). CGA-style quantization. |
239
+ | `'rgb12bit'` | cube | 4-bit per channel (4096 colors). Amiga / NTSC. |
240
+ | `'rgb15bit'` | cube | 5-bit per channel (32768 colors). SVGA HiColor. |
241
+ | `'rgb18bit'` | cube | 6-bit per channel (262144 colors). VGA. |
242
+
243
+ **Spectral**
244
+
245
+ | Value | Shape | Description |
246
+ | ------------ | ----- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
247
+ | `'spectrum'` | cube | Visible light wavelengths (410–665 nm) plus purple line, modulated in OKLab. Inspired by censor's SpectroBoxWidget. X→wavelength, Y→lightness, Z→chroma scale. |
248
+
231
249
  The OK-variants rely on Björn Ottosson's gamut-aware implementation and produce significantly more even hue distributions than the classic variants at the same GPU cost.
232
250
 
233
251
  ### Cube vs. polar — which to use?
@@ -248,10 +266,12 @@ Controls how "nearest palette color" is determined per pixel.
248
266
 
249
267
  **OK**
250
268
 
251
- | Value | Description | Cost |
252
- | ---------- | ------------------------------------------------------------------------------------------------------- | ---- |
253
- | `'oklab'` | **Default.** Euclidean distance in OKLab. Fast, perceptually uniform, excellent general-purpose choice. | low |
254
- | `'oklrab'` | Euclidean in OKLab with toe-corrected lightness. Slightly better uniformity in dark tones than OKLab. | low |
269
+ | Value | Description | Cost |
270
+ | --------------- | ------------------------------------------------------------------------------------------------------- | ---- |
271
+ | `'oklab'` | **Default.** Euclidean distance in OKLab. Fast, perceptually uniform, excellent general-purpose choice. | low |
272
+ | `'oklrab'` | Euclidean in OKLab with toe-corrected lightness. Slightly better uniformity in dark tones than OKLab. | low |
273
+ | `'okLightness'` | Absolute lightness difference in OKLab (`|ΔL|`). Ignores hue and chroma — groups by brightness only. | low |
274
+ | `'liMatch'` | Spatially varying blend: full OKLab distance at the left edge, pure lightness match at the right. Inspired by censor's li-match. Useful for visualising tonal structure. | low |
255
275
 
256
276
  **CIE — D65**
257
277
 
@@ -4,7 +4,7 @@ export declare type ColorList = ColorRGB[];
4
4
 
5
5
  export declare type ColorRGB = [number, number, number];
6
6
 
7
- export declare type DistanceMetric = 'rgb' | 'oklab' | 'deltaE76' | 'deltaE94' | 'deltaE2000' | 'kotsarenkoRamos' | 'oklrab' | 'cielabD50';
7
+ export declare type DistanceMetric = 'rgb' | 'oklab' | 'deltaE76' | 'deltaE94' | 'deltaE2000' | 'kotsarenkoRamos' | 'oklrab' | 'cielabD50' | 'okLightness' | 'liMatch';
8
8
 
9
9
  export declare const fragmentShader: string;
10
10
 
@@ -132,6 +132,6 @@ export declare type PaletteVizOptions = {
132
132
 
133
133
  export declare const randomPalette: (size?: number) => ColorList;
134
134
 
135
- export declare type SupportedColorModels = 'rgb' | 'rgb12bit' | 'rgb8bit' | 'rgb18bit' | 'rgb6bit' | 'rgb15bit' | 'oklab' | 'okhsv' | 'okhsvPolar' | 'okhsl' | 'okhslPolar' | 'oklch' | 'oklchPolar' | 'hsv' | 'hsvPolar' | 'hsl' | 'hslPolar' | 'hwb' | 'hwbPolar' | 'oklrab' | 'oklrch' | 'oklrchPolar' | 'cielab' | 'cielch' | 'cielchPolar' | 'cielabD50' | 'cielchD50' | 'cielchD50Polar';
135
+ export declare type SupportedColorModels = 'rgb' | 'rgb12bit' | 'rgb8bit' | 'rgb18bit' | 'rgb6bit' | 'rgb15bit' | 'oklab' | 'okhsv' | 'okhsvPolar' | 'okhsl' | 'okhslPolar' | 'oklch' | 'oklchPolar' | 'hsv' | 'hsvPolar' | 'hsl' | 'hslPolar' | 'hwb' | 'hwbPolar' | 'oklrab' | 'oklrch' | 'oklrchPolar' | 'cielab' | 'cielch' | 'cielchPolar' | 'cielabD50' | 'cielchD50' | 'cielchD50Polar' | 'spectrum' | 'oklchDiag' | 'oklrchDiag';
136
136
 
137
137
  export { }