Liking cljdoc? Tell your friends :D

dk.simongray.colour-coded.space

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

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
raw docstring

convertclj/s

(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.
sourceraw docstring

coord-indexclj/s

(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.
sourceraw docstring

d50clj/s

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.
sourceraw docstring

gamutclj/s

(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.
sourceraw docstring

hsl->srgbclj/s

(hsl->srgb [h s l])

The HSL hsl as sRGB.

The HSL `hsl` as sRGB.
sourceraw docstring

hueclj/s

(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.
sourceraw docstring

hue-indexclj/s

(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.
sourceraw docstring

hwb->srgbclj/s

(hwb->srgb [h w b])

The HWB hwb as sRGB.

The HWB `hwb` as sRGB.
sourceraw docstring

lab->xyzclj/s

(lab->xyz [l a b])

The CIE Lab lab as XYZ D50.

The CIE Lab `lab` as XYZ D50.
sourceraw docstring

lineageclj/s

(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.
sourceraw docstring

linear->prophotoclj/s

(linear->prophoto x)

The channel x of linear light as ProPhoto RGB.

The channel `x` of linear light as ProPhoto RGB.
sourceraw docstring

linear->srgbclj/s

(linear->srgb x)

The channel x of linear light as sRGB.

The channel `x` of linear light as sRGB.
sourceraw docstring

lms->oklabclj/s

The matrix from the cube roots of LMS to Oklab.

The matrix from the cube roots of LMS to Oklab.
sourceraw docstring

lms->xyzclj/s

The matrix from the LMS of Oklab to XYZ D65.

The matrix from the LMS of Oklab to XYZ D65.
sourceraw docstring

multiplyclj/s

(multiply m v)

The 3×3 matrix m times the vector v.

The 3×3 matrix `m` times the vector `v`.
sourceraw docstring

oklab->lmsclj/s

The matrix from Oklab to the cube roots of LMS.

The matrix from Oklab to the cube roots of LMS.
sourceraw docstring

polarclj/s

(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.
sourceraw docstring

powerclj/s

(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.
sourceraw docstring

prophoto->linearclj/s

(prophoto->linear x)

The channel x of ProPhoto RGB as linear light.

The channel `x` of ProPhoto RGB as linear light.
sourceraw docstring

rgb-hueclj/s

(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.
sourceraw docstring

rgb-spaceclj/s

(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.
sourceraw docstring

signedclj/s

(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.
sourceraw docstring

spaceclj/s

(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.
sourceraw docstring

spacesclj/s

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.
sourceraw docstring

srgb->hslclj/s

(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.
sourceraw docstring

srgb->hwbclj/s

(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.
sourceraw docstring

srgb->linearclj/s

(srgb->linear x)

The channel x of sRGB as linear light.

The channel `x` of sRGB as linear light.
sourceraw docstring

xyz->labclj/s

(xyz->lab xyz)

The XYZ D50 xyz as CIE Lab.

The XYZ D50 `xyz` as CIE Lab.
sourceraw docstring

xyz->lmsclj/s

The matrix from XYZ D65 to the LMS of Oklab.

The matrix from XYZ D65 to the LMS of Oklab.
sourceraw docstring

xyz-spaceclj/s

(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.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close