(->color r g b)(->color r g b a)Create a Color record from RGB values with optional alpha
Create a Color record from RGB values with optional alpha
(->name color)Find closest color name for a color
Find closest color name for a color
(->rgb color)Convert a color to RGB vector
Convert a color to RGB vector
(->rgba color)Convert Color to RGBA vector
Convert Color to RGBA vector
(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)Returns a map of hex color tokens for app UIs, including foreground tokens that meet the requested contrast level against their paired backgrounds.
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`) Returns a map of hex color tokens for app UIs, including foreground tokens that meet the requested contrast level against their paired backgrounds.
(accessible? color1 color2)(accessible? color1 color2 level)Check if two colors meet WCAG AA accessibility standards
Check if two colors meet WCAG AA accessibility standards
(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)Blend two colors with alpha compositing (overlay on top of base)
Blend two colors with alpha compositing (overlay on top of base)
(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
(color input)(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
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-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
(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 contrast ratio between two colors
Calculate contrast ratio between two colors
(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 an accessible color by adjusting lightness
Find an accessible color by adjusting lightness
(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 the best contrast text color (black or white) for a given background color. Uses luminance threshold of 0.35 following accessibility best practices, with fallback to ensure WCAG AA compliance:
Get the best contrast text color (black or white) for a given background color. Uses luminance threshold of 0.35 following accessibility best practices, with fallback to ensure WCAG AA compliance: - Light backgrounds (luminance > 0.35) get black text - Dark backgrounds (luminance ≤ 0.35) get white text - If the primary choice doesn't meet WCAG AA standards, tries the alternative - If neither meets standards, returns the one with better contrast ratio Always returns a hex color string for consistency.
(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
(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
Interpolate between multiple colors at given position (0-1). Can use different color spaces: :rgb (default), :hsl, or :hsv
(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)
Mix two colors with optional ratio (0-1, default 0.5)
(monochromatic color)(monochromatic color count)Generate monochromatic palette by varying lightness and saturation
Generate monochromatic palette by varying lightness and saturation
(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 #
(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 integers 0-255
- For rgba(): [r g b a] where r, g, b are integers 0-255 and a is float 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
Parse CSS rgb() string to RGB vector
(parse-css-rgba css-str)Parse CSS rgba() string to RGBA vector
Parse CSS rgba() string to RGBA vector
(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->kelvin rgb)Approximate the color temperature in Kelvin from RGB. This is an approximation and works best for colors close to the Planckian locus. Returns nil if the color is too far from the black body curve.
Approximate the color temperature in Kelvin from RGB. This is an approximation and works best for colors close to the Planckian locus. Returns nil if the color is too far from the black body curve.
(rgb->lab rgb)Convert RGB to LAB color space (CIE Lab*)
Convert RGB to LAB color space (CIE L*a*b*)
(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
Round a number to specified decimal places
(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 valid CSS rgb() color
Check if string is a valid CSS rgb() color
(valid-css-rgba? css-str)Check if string is a valid CSS rgba() color
Check if string is a valid CSS rgba() color
(valid-hex? hex)Check if string is a valid hex color
Check if string is a valid hex color
(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)Set alpha channel of a color
Set alpha channel of a color
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 |