Liking cljdoc? Tell your friends :D
Clojure only.

clojure2d.color

Color functions.

This namespace contains color manipulation functions which can be divided into following groups:

  • Representation
  • Channel manipulations
  • Conversions
  • Blending
  • Palettes / gradients
  • Distances

Representation

Color can be represented by following types:

  • fastmath Vec4 - this is core type representing 3 color channels and alpha (RGBA). Values are double type from [0-255] range. color, gray creators returns Vec4 representation. To ensure Vec4 use [[to-color]] function.
  • fastmath Vec3 - 3 color channels, assuming alpha set to value of 255.
  • java.awt.Color - Java AWT representation. Creators are awt-color, awt-gray. Use [[to-awt-color]] to convert to this representations.
  • keyword - one of the defined names (see named-colors-list)
  • Integer - packed ARGB value. Example: 0xffaa01.
  • String - CSS ("#ab1122") or 6 chars string containg hexadecimal representation ("ffaa01")
  • any seqable - list, vector containing 2-4 elements. Conversion is done by applying content to color function.
  • nil - returning nil during color conversion.

To create color from individual channel values use color function. To create gray for given intensity call gray.

By default color is treated as RGB with values from ranges [0.0-255.0] inclusive.

Coloured list of all names

Color/ channel manipulations

You can access individual channels by calling on of the following:

  • [[red]] or [[ch0]] - to get first channel value.
  • [[green]] or [[ch1]] - to get second channel value.
  • [[blue]] or [[ch2]] - to get third channel value.
  • [[alpha]] - to get alpha value.
  • [[luma]] - to get luma or brightness (range from 0 (black) to 255 (white)).
  • hue - to get hue value in degrees (range from 0 to 360). Hexagon projection.
  • hue-polar - to get hue from polar transformation.

set-ch0, set-ch1, set-ch2 and set-alpha return new color with respective channel set to new value.

To make color darker/brighter use darken / [[lighten]] functions. Operations are done in Lab color space.

To change saturation call saturate / desaturate. Operations are done in LCH color space.

You can also rely on VectorProto from fastmath library and treat colors as vectors.

Conversions

Color can be converted from RGB to other color space (and back). List of color spaces are listed under colorspaces-list variable. There are two types of conversions:

  • raw - with names to-XXX and from-XXX where XXX is color space name. Every color space has it's own value range for each channel. (comp from-XXX to-XXX) acts almost as identity.
  • normalized - with names to-XXX* and from-XXX* where XXX is color space name. to-XXX* returns values normalized to [0-255] range. from-XXX* expects also channel values in range [0-255].

NOTE: there is no information which color space is used. It's just a matter of your code interpretation.

Color space conversion functions are collected in two maps colorspaces for raw and colorspaces* for normalized functions. Keys are color space names as keyword and values are vectors with to- fn as first and from- fn as second element.

Blending

You can blend two colors (or individual channels) using one of the methods from blends-list. All functions are collected in blends map with names as names and blending function as value.

Palettes / gradients

Links

List of all defined colors and palettes:

Palette

Palette is just sequence of colors.

There are plenty of them predefined or can be generated:

  • colourlovers-palettes contains 500 top palettes in vector from colourlovers website.
  • palette-presets contains 256 Brewer, categorical, veridis, tableau, microsoft palettes as map. See palette-presets-list for names.
  • [[paletton-palette]] function to generate palette of type: :monochromatic, :triad, :tetrad with complementary color for given hue and configuration. See also Paletton website for details.

Gradient

Gradient is continuous functions which accepts value from [0-1] range and returns color. Call gradient, gradient-easing or iq-gradient to create one.

Predefined gradients are collected in gradient-presets map. You can find them cubehelix based and generated from Inigo Quilez settings.

Conversions

To convert palette to gradient call gradient function. You can set interpolation method and colorspace.

To convert gradient to palette call sample function from fastmath library.

Call resample to resample palette to other number of colors. Internally input palette is converted to gradient and sampled back.

To make gradient from two colors you can use also gradient-easing where you interpolate between to colors using one of the easings functions from fastmath.

Linear gradient between colors is defined as lerp function.

Distances

Several functions to calculate distance between colors (euclidean, delta-xxx etc.).

Thi.ng interoperability

Thi.ng RGBA type implements ColorProto. To convert any color to RGBA use to-thing-rgba.

Color functions.

This namespace contains color manipulation functions which can be divided into following groups:

* Representation
* Channel manipulations
* Conversions
* Blending
* Palettes / gradients
* Distances

## Representation

Color can be represented by following types:

* fastmath `Vec4` - this is core type representing 3 color channels and alpha (RGBA). Values are `double` type from `[0-255]` range. [[color]], [[gray]] creators returns `Vec4` representation. To ensure `Vec4` use [[to-color]] function.
* fastmath `Vec3` - 3 color channels, assuming `alpha` set to value of `255`.
* `java.awt.Color` - Java AWT representation. Creators are [[awt-color]], [[awt-gray]]. Use [[to-awt-color]] to convert to this representations.
* `keyword` - one of the defined names (see [[named-colors-list]])
* `Integer` - packed ARGB value. Example: `0xffaa01`.
* `String` - CSS ("#ab1122") or 6 chars string containg hexadecimal representation ("ffaa01")
* any `seqable` - list, vector containing 2-4 elements. Conversion is done by applying content to [[color]] function.
* `nil` - returning `nil` during color conversion.

To create color from individual channel values use [[color]] function. To create gray for given intensity call [[gray]].

By default color is treated as `RGB` with values from ranges `[0.0-255.0]` inclusive.

[Coloured list of all names](../static/colors.html)

## Color/ channel manipulations

You can access individual channels by calling on of the following:

* [[red]] or [[ch0]] - to get first channel value.
* [[green]] or [[ch1]] - to get second channel value.
* [[blue]] or [[ch2]] - to get third channel value.
* [[alpha]] - to get alpha value.
* [[luma]] - to get luma or brightness (range from `0` (black) to `255` (white)).
* [[hue]] - to get hue value in degrees (range from 0 to 360). Hexagon projection.
* [[hue-polar]] - to get hue from polar transformation.

[[set-ch0]], [[set-ch1]], [[set-ch2]] and [[set-alpha]] return new color with respective channel set to new value.

To make color darker/brighter use [[darken]] / [[lighten]] functions. Operations are done in `Lab` color space.

To change saturation call [[saturate]] / [[desaturate]]. Operations are done in `LCH` color space.

You can also rely on `VectorProto` from `fastmath` library and treat colors as vectors.

## Conversions

Color can be converted from RGB to other color space (and back). List of color spaces are listed under [[colorspaces-list]] variable. There are two types of conversions:

* raw - with names `to-XXX` and `from-XXX` where `XXX` is color space name. Every color space has it's own value range for each channel. `(comp from-XXX to-XXX)` acts almost as identity.
* normalized - with names `to-XXX*` and `from-XXX*` where `XXX` is color space name. `to-XXX*` returns values normalized to `[0-255]` range. `from-XXX*` expects also channel values in range `[0-255]`.

NOTE: there is no information which color space is used. It's just a matter of your code interpretation.

Color space conversion functions are collected in two maps [[colorspaces]] for raw and [[colorspaces*]] for normalized functions. Keys are color space names as `keyword` and values are vectors with `to-` fn as first and `from-` fn as second element.

## Blending

You can blend two colors (or individual channels) using one of the methods from [[blends-list]]. All functions are collected in [[blends]] map with names as names and blending function as value.

## Palettes / gradients

### Links

List of all defined colors and palettes:

* [Named palettes](../static/palettes.html)
* [Colourlovers palettes](../static/colourlovers.html)
* [Gradients](../static/gradients.html)

### Palette

Palette is just sequence of colors.

There are plenty of them predefined or can be generated:

* [[colourlovers-palettes]] contains 500 top palettes in vector from [colourlovers](http://www.colourlovers.com/) website.
* [[palette-presets]] contains 256 Brewer, categorical, veridis, tableau, microsoft palettes as map. See [[palette-presets-list]] for names.
* [[paletton-palette]] function to generate palette of type: `:monochromatic`, `:triad`, `:tetrad` with complementary color for given hue and configuration. See also [Paletton](http://paletton.com) website for details.

### Gradient

Gradient is continuous functions which accepts value from `[0-1]` range and returns color. Call [[gradient]], [[gradient-easing]] or [[iq-gradient]] to create one.

Predefined gradients are collected in [[gradient-presets]] map. You can find them `cubehelix` based and generated from [Inigo Quilez](http://iquilezles.org/www/articles/palettes/palettes.htm) settings.

### Conversions

To convert palette to gradient call [[gradient]] function. You can set interpolation method and colorspace.

To convert gradient to palette call `sample` function from fastmath library.

Call [[resample]] to resample palette to other number of colors. Internally input palette is converted to gradient and sampled back.

To make gradient from two colors you can use also [[gradient-easing]] where you interpolate between to colors using one of the easings functions from `fastmath`.

Linear gradient between colors is defined as [[lerp]] function.

## Distances

Several functions to calculate distance between colors (`euclidean`, `delta-xxx` etc.).

## Thi.ng interoperability

Thi.ng `RGBA` type implements [[ColorProto]]. To convert any color to `RGBA` use [[to-thing-rgba]].
raw docstring

*blend-threshold*clj

Some blend functions can be parametrized with threshold value. Default 0.5.

Some blend functions can be parametrized with `threshold` value. Default `0.5`.
sourceraw docstring

averageclj

(average xs)
(average colorspace xs)

Average colors in given colorspace (default: :RGB)

Average colors in given `colorspace` (default: `:RGB`)
sourceraw docstring

awt-colorclj

(awt-color c)
(awt-color c a)
(awt-color r g b)
(awt-color r g b a)

Create java.awt.Color object.

See also color, gray.

Create java.awt.Color object.

See also [[color]], [[gray]].
sourceraw docstring

awt-grayclj

(awt-gray v)
(awt-gray v a)

Create grayscale color based on intensity v. Optional parameter alpha a.

AWT version of gray. See also awt-color

Create grayscale color based on intensity `v`. Optional parameter alpha `a`.

AWT version of [[gray]]. See also [[awt-color]]
sourceraw docstring

blend-addclj

(blend-add a b)

Add channel values.

Add channel values.
sourceraw docstring

blend-andclj

(blend-and a b)

Bitwise and of channel values.

Bitwise and of channel values.
sourceraw docstring

blend-burnclj

(blend-burn a b)

Burn channel values.

Burn channel values.
sourceraw docstring

blend-colorsclj

(blend-colors f c1 c2)
(blend-colors f c1 c2 alpha?)

Blend colors with blending function. Set alpha? if you want to blend alpha channel (default: false).

Blend colors with blending function. Set `alpha?` if you want to blend alpha channel (default: `false`).
sourceraw docstring

blend-darkenclj

(blend-darken a b)

Darken channel values.

Darken channel values.
sourceraw docstring

blend-darkthresholdclj

(blend-darkthreshold a b)
(blend-darkthreshold a b thr)

Dark thresholded (with *blend-threshold*) channel values.

Dark thresholded (with `*blend-threshold*`) channel values.
sourceraw docstring

blend-differenceclj

(blend-difference a b)

Difference channel values.

Difference channel values.
sourceraw docstring

blend-divideclj

(blend-divide a b)

Divide channel values.

Divide channel values.
sourceraw docstring

blend-dodgeclj

(blend-dodge a b)

Dodge channel values.

Dodge channel values.
sourceraw docstring

blend-exclusionclj

(blend-exclusion a b)

Exclusion of channel values.

Exclusion of channel values.
sourceraw docstring

blend-hardlightclj

(blend-hardlight a b)

Hardlight channel values.

Hardlight channel values.
sourceraw docstring

blend-hardmixclj

(blend-hardmix a b)

Hard mix channel values.

Hard mix channel values.
sourceraw docstring

blend-lightenclj

(blend-lighten a b)

Lighten channel values.

Lighten channel values.
sourceraw docstring

blend-lightthresholdclj

(blend-lightthreshold a b)
(blend-lightthreshold a b thr)

Light thresholded (with *blend-threshold*) channel values.

Light thresholded (with `*blend-threshold*`) channel values.
sourceraw docstring

blend-linearburnclj

(blend-linearburn a b)

Linear burn channel values.

Linear burn channel values.
sourceraw docstring

blend-linearlightclj

(blend-linearlight a b)

Linear light channel values.

Linear light channel values.
sourceraw docstring

blend-maddclj

(blend-madd a b)

Modulus add channel values.

Modulus add channel values.
sourceraw docstring

blend-mburnclj

(blend-mburn a b)

Modulus burn channel values.

Modulus burn channel values.
sourceraw docstring

blend-mdivideclj

(blend-mdivide a b)

Modulus divide channel values.

Modulus divide channel values.
sourceraw docstring

blend-mdodgeclj

(blend-mdodge a b)

Modulus dodge channel values.

Modulus dodge channel values.
sourceraw docstring

blend-mhardlightclj

(blend-mhardlight a b)

Modulus hardlight channel values.

Modulus hardlight channel values.
sourceraw docstring

blend-mlinearburnclj

(blend-mlinearburn a b)

Modulus linear burn channel values.

Modulus linear burn channel values.
sourceraw docstring

blend-mlinearlightclj

(blend-mlinearlight a b)

Modulus linear light channel values.

Modulus linear light channel values.
sourceraw docstring

blend-moverlayclj

(blend-moverlay a b)

Modulus overlay channel values.

Modulus overlay channel values.
sourceraw docstring

blend-mpegtoplightclj

(blend-mpegtoplight a b)

Modulus pegtop light channel values.

Modulus pegtop light channel values.
sourceraw docstring

blend-mpinlightclj

(blend-mpinlight a b)

Modulus pinlight channel values.

Modulus pinlight channel values.
sourceraw docstring

blend-msoftlightclj

(blend-msoftlight a b)

Modulus softlight channel values.

Modulus softlight channel values.
sourceraw docstring

blend-msubtractclj

(blend-msubtract a b)

Modulus subtract channel values.

Modulus subtract channel values.
sourceraw docstring

blend-multiplyclj

(blend-multiply a b)

Multiply channel values.

Multiply channel values.
sourceraw docstring

blend-mvividlightclj

(blend-mvividlight a b)

Modulus vividlight channel values.

Modulus vividlight channel values.
sourceraw docstring

blend-noneclj

(blend-none a b)

Return first value only. Do nothing.

Return first value only. Do nothing.
sourceraw docstring

blend-opacityclj

(blend-opacity a b)
(blend-opacity a b thr)

Opacity (with *blend-threshold*)

Opacity (with `*blend-threshold*`)
sourceraw docstring

blend-orclj

(blend-or a b)

Bitwise or of channel values.

Bitwise or of channel values.
sourceraw docstring

blend-overlayclj

(blend-overlay a b)

Overlay channel values.

Overlay channel values.
sourceraw docstring

blend-pegtoplightclj

(blend-pegtoplight a b)

Pegtop light channel values.

Pegtop light channel values.
sourceraw docstring

blend-pinlightclj

(blend-pinlight a b)

Pinlight of channel values.

Pinlight of  channel values.
sourceraw docstring

blend-screenclj

(blend-screen a b)

Screen channel values.

Screen channel values.
sourceraw docstring

blend-softlightclj

(blend-softlight a b)

Softlight channel values.

Softlight channel values.
sourceraw docstring

blend-subtractclj

(blend-subtract a b)

Subtract channel values.

Subtract channel values.
sourceraw docstring

blend-valuesclj

(blend-values f a b)

Blend two values a and b from range [0,255] using blending function f.

Result is from range [0,255].

Blend two values `a` and `b` from range `[0,255]` using blending function `f`.

Result is from range `[0,255]`.
sourceraw docstring

blend-vividlightclj

(blend-vividlight a b)

Vividlight channel values.

Vividlight channel values.
sourceraw docstring

blend-xorclj

(blend-xor a b)

Bitwise xor of channel values.

Bitwise xor of channel values.
sourceraw docstring

blendsclj

Map of all blending functions.

  • key - name as keyword
  • value - function

See blends-list for names.

Map of all blending functions.

* key - name as keyword
* value - function

See [[blends-list]] for names.
sourceraw docstring

blends-listclj

List of all blending functions.

List of all blending functions.
sourceraw docstring

brightenclj

Make color brighter. See darken.

Make color brighter. See [[darken]].
sourceraw docstring

change-lab-lumaclj

(change-lab-luma amt col)

Change luma for givent color by given amount. Works in LAB color space.

Luma value can't exceed [0-100] range.

Change luma for givent color by given amount. Works in LAB color space.

Luma value can't exceed `[0-100]` range.
sourceraw docstring

change-saturationclj

(change-saturation amt col)

Change color saturation in LCH color space.

Saturation value can't exceed [0-134] range.

Change color saturation in LCH color space.

Saturation value can't exceed `[0-134]` range.
sourceraw docstring

clampclj

(clamp c)

Clamp all color channels to [0-255] range.

Clamp all color channels to `[0-255]` range.
sourceraw docstring

clamp255clj

(clamp255 a)

Constrain value a to 0-255 double.

Use to ensure that value is in RGB range. Accepts and returns double.

See also lclamp255, clamp and lclamp.

Constrain value `a` to 0-255 double.

Use to ensure that value is in RGB range.
Accepts and returns `double`.

See also [[lclamp255]], [[clamp]] and [[lclamp]].
sourceraw docstring

colorclj

(color c)
(color c a)
(color r g b)
(color r g b a)

Create Vec4 object as color representation.

Arity:

  • 1 - convert to Vec4 from any color. Same as [[to-color]]
  • 2 - sets color alpha
  • 3 - sets r,g,b with alpha 255
  • 4 - sets r,g,b and alpha

See also awt-color, awt-gray.

Create Vec4 object as color representation.

Arity: 

* 1 - convert to `Vec4` from any color. Same as [[to-color]]
* 2 - sets color alpha
* 3 - sets r,g,b with alpha 255
* 4 - sets r,g,b and alpha

See also [[awt-color]], [[awt-gray]].
sourceraw docstring

color-converterclj

(color-converter cs)
(color-converter cs ch-scale)
(color-converter cs ch1-scale ch2-scale ch3-scale)
(color-converter cs ch1-scale ch2-scale ch3-scale ch4-scale)

Create fn which converts provided color from cs color space using ch-scale as maximum value. (to simulate Processing colorMode fn).

Arity:

  • 1 - returns from-XXX* function
  • 2 - sets the same maximum value for each channel
  • 3 - sets individual maximum value without alpha, which is set to 0-255 range
  • 4 - all channels have it's own indivudual maximum value.
Create fn which converts provided color from `cs` color space using `ch-scale` as maximum value. (to simulate Processing `colorMode` fn).

Arity:

* 1 - returns from-XXX* function
* 2 - sets the same maximum value for each channel
* 3 - sets individual maximum value without alpha, which is set to 0-255 range
* 4 - all channels have it's own indivudual maximum value.
sourceraw docstring

ColorProtocljprotocol

Basic color operations

Basic color operations

to-colorclj

(to-color c)

Convert any color representation to Vec4 vector.

Convert any color representation to `Vec4` vector.

greenclj

(green c)

Returns green (second channel) value. See also [[ch1]].

Returns green (second channel) value. See also [[ch1]].

ch2clj

(ch2 c)

Returns third channel value. See also [[blue]]

Returns third channel value. See also [[blue]]

to-awt-colorclj

(to-awt-color c)

Convert any color representation to java.awt.Color.

Convert any color representation to `java.awt.Color`.

ch0clj

(ch0 c)

Returns first channel value. See also [[red]]

Returns first channel value. See also [[red]]

redclj

(red c)

Returns red (first channel) value. See also [[ch0]].

Returns red (first channel) value. See also [[ch0]].

blueclj

(blue c)

Returns blue (third channel) value. See also [[ch2]].

Returns blue (third channel) value. See also [[ch2]].

ch1clj

(ch1 c)

Returns second channel value. See also [[green]]

Returns second channel value. See also [[green]]

lumaclj

(luma c)

Returns luma

Returns luma

alphaclj

(alpha c)

Returns alpha value.

Returns alpha value.
sourceraw docstring

colorspacesclj

Map of all color spaces functions

  • key - name as keyword
  • value - vector with functions containing to-XXX and from-XXX converters.
Map of all color spaces functions

* key - name as keyword
* value - vector with functions containing to-XXX and from-XXX converters.
sourceraw docstring

colorspaces*clj

Map of all normalized color spaces functions

  • key - name as keyword
  • value - vector with functions containing to-XXX* and from-XXX* converters.
Map of all normalized color spaces functions

* key - name as keyword
* value - vector with functions containing to-XXX* and from-XXX* converters.
sourceraw docstring

colorspaces-listclj

List of all color space names.

List of all color space names.
sourceraw docstring

colourlovers-palettesclj

Vector 500 best palettes taken from http://www.colourlovers.com/

See all

Vector 500 best palettes taken from http://www.colourlovers.com/

[See all](../static/colourlovers.html)
sourceraw docstring

contrast-ratioclj

(contrast-ratio c1 c2)

WCAG contrast ratio.

Based on YUV luma.

WCAG contrast ratio.

Based on YUV luma.
sourceraw docstring

darkenclj

Make color darker. See brighten.

Make color darker. See [[brighten]].
sourceraw docstring

delta-cclj

(delta-c c1 c2)

Delta C* distance

Delta C* distance
sourceraw docstring

delta-e-cieclj

Delta E CIE distance (euclidean in LAB colorspace.

Delta E CIE distance (euclidean in LAB colorspace.
sourceraw docstring

delta-e-cmcclj

(delta-e-cmc c1 c2)
(delta-e-cmc l c c1 c2)

Delta E CMC distance.

Parameters l and c defaults to 1.0. Other common settings is l=2.0 and c=1.0.

Delta E CMC distance.

Parameters `l` and `c` defaults to 1.0. Other common settings is `l=2.0` and `c=1.0`.
sourceraw docstring

delta-e-jabclj

(delta-e-jab c1 c2)

Delta e calculated in JAB color space.

Delta e calculated in JAB color space.
sourceraw docstring

delta-hclj

(delta-h c1 c2)

Delta H* distance

Delta H* distance
sourceraw docstring

desaturateclj

Desaturate color

Desaturate color
sourceraw docstring

euclideanclj

Euclidean distance in RGB

Euclidean distance in RGB
sourceraw docstring

format-hexclj

(format-hex c)

Convert color to hex string (css).

Convert color to hex string (css).
sourceraw docstring

from-CMYclj

CMY -> RGB

CMY -> RGB
sourceraw docstring

from-CMY*clj

CMY -> RGB, alias for from-CMY

CMY -> RGB, alias for [[from-CMY]]
sourceraw docstring

from-Cubehelixclj

(from-Cubehelix c)

Cubehelix -> RGB

Cubehelix -> RGB
sourceraw docstring

from-Cubehelix*clj

(from-Cubehelix* c)

Cubehelix -> RGB, normalized

Cubehelix -> RGB, normalized
sourceraw docstring

from-GLHSclj

(from-GLHS c)

GLHS -> RGB

GLHS -> RGB
sourceraw docstring

from-GLHS*clj

(from-GLHS* c)

GLHS -> RGB

GLHS -> RGB
sourceraw docstring

from-Grayclj

RGB -> Grayscale

RGB -> Grayscale
sourceraw docstring

from-Gray*clj

RGB -> Grayscale

RGB -> Grayscale
sourceraw docstring

from-HCLclj

(from-HCL c)

HCL -> RGB

HCL -> RGB
sourceraw docstring

from-HCL*clj

HCL -> RGB, normalized

HCL -> RGB, normalized
sourceraw docstring

from-HSBclj

HSB(V) -> RGB, normalized (see from-HSV)

HSB(V) -> RGB, normalized (see [[from-HSV]])
sourceraw docstring

from-HSB*clj

HSB(V) -> RGB (see [[from-HSV-raw]])

HSB(V) -> RGB (see [[from-HSV-raw]])
sourceraw docstring

from-HSIclj

(from-HSI c)

HSI -> RGB

HSI -> RGB
sourceraw docstring

from-HSI*clj

HSI -> RGB, normalized

HSI -> RGB, normalized
sourceraw docstring

from-HSLclj

(from-HSL c)

HSL -> RGB

HSL -> RGB
sourceraw docstring

from-HSL*clj

HSL -> RGB, normalized

HSL -> RGB, normalized
sourceraw docstring

from-HSVclj

(from-HSV c)

HSV -> RGB

HSV -> RGB
sourceraw docstring

from-HSV*clj

HSV -> RGB, normalized

HSV -> RGB, normalized
sourceraw docstring

from-HunterLABclj

(from-HunterLAB c)

HunterLAB -> RGB

HunterLAB -> RGB
sourceraw docstring

from-HunterLAB*clj

(from-HunterLAB* c)

HunterLAB -> RGB, normalized

HunterLAB -> RGB, normalized
sourceraw docstring

from-HWBclj

(from-HWB c)

HWB -> RGB

HWB -> RGB
sourceraw docstring

from-HWB*clj

(from-HWB* c)

HWB -> RGB, normalized

HWB -> RGB, normalized
sourceraw docstring

from-IPTclj

(from-IPT c)

IPT -> RGB

IPT -> RGB
sourceraw docstring

from-IPT*clj

(from-IPT* c)

LMS -> RGB, normalized

LMS -> RGB, normalized
sourceraw docstring

from-JABclj

(from-JAB c)

JAB -> RGB

JAB -> RGB
sourceraw docstring

from-JAB*clj

(from-JAB* c)

JAB -> RGB, normalized

JAB -> RGB, normalized
sourceraw docstring

from-JCHclj

(from-JCH c)

JCH -> RGB

JCH -> RGB
sourceraw docstring

from-JCH*clj

(from-JCH* c)

JCH -> RGB, normalized

JCH -> RGB, normalized
sourceraw docstring

from-LABclj

(from-LAB c)

LAB -> RGB

LAB -> RGB
sourceraw docstring

from-LAB*clj

(from-LAB* c)

LAB -> RGB, normalized

LAB -> RGB, normalized
sourceraw docstring

from-LCHclj

(from-LCH c)

LCH -> RGB

LCH -> RGB
sourceraw docstring

from-LCH*clj

(from-LCH* c)

LCH -> RGB, normalized

LCH -> RGB, normalized
sourceraw docstring

from-linearclj

(from-linear v)

Gamma correction (gamma=1/2.4), lighten

Gamma correction (gamma=1/2.4), lighten
sourceraw docstring

from-LMSclj

(from-LMS c)

LMS -> RGB, D65

LMS -> RGB, D65
sourceraw docstring

from-LMS*clj

(from-LMS* c)

LMS -> RGB, normalized

LMS -> RGB, normalized
sourceraw docstring

from-LUVclj

(from-LUV c)

LUV -> RGB

LUV -> RGB
sourceraw docstring

from-LUV*clj

(from-LUV* c)

LUV -> RGB, normalized

LUV -> RGB, normalized
sourceraw docstring

from-OHTAclj

(from-OHTA c)

OHTA -> RGB

OHTA -> RGB
sourceraw docstring

from-OHTA*clj

(from-OHTA* c)

OHTA -> RGB, normalized

OHTA -> RGB, normalized
sourceraw docstring

from-RGBclj

Alias for [[to-color]]

Alias for [[to-color]]
sourceraw docstring

from-RGB*clj

Alias for [[to-color]]

Alias for [[to-color]]
sourceraw docstring

from-sRGBclj

(from-sRGB c)

sRGB -> RGB

sRGB -> RGB
sourceraw docstring

from-sRGB*clj

sRGB -> RGB

sRGB -> RGB
sourceraw docstring

from-XYZclj

(from-XYZ c)

XYZ -> RGB

XYZ -> RGB
sourceraw docstring

from-XYZ*clj

(from-XYZ* c)

XYZ -> RGB, normalized

XYZ -> RGB, normalized
sourceraw docstring

from-YCbCrclj

(from-YCbCr c)

YCbCr -> RGB

YCbCr -> RGB
sourceraw docstring

from-YCbCr*clj

(from-YCbCr* c)

YCbCr -> RGB, normalized

YCbCr -> RGB, normalized
sourceraw docstring

from-YCgCoclj

(from-YCgCo c)

YCgCo -> RGB

YCgCo -> RGB
sourceraw docstring

from-YCgCo*clj

(from-YCgCo* c)

YCgCo -> RGB, normalized

YCgCo -> RGB, normalized
sourceraw docstring

from-YDbDrclj

(from-YDbDr c)

YDbDr -> RGB

YDbDr -> RGB
sourceraw docstring

from-YDbDr*clj

(from-YDbDr* c)

YDbDr -> RGB, normalized

YDbDr -> RGB, normalized
sourceraw docstring

from-YIQclj

(from-YIQ c)

YIQ -> RGB

YIQ -> RGB
sourceraw docstring

from-YIQ*clj

(from-YIQ* c)

YIQ -> RGB, normalized

YIQ -> RGB, normalized
sourceraw docstring

from-YPbPrclj

(from-YPbPr c)

YPbPr -> RGB

YPbPr -> RGB
sourceraw docstring

from-YPbPr*clj

(from-YPbPr* c)

YPbPr -> RGB, normalized

YPbPr -> RGB, normalized
sourceraw docstring

from-YUVclj

(from-YUV c)

YUV -> RGB

YUV -> RGB
sourceraw docstring

from-YUV*clj

(from-YUV* c)

YUV -> RGB, normalized

YUV -> RGB, normalized
sourceraw docstring

from-Yxyclj

(from-Yxy c)

Yxy -> RGB

Yxy -> RGB
sourceraw docstring

from-Yxy*clj

(from-Yxy* c)

Yxy -> RGB, normalized

Yxy -> RGB, normalized
sourceraw docstring

gradientclj

(gradient palette)
(gradient colorspace palette)
(gradient colorspace interpolator palette)
(gradient colorspace interpolator domain palette)

Create gradient function from palette (list of colors).

Grandient function accepts value from 0 to 1 and returns interpolated color.

Optionally interpolate in given colorspace and 1d interpolator as keyword or function.

To make irregular spacings between colors, provide own domain.

Create gradient function from palette (list of colors).

Grandient function accepts value from 0 to 1 and returns interpolated color.

Optionally interpolate in given `colorspace` and 1d [interpolator](https://generateme.github.io/fastmath/fastmath.interpolation.html#var-interpolators-1d-list) as keyword or function.

To make irregular spacings between colors, provide own `domain`.
sourceraw docstring

gradient-cubehelixclj

Cubehelix gradient generator.

Cubehelix gradient generator.
sourceraw docstring

gradient-easingclj

(gradient-easing col1 col2)
(gradient-easing cs col1 col2)
(gradient-easing cs easing col1 col2)

Create gradient between two colors.

Input colors should be in expected color space (default: RGB).

You can use easing function to make interpolation non-linear (default: linear).

Create gradient between two colors.

Input colors should be in expected color space (default: `RGB`).

You can use easing function to make interpolation non-linear (default: linear).
sourceraw docstring

gradient-presetsclj

Ready to use gradients containing Inigo Quilez, Cubehelix sets and other.

Map with name (keyword) as key and gradient function as value.

See all

Ready to use gradients containing Inigo Quilez, Cubehelix sets and other.

Map with name (keyword) as key and gradient function as value.

[See all](../static/gradients.html)
sourceraw docstring

gradient-presets-listclj

Gradient presets names.

Gradient presets names.
sourceraw docstring

grayclj

(gray v)
(gray v a)

Create grayscale color based on intensity v. Optional parameter alpha a.

See also color

Create grayscale color based on intensity `v`. Optional parameter alpha `a`.

See also [[color]]
sourceraw docstring

hueclj

(hue c)

Hue value of color (any representation). Returns angle (0-360).

Uses hexagonal transformation. See also hue-polar.

Hue value of color (any representation). Returns angle (0-360).

Uses hexagonal transformation. See also [[hue-polar]].
sourceraw docstring

hue-polarclj

(hue-polar c)

Hue value of color (any representation). Returns angle (0-360).

Uses polar transformation. See also hue.

Hue value of color (any representation). Returns angle (0-360).

Uses polar transformation. See also [[hue]].
sourceraw docstring

iq-gradientclj

(iq-gradient c1 c2)
(iq-gradient a b c d)

Create gradient generator function with given parametrization or two colors.

See http://iquilezles.org/www/articles/palettes/palettes.htm and https://github.com/thi-ng/color/blob/master/src/gradients.org#gradient-coefficient-calculation

Parameters should be Vec3 type.

Create gradient generator function with given parametrization or two colors.

See http://iquilezles.org/www/articles/palettes/palettes.htm and https://github.com/thi-ng/color/blob/master/src/gradients.org#gradient-coefficient-calculation

Parameters should be `Vec3` type.
sourceraw docstring

iq-random-gradientclj

(iq-random-gradient)

Create random iq gradient.

Create random iq gradient.
sourceraw docstring

lclampclj

(lclamp c)

Clamp all color channels to [0-255] range. Round if necessary.

Clamp all color channels to `[0-255]` range. Round if necessary.
sourceraw docstring

lclamp255clj

(lclamp255 a)

Constrain value a to 0-255 long (rounding if necessary).

Use to ensure that value is in RGB range.

See also clamp255, clamp and lclamp.

Constrain value `a` to 0-255 long (rounding if necessary).

Use to ensure that value is in RGB range.

See also [[clamp255]], [[clamp]] and [[lclamp]].
sourceraw docstring

lerpclj

(lerp c1 c2 t)

Lineary interpolate color between two values.

See also gradient or fastmath vector interpolations.

Lineary interpolate color between two values.

See also [[gradient]] or `fastmath` vector interpolations.
sourceraw docstring

mixclj

(mix x1 x2)
(mix x1 x2 t)
(mix colorspace x1 x2 t)

Mix colors in given optional colorspace (default: :RGB) and optional ratio (default: 0.5).

Mix colors in given optional `colorspace` (default: `:RGB`) and optional ratio (default: 0.5).
sourceraw docstring

named-colors-listclj

List of html color names

Coloured list

List of html color names

[Coloured list](../static/colors.html)
sourceraw docstring

nearest-colorclj

(nearest-color xf c)
(nearest-color f xf c)

Find nearest color from a set. Input: distance function (default euclidean), list of target colors and source color.

Find nearest color from a set. Input: distance function (default euclidean), list of target colors and source color.
sourceraw docstring

noticable-different?clj

(noticable-different? c1 c2)
(noticable-different? s p c1 c2)

Returns noticable difference (true/false) between colors.

Defined in: https://research.tableau.com/sites/default/files/2014CIC_48_Stone_v3.pdf

Implementation from: https://github.com/connorgr/d3-jnd/blob/master/src/jnd.js

Returns noticable difference (true/false) between colors.

Defined in: https://research.tableau.com/sites/default/files/2014CIC_48_Stone_v3.pdf

Implementation from: https://github.com/connorgr/d3-jnd/blob/master/src/jnd.js
sourceraw docstring

packclj

(pack c)

Pack color to ARGB 32bit integer.

Pack color to ARGB 32bit integer.
sourceraw docstring

palette-presetsclj

Color palette presets.

See all

Color palette presets.

[See all](../static/palettes.html)
sourceraw docstring

palette-presets-listclj

Color palette presets list.

Color palette presets list.
sourceraw docstring

palettoncljmultimethod

Create paletton palette.

Input:

  • type - one of: :monochromatic (one hue), :triad (three hues), :tetrad (four hues)
  • hue - paletton version of hue (use paletton-rgb-to-hue to get hue value).
  • configuration as a map

Configuration consist:

  • :preset - one of paletton-presets-list, default :full.
  • :compl - generate complementary color?, default false. Works with :monochromatic and :triad
  • :angle - hue angle for additional colors for :triad and :tetrad.
  • :adj - for :triad only, generate adjacent (default true) values or not.
Create [paletton](http://paletton.com/) palette.

Input:

* type - one of: `:monochromatic` (one hue), `:triad` (three hues), `:tetrad` (four hues)
* hue - paletton version of hue (use [[paletton-rgb-to-hue]] to get hue value).
* configuration as a map

Configuration consist:

* `:preset` - one of [[paletton-presets-list]], default `:full`.
* `:compl` - generate complementary color?, default `false`. Works with `:monochromatic` and `:triad`
* `:angle` - hue angle for additional colors for `:triad` and `:tetrad`.
* `:adj` - for `:triad` only, generate adjacent (default `true`) values or not.
sourceraw docstring

paletton-presets-listclj

Paletton presets names

Paletton presets names
sourceraw docstring

paletton-rgb-to-hueclj

(paletton-rgb-to-hue c)
(paletton-rgb-to-hue r g b)

Convert color to paletton HUE (which is different than hexagon or polar conversion).

Convert color to paletton HUE (which is different than hexagon or polar conversion).
sourceraw docstring

random-gradientclj

(random-gradient)

Generate random gradient function.

Generate random gradient function.
sourceraw docstring

random-paletteclj

(random-palette)

Generate random palette from all collections defined in clojure2d.color namespace.

Generate random palette from all collections defined in clojure2d.color namespace.
sourceraw docstring

reduce-colorsclj

(reduce-colors xs number-of-colors)
(reduce-colors colorspace xs number-of-colors)

Reduce colors using x-means clustering in given colorspace (default :RGB).

Use for long sequences (for example to generate palette from image).

Reduce colors using x-means clustering in given `colorspace` (default `:RGB`).

Use for long sequences (for example to generate palette from image).
sourceraw docstring

resampleclj

(resample number-of-colors palette & gradient-params)

Resample palette.

Internally it's done by creating gradient and sampling back to colors. You can pass gradient parameters like colorspace, interpolator name and domain.

Resample palette.

Internally it's done by creating gradient and sampling back to colors. You can pass [[gradient]] parameters like colorspace, interpolator name and domain.
sourceraw docstring

rev255clj

Scaling factor to convert color value from range [0-255] to [0-1].

Scaling factor to convert color value from range `[0-255]` to `[0-1]`.
sourceraw docstring

saturateclj

Saturate color

Saturate color
sourceraw docstring

set-alphaclj

(set-alpha c a)

Set alpha channel and return new color

Set alpha channel and return new color
sourceraw docstring

set-awt-alphaclj

(set-awt-alpha c a)

Set alpha channel and return Color representation.

Set alpha channel and return `Color` representation.
sourceraw docstring

set-ch0clj

(set-ch0 c val)

Set alpha channel and return new color.

Set alpha channel and return new color.
sourceraw docstring

set-ch1clj

(set-ch1 c val)

Set alpha channel and return new color.

Set alpha channel and return new color.
sourceraw docstring

set-ch2clj

(set-ch2 c val)

Set alpha channel and return new color

Set alpha channel and return new color
sourceraw docstring

to-CMYclj

(to-CMY c)

RGB -> CMY

RGB -> CMY
sourceraw docstring

to-CMY*clj

CMY -> RGB, alias for to-CMY

CMY -> RGB, alias for [[to-CMY]]
sourceraw docstring

to-Cubehelixclj

(to-Cubehelix c)

RGB -> Cubehelix

RGB -> Cubehelix
sourceraw docstring

to-Cubehelix*clj

(to-Cubehelix* c)

RGB -> Cubehelix, normalized

RGB -> Cubehelix, normalized
sourceraw docstring

to-GLHSclj

(to-GLHS c)

RGB -> GLHS

RGB -> GLHS
sourceraw docstring

to-GLHS*clj

(to-GLHS* c)

RGB -> GLHS, normalized

RGB -> GLHS, normalized
sourceraw docstring

to-Grayclj

(to-Gray c)

RGB -> Grayscale

RGB -> Grayscale
sourceraw docstring

to-Gray*clj

RGB -> Grayscale

RGB -> Grayscale
sourceraw docstring

to-HCLclj

(to-HCL c)

RGB -> HCL

RGB -> HCL
sourceraw docstring

to-HCL*clj

RGB -> HCL, normalized

RGB -> HCL, normalized
sourceraw docstring

to-HSBclj

RGB -> HSB(V), normalized (see to-HSV)

RGB -> HSB(V), normalized (see [[to-HSV]])
sourceraw docstring

to-HSB*clj

RGB -> HSB(V) (see [[to-HSV-raw]])

RGB -> HSB(V) (see [[to-HSV-raw]])
sourceraw docstring

to-HSIclj

(to-HSI c)

RGB -> HSI

RGB -> HSI
sourceraw docstring

to-HSI*clj

RGB -> HSI, normalized

RGB -> HSI, normalized
sourceraw docstring

to-HSLclj

(to-HSL c)

RGB -> HSL

RGB -> HSL
sourceraw docstring

to-HSL*clj

RGB -> HSL, normalized

RGB -> HSL, normalized
sourceraw docstring

to-HSVclj

(to-HSV c)

RGB -> HSV

RGB -> HSV
sourceraw docstring

to-HSV*clj

RGB -> HSV, normalized

RGB -> HSV, normalized
sourceraw docstring

to-HunterLABclj

(to-HunterLAB c)

RGB -> HunterLAB

RGB -> HunterLAB
sourceraw docstring

to-HunterLAB*clj

(to-HunterLAB* c)

RGB -> HunterLAB, normalized

RGB -> HunterLAB, normalized
sourceraw docstring

to-HWBclj

(to-HWB c)

RGB -> HWB

RGB -> HWB
sourceraw docstring

to-HWB*clj

(to-HWB* c)

RGB - HWB, normalized

RGB - HWB, normalized
sourceraw docstring

to-IPTclj

(to-IPT c)

RGB -> IPT

RGB -> IPT
sourceraw docstring

to-IPT*clj

(to-IPT* c)

RGB -> IPT, normalized

RGB -> IPT, normalized
sourceraw docstring

to-JABclj

(to-JAB c)

RGB -> JAB

RGB -> JAB
sourceraw docstring

to-JAB*clj

(to-JAB* c)

RGB -> JAB, normalized

RGB -> JAB, normalized
sourceraw docstring

to-JCHclj

(to-JCH c)

RGB -> JCH

RGB -> JCH
sourceraw docstring

to-JCH*clj

(to-JCH* c)

RGB -> JCH, normalized

RGB -> JCH, normalized
sourceraw docstring

to-LABclj

(to-LAB c)

RGB -> LAB

RGB -> LAB
sourceraw docstring

to-LAB*clj

(to-LAB* c)

RGB -> LAB, normalized

RGB -> LAB, normalized
sourceraw docstring

to-LCHclj

(to-LCH c)

RGB -> LCH

RGB -> LCH
sourceraw docstring

to-LCH*clj

(to-LCH* c)

RGB -> LCH, normalized

RGB -> LCH, normalized
sourceraw docstring

to-linearclj

(to-linear v)

Gamma correction (gamma=2.4), darken

Gamma correction (gamma=2.4), darken
sourceraw docstring

to-LMSclj

(to-LMS c)

RGB -> LMS, D65

RGB -> LMS, D65
sourceraw docstring

to-LMS*clj

(to-LMS* c)

RGB -> LMS, normalized

RGB -> LMS, normalized
sourceraw docstring

to-LUVclj

(to-LUV c)

RGB -> LUV

RGB -> LUV
sourceraw docstring

to-LUV*clj

(to-LUV* c)

RGB -> LUV, normalized

RGB -> LUV, normalized
sourceraw docstring

to-OHTAclj

(to-OHTA c)

RGB -> OHTA

RGB -> OHTA
sourceraw docstring

to-OHTA*clj

(to-OHTA* c)

RGB -> OHTA, normalized

RGB -> OHTA, normalized
sourceraw docstring

to-RGBclj

Alias for [[to-color]]

Alias for [[to-color]]
sourceraw docstring

to-RGB*clj

Alias for [[to-color]]

Alias for [[to-color]]
sourceraw docstring

to-sRGBclj

(to-sRGB c)

RGB -> sRGB

RGB -> sRGB
sourceraw docstring

to-sRGB*clj

RGB -> sRGB

RGB -> sRGB
sourceraw docstring

to-thing-rgbaclj

(to-thing-rgba c)

Convert Clojure2d color to thi.ng RGBA.

Convert Clojure2d color to thi.ng RGBA.
sourceraw docstring

to-XYZclj

(to-XYZ c)

RGB -> XYZ

RGB -> XYZ
sourceraw docstring

to-XYZ*clj

(to-XYZ* c)

RGB -> XYZ, normalized

RGB -> XYZ, normalized
sourceraw docstring

to-YCbCrclj

(to-YCbCr c)

RGB -> YCbCr

RGB -> YCbCr
sourceraw docstring

to-YCbCr*clj

(to-YCbCr* c)

RGB -> YCbCr, normalized

RGB -> YCbCr, normalized
sourceraw docstring

to-YCgCoclj

(to-YCgCo c)

RGB -> YCgCo

RGB -> YCgCo
sourceraw docstring

to-YCgCo*clj

(to-YCgCo* c)

RGB -> YCgCo, normalized

RGB -> YCgCo, normalized
sourceraw docstring

to-YDbDrclj

(to-YDbDr c)

RGB -> YDbDr

RGB -> YDbDr
sourceraw docstring

to-YDbDr*clj

(to-YDbDr* c)

RGB -> YDbDr

RGB -> YDbDr
sourceraw docstring

to-YIQclj

(to-YIQ c)

RGB -> YIQ

RGB -> YIQ
sourceraw docstring

to-YIQ*clj

(to-YIQ* c)

RGB -> YIQ, normalized

RGB -> YIQ, normalized
sourceraw docstring

to-YPbPrclj

(to-YPbPr c)

RGB -> YPbPr

RGB -> YPbPr
sourceraw docstring

to-YPbPr*clj

(to-YPbPr* c)

RGB -> YPbPr, normalized

RGB -> YPbPr, normalized
sourceraw docstring

to-YUVclj

(to-YUV c)

RGB -> YUV

RGB -> YUV
sourceraw docstring

to-YUV*clj

(to-YUV* c)

RGB -> YUV, normalized

RGB -> YUV, normalized
sourceraw docstring

to-Yxyclj

(to-Yxy c)

RGB -> Yxy

RGB -> Yxy
sourceraw docstring

to-Yxy*clj

(to-Yxy* c)

RGB -> Yxy, normalized

RGB -> Yxy, normalized
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close