1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//! Gamut mapping: deciding when a color sits inside a target gamut and
//! producing the closest in-gamut color when it does not.
//!
//! Mirrors culori 4.0.2's `clamp.js`. Four entry points:
//!
//! - [`in_gamut`] — boolean predicate, mirrors culori's `inGamut(mode)`.
//! - [`clamp_gamut`] — naïve per-channel clip, mirrors culori's
//! `clampGamut(mode)`.
//! - [`clamp_chroma`] — chroma-bisection clip in an LCh-like space, mirrors
//! culori's `clampChroma(color, mode)`.
//! - [`to_gamut`] — CSS Color Module 4 gamut-mapping algorithm, mirrors
//! culori's `toGamut(dest, mode)`.
//!
//! The `mode` argument names the destination gamut. Modes that carry a
//! gamut definition in culori 4.0.2:
//!
//! - sRGB family (`"rgb"`, `"hsl"`, `"hsv"`, `"hwb"`, `"hsi"`, `"okhsl"`,
//! `"okhsv"`) — `gamut: 'rgb'`, evaluated on the sRGB unit cube.
//! - linear sRGB (`"lrgb"`) — `gamut: true`, evaluated on its own channels.
//! - wide-gamut RGB (`"p3"`, `"rec2020"`, `"a98"`, `"prophoto"`) — each
//! defines its own `[0, 1]` linear-RGB box.
//!
//! Every other culori mode (`lab`, `lch`, `oklab`, `oklch`, `xyz*`, `jab`,
//! `dlab`, `itp`, `xyb`, `luv`, …) has no gamut field, so `in_gamut`
//! returns `true` and `clamp_gamut` returns the input unchanged. The three
//! culors-only modes (`hsluv`, `hpluv`, `prismatic`) share rgb's gamut box
//! since they have no culori entry to reference.
//!
//! Truly unknown mode strings degrade through the rgb gamut rather than
//! panicking; v1.5 dropped the panic from earlier versions.
pub use ;
pub use in_gamut;
pub use to_gamut;
use crateColor;
/// Returns `true` if `color` is in the sRGB gamut.
///
/// Mirrors culori 4.0.2's `displayable(color)` (`node_modules/culori/src/clamp.js`):
/// equivalent to `in_gamut(color, "rgb")`. Convenience alias for callers
/// that don't want to spell out the mode string.
/// Clamps `color` into the sRGB gamut by per-channel clipping.
///
/// Mirrors culori 4.0.2's `clampRgb(color)`: equivalent to
/// `clamp_gamut(color, "rgb")`. The result is returned in `color`'s
/// original mode.