The colour spaces of CSS Color 4 as data, and the conversion of coordinates between them.
A space is a map of its :id, its :coords, its :base, and the functions :to-base and :from-base, which convert a vector of coordinates to and from those of the base. Each space's chain of bases ends at xyz-d65, the only space without a base. A conversion goes up one space's chain to the first space that the other's chain shares, then down the other's.
Each coordinate is a map of these:
The matrices and transfer functions are those of CSS Color 4's sample code, section 19, under the W3C Software and Document License: https://www.w3.org/TR/css-color-4/#color-conversion-code
The colour spaces of CSS Color 4 as data, and the conversion of coordinates between them. A space is a map of its :id, its :coords, its :base, and the functions :to-base and :from-base, which convert a vector of coordinates to and from those of the base. Each space's chain of bases ends at xyz-d65, the only space without a base. A conversion goes up one space's chain to the first space that the other's chain shares, then down the other's. Each coordinate is a map of these: - :id - :range, which a percentage of CSS is a share of - :category, the coordinates of other spaces it's analogous to, which interpolation uses - :angle?, true for a hue The matrices and transfer functions are those of CSS Color 4's sample code, section 19, under the W3C Software and Document License: https://www.w3.org/TR/css-color-4/#color-conversion-code
(convert coords from to)The coordinates coords of the space from in the space to. A missing
coordinate, nil, counts as 0, like none in CSS. A conversion to the
same space returns coords as they are.
The coordinates `coords` of the space `from` in the space `to`. A missing coordinate, nil, counts as 0, like none in CSS. A conversion to the same space returns `coords` as they are.
(coord-index k id)The index of the coordinate id of the space k, or nil.
The index of the coordinate `id` of the space `k`, or nil.
The white point D50 in XYZ, with the values of CSS Color 4.
The white point D50 in XYZ, with the values of CSS Color 4.
(gamut k)The id of the space whose gamut bounds the space k: its own for a space
of red, green and blue, sRGB for HSL and HWB, or nil for an unbounded
space, e.g. Oklab.
The id of the space whose gamut bounds the space `k`: its own for a space of red, green and blue, sRGB for HSL and HWB, or nil for an unbounded space, e.g. Oklab.
(hue a b)The hue in degrees of the opponent coordinates a and b, from 0 up to
360.
The hue in degrees of the opponent coordinates `a` and `b`, from 0 up to 360.
(hue-index k)The index of the hue of the space k, or nil for a space without one.
The index of the hue of the space `k`, or nil for a space without one.
(lab->xyz [l a b])The CIE Lab lab as XYZ D50.
The CIE Lab `lab` as XYZ D50.
(lineage k)The ids of the space k and of its bases, the space itself first.
The ids of the space `k` and of its bases, the space itself first.
(linear->prophoto x)The channel x of linear light as ProPhoto RGB.
The channel `x` of linear light as ProPhoto RGB.
(linear->srgb x)The channel x of linear light as sRGB.
The channel `x` of linear light as sRGB.
The matrix from the cube roots of LMS to Oklab.
The matrix from the cube roots of LMS to Oklab.
The matrix from the LMS of Oklab to XYZ D65.
The matrix from the LMS of Oklab to XYZ D65.
(multiply m v)The 3×3 matrix m times the vector v.
The 3×3 matrix `m` times the vector `v`.
The matrix from Oklab to the cube roots of LMS.
The matrix from Oklab to the cube roots of LMS.
(polar id base l-range c-range epsilon)The space id of lightness, chroma and hue over the space base, with
the lightness and chroma ranging over l-range and c-range.
At a chroma of epsilon or less, CSS Color 4 makes the hue powerless, so
missing, and the chroma 0.
The space `id` of lightness, chroma and hue over the space `base`, with the lightness and chroma ranging over `l-range` and `c-range`. At a chroma of `epsilon` or less, CSS Color 4 makes the hue powerless, so missing, and the chroma 0.
(power p)A transfer function that raises a channel to the power p and keeps its
sign, for a98-rgb and rec2020.
A transfer function that raises a channel to the power `p` and keeps its sign, for a98-rgb and rec2020.
(prophoto->linear x)The channel x of ProPhoto RGB as linear light.
The channel `x` of ProPhoto RGB as linear light.
(rgb-hue [r g b])The hue in degrees that HSL and HWB give the sRGB rgb, or nil for a
grey, including one that the rounding of a conversion leaves a hair away
from grey.
The hue in degrees that HSL and HWB give the sRGB `rgb`, or nil for a grey, including one that the rounding of a conversion leaves a hair away from grey.
(rgb-space id base to from)The space id of red, green and blue from 0 to 1, over the space base,
which to and from convert to and from: transfer functions of a
channel, or matrices.
The space `id` of red, green and blue from 0 to 1, over the space `base`, which `to` and `from` convert to and from: transfer functions of a channel, or matrices.
(signed f x)The function f of the absolute value of x, with the sign of x, so
that a transfer function extends below 0.
The function `f` of the absolute value of `x`, with the sign of `x`, so that a transfer function extends below 0.
(space k)The space whose id is k, or k itself when it's a space, or nil.
The space whose id is `k`, or `k` itself when it's a space, or nil.
The spaces of CSS Color 4 by their ids, and the linear forms of a98-rgb, prophoto-rgb and rec2020, which CSS doesn't name.
The spaces of CSS Color 4 by their ids, and the linear forms of a98-rgb, prophoto-rgb and rec2020, which CSS doesn't name.
(srgb->hsl rgb)The sRGB rgb as HSL, with no hue and no saturation for a grey.
The sRGB `rgb` as HSL, with no hue and no saturation for a grey.
(srgb->hwb rgb)The sRGB rgb as HWB, with no hue for a grey.
The sRGB `rgb` as HWB, with no hue for a grey.
(srgb->linear x)The channel x of sRGB as linear light.
The channel `x` of sRGB as linear light.
(xyz->lab xyz)The XYZ D50 xyz as CIE Lab.
The XYZ D50 `xyz` as CIE Lab.
The matrix from XYZ D65 to the LMS of Oklab.
The matrix from XYZ D65 to the LMS of Oklab.
(xyz-space id to from)The CIE XYZ space id, which the matrices to and from convert to and
from XYZ D65, both nil for xyz-d65 itself.
The CIE XYZ space `id`, which the matrices `to` and `from` convert to and from XYZ D65, both nil for xyz-d65 itself.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |