Liking cljdoc? Tell your friends :D

jon.color-tools


->colorclj/s

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

->hexclj/s

(->hex color)

Convert Color to hex string

Convert Color to hex string
sourceraw docstring

->hslclj/s

(->hsl color)

Convert Color to HSL vector

Convert Color to HSL vector
sourceraw docstring

->hsvclj/s

(->hsv color)

Convert Color to HSV vector

Convert Color to HSV vector
sourceraw docstring

->nameclj/s

(->name color)

Find closest color name for a color

Find closest color name for a color
sourceraw docstring

->rgbclj/s

(->rgb color)

Convert a color to RGB vector

Convert a color to RGB vector
sourceraw docstring

->rgbaclj/s

(->rgba color)

Convert Color to RGBA vector

Convert Color to RGBA vector
sourceraw docstring

accessible?clj/s

(accessible? color1 color2 & [level])

Check if two colors meet WCAG AA accessibility standards

Check if two colors meet WCAG AA accessibility standards
sourceraw docstring

adjust-hueclj/s

(adjust-hue color degrees)

Adjust the hue of a color by degrees

Adjust the hue of a color by degrees
sourceraw docstring

analogousclj/s

(analogous color & [count angle])

Generate analogous colors

Generate analogous colors
sourceraw docstring

brightnessclj/s

(brightness color)

Calculate perceived brightness of a color (0-255)

Calculate perceived brightness of a color (0-255)
sourceraw docstring

clampclj/s

(clamp value min-val max-val)

Clamp a value between min and max

Clamp a value between min and max
sourceraw docstring

colorclj/s

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

color-distanceclj/s

(color-distance color1 color2)

Calculate Euclidean distance between two colors in RGB space

Calculate Euclidean distance between two colors in RGB space
sourceraw docstring

color-from-hexclj/s

(color-from-hex hex-str)

Create a Color record from hex string

Create a Color record from hex string
sourceraw docstring

color-from-hslclj/s

(color-from-hsl hsl-vec)

Create a Color record from HSL vector

Create a Color record from HSL vector
sourceraw docstring

color-from-hsvclj/s

(color-from-hsv hsv-vec)

Create a Color record from HSV vector

Create a Color record from HSV vector
sourceraw docstring

color-from-rgbclj/s

(color-from-rgb rgb-vec)

Create a Color record from RGB vector

Create a Color record from RGB vector
sourceraw docstring

color-from-rgbaclj/s

(color-from-rgba rgba-vec)

Create a Color record from RGBA vector

Create a Color record from RGBA vector
sourceraw docstring

color-namesclj/s

source

color?clj/s

(color? x)

Check if value is a Color record

Check if value is a Color record
sourceraw docstring

complementaryclj/s

(complementary color)

Get the complementary color

Get the complementary color
sourceraw docstring

contrast-ratioclj/s

(contrast-ratio color1 color2)

Calculate contrast ratio between two colors

Calculate contrast ratio between two colors
sourceraw docstring

cool?clj/s

(cool? color)

Check if a color is cool (blue/green/purple family)

Check if a color is cool (blue/green/purple family)
sourceraw docstring

dark?clj/s

(dark? color)

Check if a color is dark

Check if a color is dark
sourceraw docstring

darkenclj/s

(darken color amount)

Darken a color by a percentage (0-1)

Darken a color by a percentage (0-1)
sourceraw docstring

desaturateclj/s

(desaturate color amount)

Decrease saturation of a color by a percentage (0-1)

Decrease saturation of a color by a percentage (0-1)
sourceraw docstring

find-accessible-colorclj/s

(find-accessible-color background target-color & [level])

Find an accessible color by adjusting lightness

Find an accessible color by adjusting lightness
sourceraw docstring

generate-paletteclj/s

(generate-palette strategy base-color & [options])

Generate a color palette using various strategies

Generate a color palette using various strategies
sourceraw docstring

get-contrast-textclj/s

(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:

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

grayscaleclj/s

(grayscale color)

Convert a color to grayscale

Convert a color to grayscale
sourceraw docstring

hex->hslclj/s

(hex->hsl hex)

Convert hex to HSL

Convert hex to HSL
sourceraw docstring

hex->nameclj/s

(hex->name hex)

Find closest color name for a hex color (approximate)

Find closest color name for a hex color (approximate)
sourceraw docstring

hex->rgbclj/s

(hex->rgb hex)

Convert hex color to RGB vector

Convert hex color to RGB vector
sourceraw docstring

hex->rgbaclj/s

(hex->rgba hex & [alpha])

Convert hex color to RGBA vector with optional alpha

Convert hex color to RGBA vector with optional alpha
sourceraw docstring

hsl->hexclj/s

(hsl->hex hsl)

Convert HSL to hex

Convert HSL to hex
sourceraw docstring

hsl->rgbclj/s

(hsl->rgb hsl)

Convert HSL to RGB

Convert HSL to RGB
sourceraw docstring

hsv->rgbclj/s

(hsv->rgb hsv)

Convert HSV to RGB

Convert HSV to RGB
sourceraw docstring

invertclj/s

(invert color)

Invert a color

Invert a color
sourceraw docstring

light?clj/s

(light? color)

Check if a color is light

Check if a color is light
sourceraw docstring

lightenclj/s

(lighten color amount)

Lighten a color by a percentage (0-1)

Lighten a color by a percentage (0-1)
sourceraw docstring

luminanceclj/s

(luminance color)

Calculate relative luminance of a color

Calculate relative luminance of a color
sourceraw docstring

mixclj/s

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

monochromaticclj/s

(monochromatic color & [count])

Generate monochromatic palette by varying lightness and saturation

Generate monochromatic palette by varying lightness and saturation
sourceraw docstring

muted?clj/s

(muted? color & [threshold])

Check if a color is muted (low saturation)

Check if a color is muted (low saturation)
sourceraw docstring

name->hexclj/s

(name->hex color-name)

Convert color name to hex

Convert color name to hex
sourceraw docstring

normalize-css-color-stringclj/s

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

normalize-hexclj/s

(normalize-hex hex)

Normalize hex color to 6 characters with #

Normalize hex color to 6 characters with #
sourceraw docstring

parse-css-color-componentsclj/s

(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:

  • 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() 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)
sourceraw docstring

parse-css-rgbclj/s

(parse-css-rgb css-str)

Parse CSS rgb() string to RGB vector

Parse CSS rgb() string to RGB vector
sourceraw docstring

parse-css-rgbaclj/s

(parse-css-rgba css-str)

Parse CSS rgba() string to RGBA vector

Parse CSS rgba() string to RGBA vector
sourceraw docstring

parse-intclj/s

(parse-int s & [radix])
source

random-colorclj/s

(random-color)

Generate a random color

Generate a random color
sourceraw docstring

rgb->hexclj/s

(rgb->hex rgb)

Convert RGB vector to hex string

Convert RGB vector to hex string
sourceraw docstring

rgb->hslclj/s

(rgb->hsl rgb)

Convert RGB to HSL

Convert RGB to HSL
sourceraw docstring

rgb->hsvclj/s

(rgb->hsv rgb)

Convert RGB to HSV

Convert RGB to HSV
sourceraw docstring

rgba->hexclj/s

(rgba->hex rgba)

Convert RGBA vector to hex string (ignoring alpha)

Convert RGBA vector to hex string (ignoring alpha)
sourceraw docstring

roundclj/s

(round n & [decimals])

Round a number to specified decimal places

Round a number to specified decimal places
sourceraw docstring

round-intclj/s

(round-int n)
source

saturateclj/s

(saturate color amount)

Increase saturation of a color by a percentage (0-1)

Increase saturation of a color by a percentage (0-1)
sourceraw docstring

similar?clj/s

(similar? color1 color2 & [threshold])

Check if two colors are similar within a threshold

Check if two colors are similar within a threshold
sourceraw docstring

split-complementaryclj/s

(split-complementary color & [angle])

Get split-complementary colors

Get split-complementary colors
sourceraw docstring

temperatureclj/s

(temperature color)

Get color temperature as a keyword

Get color temperature as a keyword
sourceraw docstring

tetradicclj/s

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

triadicclj/s

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

valid-css-rgb?clj/s

(valid-css-rgb? css-str)

Check if string is a valid CSS rgb() color

Check if string is a valid CSS rgb() color
sourceraw docstring

valid-css-rgba?clj/s

(valid-css-rgba? css-str)

Check if string is a valid CSS rgba() color

Check if string is a valid CSS rgba() color
sourceraw docstring

valid-hex?clj/s

(valid-hex? hex)

Check if string is a valid hex color

Check if string is a valid hex color
sourceraw docstring

valid-hsl?clj/s

(valid-hsl? hsl)

Check if vector is a valid HSL color

Check if vector is a valid HSL color
sourceraw docstring

valid-hsv?clj/s

(valid-hsv? hsv)

Check if vector is a valid HSV color

Check if vector is a valid HSV color
sourceraw docstring

valid-rgb?clj/s

(valid-rgb? rgb)

Check if vector is a valid RGB color

Check if vector is a valid RGB color
sourceraw docstring

valid-rgba?clj/s

(valid-rgba? rgba)

Check if vector is a valid RGBA color

Check if vector is a valid RGBA color
sourceraw docstring

vibrant?clj/s

(vibrant? color & [threshold])

Check if a color is vibrant (high saturation)

Check if a color is vibrant (high saturation)
sourceraw docstring

warm?clj/s

(warm? color)

Check if a color is warm (red/orange/yellow family)

Check if a color is warm (red/orange/yellow family)
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