(->color r g b)(->color r g b a)(->color r g b a options)Create a Color record, truncating RGB channels by default. The five-argument form accepts {:full-precision? true} to keep fractions.
Create a Color record, truncating RGB channels by default.
The five-argument form accepts {:full-precision? true} to keep fractions.(->css color)(->css color options)Export a color as CSS rgba(), preserving fractional channels by default. Pass :decimal-places (0-15) or :significant-digits (1-17) to round only this output. Passing both throws, as with round-coords. :decimal-places rounds the RGB channels; alpha keeps at least 3 places, so whole-number channels do not change the opacity.
Export a color as CSS rgba(), preserving fractional channels by default. Pass :decimal-places (0-15) or :significant-digits (1-17) to round only this output. Passing both throws, as with round-coords. :decimal-places rounds the RGB channels; alpha keeps at least 3 places, so whole-number channels do not change the opacity.
(->name color)Find closest color name for a color
Find closest color name for a color
(->rgb color)Convert a color to an RGB vector, preserving fractional channels.
Convert a color to an RGB vector, preserving fractional channels.
(->rgba color)Convert a color to an RGBA vector, preserving fractional channels.
Convert a color to an RGBA vector, preserving fractional channels.
(accessible-theme base-color)(accessible-theme base-color options)Generate WCAG-aware design tokens from a single brand color.
Options:
:mode :light or :dark (default :light):level :aa, :aa-large, or :aaa (default :aa)Throws for any other mode or level.
Returns a map of hex color tokens for app UIs. Each :on-* token is a
foreground color for the token it is named after.
:on-background, :on-surface and :on-muted always meet the requested
level: those surfaces are generated, and are chosen so that they can.
:primary is the brand color as given, and :secondary and :accent
are hue rotations of it. Their :on-* tokens meet :aa and :aa-large
for every color. No text color reaches :aaa (7:1) on a mid-tone
background, one with a relative luminance between about 0.1 and 0.3; for
those the :on-* token is black or white, whichever has more contrast.
Check a pair with accessible? when you need the guarantee.
Generate WCAG-aware design tokens from a single brand color. Options: - `:mode` `:light` or `:dark` (default `:light`) - `:level` `:aa`, `:aa-large`, or `:aaa` (default `:aa`) Throws for any other mode or level. Returns a map of hex color tokens for app UIs. Each `:on-*` token is a foreground color for the token it is named after. `:on-background`, `:on-surface` and `:on-muted` always meet the requested level: those surfaces are generated, and are chosen so that they can. `:primary` is the brand color as given, and `:secondary` and `:accent` are hue rotations of it. Their `:on-*` tokens meet `:aa` and `:aa-large` for every color. No text color reaches `:aaa` (7:1) on a mid-tone background, one with a relative luminance between about 0.1 and 0.3; for those the `:on-*` token is black or white, whichever has more contrast. Check a pair with `accessible?` when you need the guarantee.
(accessible? color1 color2)(accessible? color1 color2 level)Check if two colors meet a WCAG contrast level. level is :aa (4.5, the default), :aa-large (3) or :aaa (7); any other level throws. Compares the unrounded contrast ratio, so a pair at 4.4999 fails :aa even though contrast-ratio displays 4.5.
Check if two colors meet a WCAG contrast level. level is :aa (4.5, the default), :aa-large (3) or :aaa (7); any other level throws. Compares the unrounded contrast ratio, so a pair at 4.4999 fails :aa even though contrast-ratio displays 4.5.
(adjust-hue color degrees)Adjust the hue of a color by degrees
Adjust the hue of a color by degrees
(alpha-blend base-color overlay-color)(alpha-blend base-color overlay-color options)Blend two colors with alpha compositing (overlay on top of base). Vectors keep fractional channels. Hex and Color results quantize once to 8 bits. Translucent strings use CSS rgba(), rounded to 3 decimal places; options may contain :decimal-places or :significant-digits to choose another precision.
Blend two colors with alpha compositing (overlay on top of base). Vectors keep fractional channels. Hex and Color results quantize once to 8 bits. Translucent strings use CSS rgba(), rounded to 3 decimal places; options may contain :decimal-places or :significant-digits to choose another precision.
(analogous color)(analogous color count)(analogous color count angle)Generate analogous colors
Generate analogous colors
(blend-multiply base-color overlay-color)Blend two colors using multiply mode (darkens)
Blend two colors using multiply mode (darkens)
(blend-overlay base-color overlay-color)Blend two colors using overlay mode (combines multiply and screen)
Blend two colors using overlay mode (combines multiply and screen)
(blend-screen base-color overlay-color)Blend two colors using screen mode (lightens)
Blend two colors using screen mode (lightens)
(brightness color)Calculate perceived brightness of a color (0-255)
Calculate perceived brightness of a color (0-255)
(clamp value min-val max-val)Clamp a value between min and max
Clamp a value between min and max
(clamp-rgb rgb)Clamp each channel of an RGB vector [r g b] to the 0 to 255 range and keep fractions. Use it on computed channels, such as oklab->rgb output, before passing them to ->hex or color, which reject values outside that range.
Clamping an out-of-gamut color changes its hue and lightness. It does not find the closest in-gamut color.
Clamp each channel of an RGB vector [r g b] to the 0 to 255 range and keep fractions. Use it on computed channels, such as oklab->rgb output, before passing them to ->hex or color, which reject values outside that range. Clamping an out-of-gamut color changes its hue and lightness. It does not find the closest in-gamut color.
(color input)(color input options)(color r g b)(color r g b a)Create a Color record from various input formats.
Usage:
(color 255 0 0) ; RGB values
(color 255 0 0 0.8) ; RGBA values
(color "#ff0000") ; Hex string
(color [255 0 0]) ; RGB vector
(color [255 0 0 0.8]) ; RGBA vector
(color (color 255 0 0)) ; From another Color record
(color [10.7 20.2 30.9] {:full-precision? true}) ; Keep RGB fractions
Create a Color record from various input formats.
Usage:
(color 255 0 0) ; RGB values
(color 255 0 0 0.8) ; RGBA values
(color "#ff0000") ; Hex string
(color [255 0 0]) ; RGB vector
(color [255 0 0 0.8]) ; RGBA vector
(color (color 255 0 0)) ; From another Color record
(color [10.7 20.2 30.9] {:full-precision? true}) ; Keep RGB fractions(color-distance color1 color2)Calculate Euclidean distance between two colors in RGB space
Calculate Euclidean distance between two colors in RGB space
(color-from-hex hex-str)Create a Color record from hex string
Create a Color record from hex string
(color-from-hsl hsl-vec)Create a Color record from HSL vector
Create a Color record from HSL vector
(color-from-hsv hsv-vec)Create a Color record from HSV vector
Create a Color record from HSV vector
(color-from-rgb rgb-vec)Create a Color record from RGB vector
Create a Color record from RGB vector
(color-from-rgba rgba-vec)Create a Color record from RGBA vector
Create a Color record from RGBA vector
Map of lowercase CSS color names to hex strings, such as "red" to "#ff0000".
Map of lowercase CSS color names to hex strings, such as "red" to "#ff0000".
(color? x)Check if value is a Color record
Check if value is a Color record
(complementary color)Get the complementary color
Get the complementary color
(contrast-ratio color1 color2)Calculate the WCAG contrast ratio between two colors, from 1 to 21. Rounds to 2 decimal places for display. accessible? and the other threshold checks compare the unrounded ratio.
Calculate the WCAG contrast ratio between two colors, from 1 to 21. Rounds to 2 decimal places for display. accessible? and the other threshold checks compare the unrounded ratio.
(cool? color)Check if a color is cool (blue/green/purple family)
Check if a color is cool (blue/green/purple family)
(darken color amount)Darken a color by a percentage (0-1)
Darken a color by a percentage (0-1)
(delta-e color1 color2)Calculate perceptual color difference using CIE76 Delta E formula. Returns a value where < 1.0 is imperceptible, 1-2 is barely perceptible, 2-10 is noticeable, > 10 is very different
Calculate perceptual color difference using CIE76 Delta E formula. Returns a value where < 1.0 is imperceptible, 1-2 is barely perceptible, 2-10 is noticeable, > 10 is very different
(desaturate color amount)Decrease saturation of a color by a percentage (0-1)
Decrease saturation of a color by a percentage (0-1)
(find-accessible-color background target-color)(find-accessible-color background target-color level)Find the variant of target-color nearest to it in lightness that meets
a WCAG contrast level against background.
Keeps the hue and saturation of the target and tries each whole HSL lightness from 0 to 100, nearest the target's own lightness first. When a darker and a lighter variant are equally near, the darker one is tried first.
Returns the target itself when it already meets the level, and nil when no lightness does. No color reaches :aaa on a mid-tone background.
level is :aa (4.5, the default), :aa-large (3) or :aaa (7). Returns a hex string for string input and an RGB vector otherwise.
Find the variant of `target-color` nearest to it in lightness that meets a WCAG contrast level against `background`. Keeps the hue and saturation of the target and tries each whole HSL lightness from 0 to 100, nearest the target's own lightness first. When a darker and a lighter variant are equally near, the darker one is tried first. Returns the target itself when it already meets the level, and nil when no lightness does. No color reaches :aaa on a mid-tone background. level is :aa (4.5, the default), :aa-large (3) or :aaa (7). Returns a hex string for string input and an RGB vector otherwise.
(generate-palette strategy base-color)(generate-palette strategy base-color options)Generate a color palette using various strategies
Generate a color palette using various strategies
(get-contrast-text background-color)(get-contrast-text background-color level)Pick black or white text for a background. Returns a hex string.
Returns white when white meets the level on the background, black when only black does, and whichever has more contrast when neither does. White comes first because white text on a mid-tone brand color is the usual design choice. Material UI and Bootstrap use the same rule.
level is :aa (4.5:1, the default), :aa-large (3:1) or :aaa (7:1), as for accessible?. Pass :aa-large when the text is large, such as a heading: it keeps white on mid-tones where :aa needs black.
(get-contrast-text "#3498db") ;=> "#000000", at 6.66:1 (get-contrast-text "#3498db" :aa-large) ;=> "#ffffff", at 3.15:1
Pick black or white text for a background. Returns a hex string. Returns white when white meets the level on the background, black when only black does, and whichever has more contrast when neither does. White comes first because white text on a mid-tone brand color is the usual design choice. Material UI and Bootstrap use the same rule. level is :aa (4.5:1, the default), :aa-large (3:1) or :aaa (7:1), as for accessible?. Pass :aa-large when the text is large, such as a heading: it keeps white on mid-tones where :aa needs black. (get-contrast-text "#3498db") ;=> "#000000", at 6.66:1 (get-contrast-text "#3498db" :aa-large) ;=> "#ffffff", at 3.15:1
(gradient colors steps)(gradient colors steps color-space)Generate a gradient with n steps between colors
Generate a gradient with n steps between colors
(grayscale color)Convert a color to grayscale
Convert a color to grayscale
(hex->name hex)Find closest color name for a hex color (approximate)
Find closest color name for a hex color (approximate)
(hex->rgb hex)Convert hex color to RGB vector
Convert hex color to RGB vector
(hex->rgba hex)(hex->rgba hex alpha)Convert hex color to RGBA vector with optional alpha
Convert hex color to RGBA vector with optional alpha
(hsl->rgb hsl)(hsl->rgb hsl options)Convert HSL to RGB, rounded to 8-bit channels by default. Pass {:full-precision? true} to preserve fractional channels.
Convert HSL to RGB, rounded to 8-bit channels by default.
Pass {:full-precision? true} to preserve fractional channels.(hsv->rgb hsv)(hsv->rgb hsv options)Convert HSV to RGB, rounded to 8-bit channels by default. Pass {:full-precision? true} to preserve fractional channels.
Convert HSV to RGB, rounded to 8-bit channels by default.
Pass {:full-precision? true} to preserve fractional channels.(in-gamut? oklab)Check whether Oklab coordinates [l a b] fall inside the sRGB gamut, so that oklab->rgb returns every channel between 0 and 255. Allows a small tolerance for float error, so colors converted from valid RGB stay in gamut.
Check whether Oklab coordinates [l a b] fall inside the sRGB gamut, so that oklab->rgb returns every channel between 0 and 255. Allows a small tolerance for float error, so colors converted from valid RGB stay in gamut.
(interpolate colors position)(interpolate colors position color-space)Interpolate between multiple colors at given position (0-1). Can use different color spaces: :rgb (default), :hsl, or :hsv. Working coordinates and vector results keep full precision. Hex and Color results quantize once to 8-bit channels.
Interpolate between multiple colors at given position (0-1). Can use different color spaces: :rgb (default), :hsl, or :hsv. Working coordinates and vector results keep full precision. Hex and Color results quantize once to 8-bit channels.
(kelvin->color kelvin)Convert color temperature in Kelvin to Color record
Convert color temperature in Kelvin to Color record
(kelvin->hex kelvin)Convert color temperature in Kelvin to hex color
Convert color temperature in Kelvin to hex color
(kelvin->rgb kelvin)Convert color temperature in Kelvin to RGB. Valid range: 1000K - 40000K. Based on Tanner Helland's algorithm.
Convert color temperature in Kelvin to RGB. Valid range: 1000K - 40000K. Based on Tanner Helland's algorithm.
(lighten color amount)Lighten a color by a percentage (0-1)
Lighten a color by a percentage (0-1)
(luminance color)Calculate relative luminance of a color
Calculate relative luminance of a color
(mix color1 color2)(mix color1 color2 ratio)Mix two colors with optional ratio (0-1, default 0.5). Vector results keep fractional channels; hex and Color results quantize once to the nearest 8-bit channel.
Mix two colors with optional ratio (0-1, default 0.5). Vector results keep fractional channels; hex and Color results quantize once to the nearest 8-bit channel.
(monochromatic color)(monochromatic color count)Generate a monochromatic palette: the hue of color at lightness from
20 to 80, dark to light. Saturation follows the base color, from its
own for the darkest step down to three quarters of it for the lightest,
so a gray gives grays and a muted color a muted palette.
Generate a monochromatic palette: the hue of `color` at lightness from 20 to 80, dark to light. Saturation follows the base color, from its own for the darkest step down to three quarters of it for the lightest, so a gray gives grays and a muted color a muted palette.
(muted? color)(muted? color threshold)Check if a color is muted (low saturation)
Check if a color is muted (low saturation)
(name->hex color-name)Convert color name to hex
Convert color name to hex
(normalize-css-color-string css-str)Normalize CSS color string by removing extra spaces and standardizing separators
Normalize CSS color string by removing extra spaces and standardizing separators
(normalize-hex hex)Normalize hex color to 6 characters with #
Normalize hex color to 6 characters with #
(oklab->hex oklab)Convert Oklab coordinates [l a b] to a hex string. Clamps channels outside the sRGB gamut with clamp-rgb, then rounds each to 8 bits.
Convert Oklab coordinates [l a b] to a hex string. Clamps channels outside the sRGB gamut with clamp-rgb, then rounds each to 8 bits.
(oklab->oklch oklab)Convert Oklab coordinates [l a b] to OKLCh [l c h], the polar form:
l is unchanged, c is chroma (0 and up) and h is hue in degrees, from 0
up to 360. Colors with chroma below 1e-6 get hue 0; CSS calls that hue
none. Returns unrounded values.
Convert Oklab coordinates [l a b] to OKLCh [l c h], the polar form: l is unchanged, c is chroma (0 and up) and h is hue in degrees, from 0 up to 360. Colors with chroma below 1e-6 get hue 0; CSS calls that hue `none`. Returns unrounded values.
(oklab->rgb oklab)Convert Oklab coordinates [l a b] to an sRGB vector [r g b] on the 0 to 255 scale. The inverse of rgb->oklab.
Returns unrounded floats and does not clamp. Colors outside the sRGB gamut produce channels below 0 or above 255; check with in-gamut?. Use clamp-rgb before ->hex or color. The full-precision option on color preserves fractional channels; its default still truncates them.
The matrices are the exact inverses of the ones rgb->oklab uses, so (oklab->rgb (rgb->oklab rgb)) returns rgb to within float error. Checks the input shape with an assertion precondition.
Convert Oklab coordinates [l a b] to an sRGB vector [r g b] on the 0 to 255 scale. The inverse of rgb->oklab. Returns unrounded floats and does not clamp. Colors outside the sRGB gamut produce channels below 0 or above 255; check with in-gamut?. Use clamp-rgb before ->hex or color. The full-precision option on color preserves fractional channels; its default still truncates them. The matrices are the exact inverses of the ones rgb->oklab uses, so (oklab->rgb (rgb->oklab rgb)) returns rgb to within float error. Checks the input shape with an assertion precondition.
(oklch->hex oklch)Convert OKLCh [l c h] to a hex string, clamping colors outside the sRGB gamut like oklab->hex.
Convert OKLCh [l c h] to a hex string, clamping colors outside the sRGB gamut like oklab->hex.
(oklch->oklab oklch)Convert OKLCh [l c h] to Oklab coordinates [l a b]. Hue is in degrees and wraps, so -30 and 330 give the same color. Chroma must not be negative.
Convert OKLCh [l c h] to Oklab coordinates [l a b]. Hue is in degrees and wraps, so -30 and 330 give the same color. Chroma must not be negative.
(oklch->rgb oklch)Convert OKLCh [l c h] to an sRGB vector on the 0 to 255 scale. Returns unrounded, unclamped channels, like oklab->rgb.
Convert OKLCh [l c h] to an sRGB vector on the 0 to 255 scale. Returns unrounded, unclamped channels, like oklab->rgb.
(parse-css-color-components css-str)Parse CSS rgb() or rgba() string into color component vector.
Takes a CSS color string and normalizes it internally before extracting the color components using regex matching. Handles various formatting variations including different spacing and case.
Args: css-str - A CSS color string in format: - 'rgb(r,g,b)' or 'rgb(r g b)' - 'rgba(r,g,b,a)' or 'rgba(r g b a)' - Case insensitive, flexible whitespace
Returns:
Examples: (parse-css-color-components "rgb(255,0,0)") => [255 0 0] (parse-css-color-components "RGB( 255 , 0 , 0 )") => [255 0 0] (parse-css-color-components "rgba(255,0,0,0.5)") => [255 0 0 0.5] (parse-css-color-components "rgb(256,0,0)") => nil (out of range)
Parse CSS rgb() or rgba() string into color component vector.
Takes a CSS color string and normalizes it internally before extracting
the color components using regex matching. Handles various formatting
variations including different spacing and case.
Args:
css-str - A CSS color string in format:
- 'rgb(r,g,b)' or 'rgb(r g b)'
- 'rgba(r,g,b,a)' or 'rgba(r g b a)'
- Case insensitive, flexible whitespace
Returns:
- For rgb(): [r g b] where r, g, b are numbers 0-255
- For rgba(): [r g b a] with RGB numbers 0-255 and alpha 0.0-1.0
- nil if the string doesn't match expected format or values are out of range
Examples:
(parse-css-color-components "rgb(255,0,0)") => [255 0 0]
(parse-css-color-components "RGB( 255 , 0 , 0 )") => [255 0 0]
(parse-css-color-components "rgba(255,0,0,0.5)") => [255 0 0 0.5]
(parse-css-color-components "rgb(256,0,0)") => nil (out of range)(parse-css-rgb css-str)Parse CSS rgb() string to RGB vector. Throws ex-info for a channel above 255, which valid-css-rgb? accepts.
Parse CSS rgb() string to RGB vector. Throws ex-info for a channel above 255, which valid-css-rgb? accepts.
(parse-css-rgba css-str)Parse CSS rgba() string to RGBA vector. Throws ex-info for a channel above 255, which valid-css-rgba? accepts.
Parse CSS rgba() string to RGBA vector. Throws ex-info for a channel above 255, which valid-css-rgba? accepts.
(parse-int s)(parse-int s radix)Parse the string s as an integer in radix (10 by default). Throws on
invalid input on the JVM and returns NaN in ClojureScript.
Parse the string `s` as an integer in `radix` (10 by default). Throws on invalid input on the JVM and returns NaN in ClojureScript.
(perceptually-similar? color1 color2)(perceptually-similar? color1 color2 threshold)Check if two colors are perceptually similar using Delta E. Default threshold of 2.3 is the JND (Just Noticeable Difference)
Check if two colors are perceptually similar using Delta E. Default threshold of 2.3 is the JND (Just Noticeable Difference)
(rgb->hex rgb)Convert RGB vector to hex string
Convert RGB vector to hex string
(rgb->hsl rgb)(rgb->hsl rgb options)Convert RGB to HSL, rounded to whole coordinates by default. Pass {:full-precision? true} to preserve the computed doubles.
Convert RGB to HSL, rounded to whole coordinates by default.
Pass {:full-precision? true} to preserve the computed doubles.(rgb->hsv rgb)(rgb->hsv rgb options)Convert RGB to HSV, rounded to whole coordinates by default. Pass {:full-precision? true} to preserve the computed doubles.
Convert RGB to HSV, rounded to whole coordinates by default.
Pass {:full-precision? true} to preserve the computed doubles.(rgb->kelvin rgb)Approximate the correlated color temperature of an sRGB color in Kelvin.
Converts to CIE 1931 xy chromaticity and applies McCamy's formula, which is accurate to a few tens of kelvin from about 2000 K to 12500 K. Returns nil for black, for colors more than 0.05 from the black-body curve in CIE 1960 uv (Duv), and for results outside 1000 K to 40000 K. Saturated colors such as pure red have no meaningful temperature.
Approximate the correlated color temperature of an sRGB color in Kelvin. Converts to CIE 1931 xy chromaticity and applies McCamy's formula, which is accurate to a few tens of kelvin from about 2000 K to 12500 K. Returns nil for black, for colors more than 0.05 from the black-body curve in CIE 1960 uv (Duv), and for results outside 1000 K to 40000 K. Saturated colors such as pure red have no meaningful temperature.
(rgb->lab rgb)Convert RGB to LAB color space (CIE Lab*), relative to the D65 white point. CSS lab() uses D50, so these are not CSS values.
Convert RGB to LAB color space (CIE L*a*b*), relative to the D65 white point. CSS lab() uses D50, so these are not CSS values.
(rgb->oklab rgb)Convert an sRGB vector [r g b], with channels from 0 to 255, to Oklab. Returns [l a b] without rounding: l uses a 0-1 lightness scale; a runs from green (negative) to red (positive), and b from blue (negative) to yellow (positive). Linearizes sRGB before conversion. Checks valid-rgb? with an assertion precondition. Use ->rgb first for hex strings, CSS strings, or Color records. Formula taken from https://bottosson.github.io/posts/oklab/.
Convert an sRGB vector [r g b], with channels from 0 to 255, to Oklab. Returns [l a b] without rounding: l uses a 0-1 lightness scale; a runs from green (negative) to red (positive), and b from blue (negative) to yellow (positive). Linearizes sRGB before conversion. Checks valid-rgb? with an assertion precondition. Use ->rgb first for hex strings, CSS strings, or Color records. Formula taken from https://bottosson.github.io/posts/oklab/.
(rgb->oklch rgb)Convert an sRGB vector [r g b], with channels from 0 to 255, to OKLCh [l c h]. See rgb->oklab and oklab->oklch.
Convert an sRGB vector [r g b], with channels from 0 to 255, to OKLCh [l c h]. See rgb->oklab and oklab->oklch.
(rgba->hex rgba)Convert RGBA vector to hex string (ignoring alpha)
Convert RGBA vector to hex string (ignoring alpha)
(round n)(round n decimals)Round a number to specified decimal places. Returns a 32-bit integer at 0 places when it fits, and a double otherwise. Large values that have no fractional digit at the requested precision come back unchanged.
Round a number to specified decimal places. Returns a 32-bit integer at 0 places when it fits, and a double otherwise. Large values that have no fractional digit at the requested precision come back unchanged.
(round-coords coords options)Round each coordinate in coords for display and return a vector.
Conversions such as rgb->oklab return full precision; round only the
values you show or export.
options takes exactly one of:
Returns doubles, even at 0 decimal places; use round-int for integers. Ties round up, toward positive infinity, as Math/round does. Rounding works on the binary double, so 1.005 rounds to 1.0 at 2 places: the stored value is slightly below 1.005. Results match on the JVM and in JavaScript.
NaN and infinite values pass through unchanged. Throws ex-info for invalid options or non-numeric coordinates.
Round each coordinate in `coords` for display and return a vector. Conversions such as rgb->oklab return full precision; round only the values you show or export. options takes exactly one of: - :decimal-places, an integer from 0 to 15 - :significant-digits, an integer from 1 to 17 Returns doubles, even at 0 decimal places; use round-int for integers. Ties round up, toward positive infinity, as Math/round does. Rounding works on the binary double, so 1.005 rounds to 1.0 at 2 places: the stored value is slightly below 1.005. Results match on the JVM and in JavaScript. NaN and infinite values pass through unchanged. Throws ex-info for invalid options or non-numeric coordinates.
(round-int n)Round a number to the nearest integer. Same as (round n 0): returns a
32-bit integer when it fits and a double otherwise. Ties round toward
positive infinity.
Round a number to the nearest integer. Same as `(round n 0)`: returns a 32-bit integer when it fits and a double otherwise. Ties round toward positive infinity.
(saturate color amount)Increase saturation of a color by a percentage (0-1)
Increase saturation of a color by a percentage (0-1)
(shade color amount)Create a shade by mixing color with black (darkens while preserving hue)
Create a shade by mixing color with black (darkens while preserving hue)
(shades color)(shades color count)Generate a series of shades (color mixed with black)
Generate a series of shades (color mixed with black)
(similar? color1 color2)(similar? color1 color2 threshold)Check if two colors are similar within a threshold
Check if two colors are similar within a threshold
(split-complementary color)(split-complementary color angle)Get split-complementary colors
Get split-complementary colors
(temperature color)Get color temperature as a keyword
Get color temperature as a keyword
(tetradic color)Get tetradic colors (three colors that form a square on the color wheel)
Get tetradic colors (three colors that form a square on the color wheel)
(theme->css-vars theme)(theme->css-vars theme options)Convert an accessible-theme map to CSS custom properties.
By default variables use the --ct- prefix. Pass :prefix to override it.
Convert an `accessible-theme` map to CSS custom properties. By default variables use the `--ct-` prefix. Pass `:prefix` to override it.
(tint color amount)Create a tint by mixing color with white (lightens while preserving hue)
Create a tint by mixing color with white (lightens while preserving hue)
(tints color)(tints color count)Generate a series of tints (color mixed with white)
Generate a series of tints (color mixed with white)
(tone color amount)Create a tone by mixing color with gray (reduces saturation)
Create a tone by mixing color with gray (reduces saturation)
(tones color)(tones color count)Generate a series of tones (color mixed with gray)
Generate a series of tones (color mixed with gray)
(triadic color)Get triadic colors (two colors that form a triangle on the color wheel)
Get triadic colors (two colors that form a triangle on the color wheel)
(valid-css-rgb? css-str)Check if string is a CSS rgb() color in a supported format. Checks the format only: "rgb(300,0,0)" is valid, and parse-css-color-components returns nil for it.
Check if string is a CSS rgb() color in a supported format. Checks the format only: "rgb(300,0,0)" is valid, and parse-css-color-components returns nil for it.
(valid-css-rgba? css-str)Check if string is a CSS rgba() color in a supported format, with an alpha from 0 to 1. Does not check the channels: "rgba(300,0,0,0.5)" is valid, and parse-css-color-components returns nil for it.
Check if string is a CSS rgba() color in a supported format, with an alpha from 0 to 1. Does not check the channels: "rgba(300,0,0,0.5)" is valid, and parse-css-color-components returns nil for it.
(valid-hex? hex)Check if string is a valid 3- or 6-digit hex color, with or without a leading #. Returns true or false.
Check if string is a valid 3- or 6-digit hex color, with or without a leading #. Returns true or false.
(valid-hsl? hsl)Check if vector is a valid HSL color
Check if vector is a valid HSL color
(valid-hsv? hsv)Check if vector is a valid HSV color
Check if vector is a valid HSV color
(valid-rgb? rgb)Check if vector is a valid RGB color
Check if vector is a valid RGB color
(valid-rgba? rgba)Check if vector is a valid RGBA color
Check if vector is a valid RGBA color
(vibrant? color)(vibrant? color threshold)Check if a color is vibrant (high saturation)
Check if a color is vibrant (high saturation)
(warm? color)Check if a color is warm (red/orange/yellow family)
Check if a color is warm (red/orange/yellow family)
(with-alpha color alpha)(with-alpha color alpha options)Set alpha channel of a color. For translucent string output, options accepts :decimal-places or :significant-digits as with ->css.
Set alpha channel of a color. For translucent string output, options accepts :decimal-places or :significant-digits as with ->css.
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 |