#css-color #color-space #css #palette #oklab #gamut #oklch

palette-gamut-mapping

Convert colors between color spaces with CSS Color Module Level 4 gamut mapping

2 releases

0.1.1 Jun 4, 2024
0.1.0 May 22, 2024

#8 in #css-color

Download history 93/week @ 2024-05-16 47/week @ 2024-05-23 106/week @ 2024-05-30 45/week @ 2024-06-06 9/week @ 2024-06-13 3/week @ 2024-06-20 2/week @ 2024-06-27 4/week @ 2024-07-04 32/week @ 2024-07-11 21/week @ 2024-07-18

64 downloads per month
Used in hi-nvim-rs

MIT/Apache

10KB
153 lines

Gamut mapping

Map between color spaces

MIT Apache 2.0 Crates.io Docs

Convert Palette colors between color spaces with CSS Color Module Level 4's gamut mapping algorithm.

use palette::{Oklch, Srgb};
use palette_gamut_mapping::gamut_map;

let color = Oklch::new(0.5, 0.205, 230.);

// roughly equal to #006d91
let srgb: Srgb = gamut_map(color);

Dependencies

~2.5MB
~47K SLoC