Color functions.
This namespace contains color manipulation functions which can be divided into following groups:
Color can be represented by following types:
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.Vec3
- 3 channels (RGB), assuming alpha
set to value of 255
.Vec2
- gray with alphajava.awt.Color
- Java AWT representation. Creators are awt-color
, awt-gray
. Use to-awt-color
to convert to this representation.keyword
- one of the defined names (see named-colors-list
)Integer
- packed ARGB value. If value is less than 0xff000000
, alpha is set to 0xff
. Example: 0xffaa01
.String
- CSS (#rgb
or #rgba
) or string containg hexadecimal representation ("ffaa01")seqable
- list, vector containing 2-4 elements. Conversion is done by applying content to color
function.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.
All funtions internally convert any color representation to Vec4
type using to-color
function..
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.
General set-channel
and get-channel
can work with any colorspace.
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 modulate
color (ie. multiply by given value).
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:
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.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 interpretation.
NOTE 2: be aware that converting function do not clamp any values to/from expected range.
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.
List of all defined colors and palettes:
Palette is just sequence of colors.
There are plenty of them predefined or can be generated:
palette
to access palette by keyword (from presets), by number (from colourlovers). Use palette
to resample palette or convert gradient to palette.:monochromatic
, :triad
, :tetrad
with complementary color for given hue and configuration. See also Paletton website for details.Call palette
without any parameters to get list of predefined gradients.
Gradient is continuous functions which accepts value from [0-1]
range and returns color. Call gradient
to create one.
Call gradient
without any parameters to obtain list of predefined gradients.
Use gradient
to convert any palette to gradient or access predefined gradients by keyword.
To convert palette to gradient call gradient
function. You can set interpolation method and colorspace.
To convert gradient to palette call palette
function.
Call palette
to resample palette to other number of colors. Internally input palette is converted to gradient and sampled back.
Use lerp
, lerp+
, mix
, average
, mixbox
to mix two colors in different ways.
Several functions to calculate difference between colors, delta-E*-xxx
etc.
Color functions. This namespace contains color manipulation functions which can be divided into following groups: * Color creators * Channel manipulations * Conversions * 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. * fastmath `Vec3` - 3 channels (RGB), assuming `alpha` set to value of `255`. * fastmath `Vec2` - gray with alpha * `java.awt.Color` - Java AWT representation. Creators are [[awt-color]], [[awt-gray]]. Use [[to-awt-color]] to convert to this representation. * `keyword` - one of the defined names (see [[named-colors-list]]) * `Integer` - packed ARGB value. If value is less than `0xff000000`, alpha is set to `0xff`. Example: `0xffaa01`. * `String` - CSS (`#rgb` or `#rgba`) or string containg hexadecimal representation ("ffaa01") * any `seqable` - list, vector containing 2-4 elements. Conversion is done by applying content to [[color]] function. 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. All funtions internally convert any color representation to `Vec4` type using [[to-color]] function.. [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. General [[set-channel]] and [[get-channel]] can work with any colorspace. 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 [[modulate]] color (ie. multiply by given value). ## 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 interpretation. NOTE 2: be aware that converting function do not clamp any values to/from expected range. 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. ## Palettes / gradients ### Links List of all defined colors and palettes: * [Named palettes](../static/palettes/index.html) * [Gradients](../static/gradients/index.html) ### Palette Palette is just sequence of colors. There are plenty of them predefined or can be generated: * [[palette]] to access palette by keyword (from presets), by number (from colourlovers). Use [[palette]] to resample palette or convert gradient to palette. * [[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. Call [[palette]] without any parameters to get list of predefined gradients. ### Gradient Gradient is continuous functions which accepts value from `[0-1]` range and returns color. Call [[gradient]] to create one. Call [[gradient]] without any parameters to obtain list of predefined gradients. Use [[gradient]] to convert any palette to gradient or access predefined gradients by keyword. ### Conversions To convert palette to gradient call [[gradient]] function. You can set interpolation method and colorspace. To convert gradient to palette call [[palette]] function. Call [[palette]] to resample palette to other number of colors. Internally input palette is converted to gradient and sampled back. Use [[lerp]], [[lerp+]], [[mix]], [[average]], [[mixbox]] to mix two colors in different ways. ## Distances Several functions to calculate difference between colors, `delta-E*-xxx` etc. ## References * https://vis4.net/chromajs/ * https://github.com/thi-ng/color * https://github.com/nschloe/colorio
(adjust col channel value)
(adjust col colorspace channel value)
Adjust (add) given value to a chosen channel. Works with any color space.
Adjust (add) given value to a chosen channel. Works with any color space.
(adjust-temperature c temp)
(adjust-temperature c temp amount)
Adjust temperature of color. Default amount: 0.35 See [[temperature]] and [[lerp+]].
(apply-theme color color-theme)
Apply theme to the color, see color-themes
for names.
Generates random color similar to provided one. All operations are done in LSH* color space (normalized to have values between 0 and 255).
Color theme can be one of:
Apply theme to the color, see [[color-themes]] for names. Generates random color similar to provided one. All operations are done in LSH* color space (normalized to have values between 0 and 255). Color theme can be one of: * keyword - predefined color theme is used * [L C H] - randomization scheme of given channel, which can be: - [min-value max-value] - uniform random value from given range - a number - [channel-value, channel+value] range is used for random selection - nil, or anything else - keep original channel value
(average cs)
(average cs colorspace)
Average colors in given colorspace
(default: :sRGB
)
Average colors in given `colorspace` (default: `:sRGB`)
(blacken col)
(blacken col amt)
Change color towards black.
Works in HSB color space. Default amount is set to 0.2 and changes B channel by this amount.
Change color towards black. Works in HSB color space. Default amount is set to 0.2 and changes B channel by this amount.
(blue c)
Returns blue (third channel) value.
Returns blue (third channel) value.
(brighten col)
(brighten col amt)
Change luma for givent color by given amount.
Works in LAB color space. Default amount is 1.0 and means change luma in LAB of 18.0.
See darken
.
Change luma for givent color by given amount. Works in LAB color space. Default amount is 1.0 and means change luma in LAB of 18.0. See [[darken]].
(ch0 c)
Returns first channel value. Same as red
.
Returns first channel value. Same as [[red]].
(ch1 c)
Returns second channel value. Same as green
.
Returns second channel value. Same as [[green]].
(ch2 c)
Returns third channel value. Same as blue
.
Returns third channel value. Same as [[blue]].
(clamp c)
Clamp all color channels to [0-255]
range.
Clamp all color channels to `[0-255]` range.
(color c)
(color c a)
(color r g b)
(color r g b a)
Create Vec4 object as color representation.
Arity:
Vec4
from any color. Same as to-color
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 [[gray]]. [[awt-color]], [[awt-gray]].
(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 function which converts provided color from cs
color space using ch-scale
as maximum value. (to simulate Processing colorMode
fn).
Arity:
Create function 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 individual maximum value.
Map of all color spaces functions.
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 (normalized).
Map of all color spaces functions (normalized). * key - name as keyword * value - vector with functions containing to-XXX* and from-XXX* converters.
List of all color space names.
List of all color space names.
(complementary c)
(complementary c colorspace)
Create complementary color. Possible colorspaces are:
:PalettonHSV
(default):HSB
, :HSV
, :HSL
or :HWB
:GLHS
Create complementary color. Possible colorspaces are: * `:PalettonHSV` (default) * `:HSB`, `:HSV`, `:HSL` or `:HWB` * `:GLHS`
(contrast-ratio c1 c2)
WCAG contrast ratio.
Based on YUV luma.
WCAG contrast ratio. Based on YUV luma.
(correct-luma palette-or-gradient)
(correct-luma palette-or-gradient gradient-params)
Create palette or gradient with corrected luma to be linear.
See here
Create palette or gradient with corrected luma to be linear. See [here](https://www.vis4.net/blog/2013/09/mastering-multi-hued-color-scales/#combining-bezier-interpolation-and-lightness-correction)
(darken col)
(darken col amt)
Change luma for givent color by given amount.
Works in LAB color space. Default amount is 1.0 and means change luma in LAB of -18.0.
See brighten
.
Change luma for givent color by given amount. Works in LAB color space. Default amount is 1.0 and means change luma in LAB of -18.0. See [[brighten]].
(delta-C* c1 c2)
ΔC*_ab difference, chroma difference in LAB color space, CIE 1976
ΔC*_ab difference, chroma difference in LAB color space, CIE 1976
(delta-D-HCL c1 c2)
Color difference in HCL (Sarifuddin and Missaou) color space
Color difference in HCL (Sarifuddin and Missaou) color space
(delta-E* c1 c2)
ΔE*_ab difference, CIE 1976
ΔE*_ab difference, CIE 1976
(delta-E*-2000 c1 c2)
(delta-E*-2000 c1 c2 l c h)
ΔE* color difference, CIE 2000
http://www2.ece.rochester.edu/~gsharma/ciede2000/ciede2000noteCRNA.pdf
ΔE* color difference, CIE 2000 http://www2.ece.rochester.edu/~gsharma/ciede2000/ciede2000noteCRNA.pdf
(delta-E*-94 c1 c2)
ΔE* difference, CIE 1994
ΔE* difference, CIE 1994
(delta-E*-CMC c1 c2)
(delta-E*-CMC c1 c2 l c)
ΔE* CMC difference
Parameters l
and c
defaults to 1.0. Other common settings is l=2.0
and c=1.0
.
ΔE* CMC difference Parameters `l` and `c` defaults to 1.0. Other common settings is `l=2.0` and `c=1.0`.
Delta E CIE distance (euclidean in LAB colorspace.
Delta E CIE distance (euclidean in LAB colorspace.
(delta-E-z c1 c2)
ΔE* calculated in JAB color space.
ΔE* calculated in JAB color space.
(delta-H* c1 c2)
ΔH* difference, hue difference in LAB, CIE 1976
ΔH* difference, hue difference in LAB, CIE 1976
(desaturate col)
(desaturate col amt)
Change color saturation in LCH color space.
Change color saturation in LCH color space.
(fe-color-matrix [r1 r2 r3 r4 r5 g1 g2 g3 g4 g5 b1 b2 b3 b4 b5 a1 a2 a3 a4 a5])
Create a feColorMatrix operator.
Create a feColorMatrix operator.
(format-hex c)
Convert color to hex string (css).
When alpha is lower than 255.0, #rgba is returned.
Convert color to hex string (css). When alpha is lower than 255.0, #rgba is returned.
(from-Cubehelix c)
Cubehelix -> RGB
For ranges, see to-Cubehelix
.
Cubehelix -> RGB For ranges, see [[to-Cubehelix]].
(from-Cubehelix* c)
Cubehelix -> RGB, normalized
Cubehelix -> RGB, normalized
(from-GLHS c)
GLHS -> RGB
For ranges, see to-GLHS
.
GLHS -> RGB For ranges, see [[to-GLHS]].
(from-HCL c)
HCL -> RGB, by Sarifuddin and Missaou.
For accepted ranges, see to-HCL
.
HCL -> RGB, by Sarifuddin and Missaou. For accepted ranges, see [[to-HCL]].
HSB(V) -> RGB, normalized (see from-HSV
)
HSB(V) -> RGB, normalized (see [[from-HSV]])
(from-HSI c)
HSI -> RGB
For ranges, see to-HSI
.
HSI -> RGB For ranges, see [[to-HSI]].
(from-HSL c)
HSL -> RGB
For ranges, see to-HSL
.
HSL -> RGB For ranges, see [[to-HSL]].
(from-HunterLAB c)
HunterLAB -> RGB
For ranges, see to-HunterLAB
HunterLAB -> RGB For ranges, see [[to-HunterLAB]]
(from-HunterLAB* c)
HunterLAB -> RGB, normalized
HunterLAB -> RGB, normalized
(from-HWB c)
HWB -> RGB
For ranges, see to-HWB
.
HWB -> RGB For ranges, see [[to-HWB]].
(from-IgPgTg* c)
IgPgTg -> RGB, normalized
IgPgTg -> RGB, normalized
(from-JAB c)
JzAzBz -> RGB
For ranges, see to-JAB
.
JzAzBz -> RGB For ranges, see [[to-JAB]].
(from-JCH c)
JCH -> RGB
For ranges, see to-JCH
.
JCH -> RGB For ranges, see [[to-JCH]].
(from-LAB c)
LAB -> RGB,
For ranges, see to-LAB
LAB -> RGB, For ranges, see [[to-LAB]]
(from-LCH c)
LCH -> RGB
For ranges, see to-LCH
.
LCH -> RGB For ranges, see [[to-LCH]].
(from-LCHuv c)
LCHuv -> RGB
For ranges, see to-LCH
.
LCHuv -> RGB For ranges, see [[to-LCH]].
(from-linear v)
Gamma correction (gamma=1/2.4), lighten
Gamma correction (gamma=1/2.4), lighten
(from-LMS c)
LMS -> RGB, D65
Ranges: 0.0 - 100.0
LMS -> RGB, D65 Ranges: 0.0 - 100.0
(from-luma-color-hue from c)
For given color space convert from polar representation of the color
For given color space convert from polar representation of the color
(from-LUV c)
LUV -> RGB
For ranges, see to-LUV
LUV -> RGB For ranges, see [[to-LUV]]
(from-OHTA c)
OHTA -> RGB
For ranges, see to-OHTA
.
OHTA -> RGB For ranges, see [[to-OHTA]].
(from-Okhsl* c)
Okhsl -> sRGB, normalized
Okhsl -> sRGB, normalized
(from-Okhsv* c)
Okhsv -> sRGB, normalized
Okhsv -> sRGB, normalized
(from-Okhwb* c)
Okhwb -> sRGB, normalized
Okhwb -> sRGB, normalized
(from-Oklab c)
Oklab -> RGB, see to-Oklab
Oklab -> RGB, see [[to-Oklab]]
(from-OSA c)
RGB -> OSA-UCS
For ranges, see to-OSA
.
RGB -> OSA-UCS For ranges, see [[to-OSA]].
(from-OSA* c)
OSA-UCS -> RGB, normalized
Note that due to some extreme outliers, normalization is triple cubic power for g
and j
.
OSA-UCS -> RGB, normalized Note that due to some extreme outliers, normalization is triple cubic power for `g` and `j`.
(from-XYZ c)
XYZ -> sRGB
For ranges, see to-XYZ
XYZ -> sRGB For ranges, see [[to-XYZ]]
(from-XYZ1 c)
XYZ -> sRGB, from range 0-1
XYZ -> sRGB, from range 0-1
(from-YCbCr c)
YCbCr -> RGB
For ranges, see to-YCbCr
.
YCbCr -> RGB For ranges, see [[to-YCbCr]].
(from-YCgCo c)
YCgCo -> RGB
For ranges, see to-YCgCo
.
YCgCo -> RGB For ranges, see [[to-YCgCo]].
(from-YDbDr c)
YDbDr -> RGB
For ranges, see to-YDbDr
.
YDbDr -> RGB For ranges, see [[to-YDbDr]].
(from-YIQ c)
YIQ -> RGB
For ranges, see to-YIQ
.
YIQ -> RGB For ranges, see [[to-YIQ]].
(from-YPbPr c)
YPbPr -> RGB
For ranges, see to-YPbPr
.
YPbPr -> RGB For ranges, see [[to-YPbPr]].
(from-YUV c)
YUV -> RGB
For ranges, see to-YUV
.
YUV -> RGB For ranges, see [[to-YUV]].
(from-Yxy c)
Yxy -> sRGB
For ranges, see to-Yxy
.
Yxy -> sRGB For ranges, see [[to-Yxy]].
(get-channel col channel)
(get-channel col colorspace channel)
Get chosen channel. Works with any color space.
Get chosen channel. Works with any color space.
(gradient)
(gradient palette-or-gradient-name)
(gradient palette-or-gradient-name options)
Return gradient function.
Grandient function accepts value from 0 to 1 and returns interpolated color.
Parameters;
palette-or-gradient-name
- name of the predefined gradient or palette (seq of colors).:colorspace
- operate in given color space. Default: :RGB
.:interpolation
- interpolation name or interpolation function. Interpolation can be one of [[interpolators-1d-list]] or [[easings-list]]. When easings is used, only first two colors are interpolated. Default: :linear-smile
.:to?
- turn on/off conversion to given color space. Default: true
.:from?
- turn on/off conversion from given color space. Default: true
.:domain
- interpolation domain as seq of values for each color.When called without parameters random gradient is returned.
Return gradient function. Grandient function accepts value from 0 to 1 and returns interpolated color. Parameters; * `palette-or-gradient-name` - name of the [predefined gradient](../static/gradients.html) or palette (seq of colors). * (optional) additional parameters map: * `:colorspace` - operate in given color space. Default: `:RGB`. * `:interpolation` - interpolation name or interpolation function. Interpolation can be one of [[interpolators-1d-list]] or [[easings-list]]. When easings is used, only first two colors are interpolated. Default: `:linear-smile`. * `:to?` - turn on/off conversion to given color space. Default: `true`. * `:from?` - turn on/off conversion from given color space. Default: `true`. * `:domain` - interpolation domain as seq of values for each color. When called without parameters random gradient is returned.
Cubehelix gradient generator from two colors.
Cubehelix gradient generator from two colors.
(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]]
(green c)
Returns green (second channel) value.
Returns green (second channel) value.
(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]].
(hue-paletton c)
(hue-paletton 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).
(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]].
(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.
(lclamp c)
Clamp all color channels to [0-255]
range. Round if necessary.
Clamp all color channels to `[0-255]` range. Round if necessary.
(lerp+ c1 c2)
(lerp+ c1 c2 amount)
(lerp+ c1 c2 colorspace amount)
Linear interpolation of two colors conserving luma of the second color.
Amount: strength of the blend (defaults to 0.5).
See also lerp-
.
Linear interpolation of two colors conserving luma of the second color. Amount: strength of the blend (defaults to 0.5). See also [[lerp-]].
(lerp- c1 c2)
(lerp- c1 c2 amount)
(lerp- c1 c2 colorspace amount)
Linear interpolation of two colors conserving luma of the first color.
Amount: strength of the blend (defaults to 0.5)
See also lerp+
.
Linear interpolation of two colors conserving luma of the first color. Amount: strength of the blend (defaults to 0.5) See also [[lerp+]].
(make-LCH cs)
Create LCH conversion functions pair from any luma based color space.
Create LCH conversion functions pair from any luma based color space.
(merge-gradients g1 g2)
(merge-gradients g1 g2 midpoint)
Combine two gradients, optionally select midpoint
(0.5 by default).
Resulting gradient has colors from g1
for values lower than midpoint
and from g2
for values higher than midpoint
Combine two gradients, optionally select `midpoint` (0.5 by default). Resulting gradient has colors from `g1` for values lower than `midpoint` and from `g2` for values higher than `midpoint`
(mix c1 c2)
(mix c1 c2 t)
(mix c1 c2 colorspace t)
Mix colors in given optional colorspace
(default: :RGB
) and optional ratio (default: 0.5).
chroma.js way
Mix colors in given optional `colorspace` (default: `:RGB`) and optional ratio (default: 0.5). chroma.js way
(mixbox col1 col2)
(mixbox col1 col2 t)
Pigment based color mixing.
Pigment based color mixing. https://github.com/scrtwpns/mixbox
(mixsub c1 c2)
(mixsub c1 c2 t)
(mixsub c1 c2 colorspace t)
Subtractive color mix in given optional colorspace
(default: :RGB
) and optional ratio (default: 0.5)
Subtractive color mix in given optional `colorspace` (default: `:RGB`) and optional ratio (default: 0.5)
(modulate col channel amount)
(modulate col colorspace channel amount)
Modulate (multiply) chosen channel by given amount. Works with any color space.
Modulate (multiply) chosen channel by given amount. Works with any color space.
(named-colors-list)
Return list of the named colors.
Return list of the named colors.
(nearest-color pal)
(nearest-color pal c)
(nearest-color pal c dist-fn)
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.
(negate c)
(negate c alpha?)
Negate color (subract from 255.0)
Negate color (subract from 255.0)
(not-black? c)
Check if color is not black
Check if color is not black
(noticable-different? c1 c2)
(noticable-different? c1 c2 s p)
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
(pack c)
Pack color to ARGB 32bit integer.
Pack color to ARGB 32bit integer.
(palette)
(palette p)
(palette p number-of-colors)
(palette p number-of-colors gradient-params)
Get palette.
If argument is a keyword, returns one from palette presets.
If argument is a number, returns one from colourlovers palettes.
If argument is a gradient, returns 5 or number-of-colors
samples.
If called without argument, random palette is returned
Optionally you can pass number of requested colors and other parameters as in resample
Get palette. If argument is a keyword, returns one from palette presets. If argument is a number, returns one from colourlovers palettes. If argument is a gradient, returns 5 or `number-of-colors` samples. If called without argument, random palette is returned Optionally you can pass number of requested colors and other parameters as in [[resample]]
Create paletton palette.
Input:
:monochromatic
(one hue), :triad
(three hues), :tetrad
(four hues)hue-paletton
to get hue value).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 [[hue-paletton]] 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.
(possible-color? c)
Check if given argument can be considered as color.
Check is done by analyzing type of the argument.
See also valid-color?
.
Check if given argument can be considered as color. Check is done by analyzing type of the argument. See also [[valid-color?]].
(possible-palette? c)
Check if given argument can be considered as palette.
Check is done by analyzing type of the argument.
Check if given argument can be considered as palette. Check is done by analyzing type of the argument.
Convert color to quil
color type (ie. ARGB Integer). Alias to pack
.
Convert color to `quil` color type (ie. ARGB Integer). Alias to [[pack]].
(random-color)
(random-color alpha-or-color-theme)
(random-color color-theme alpha)
Generate random color.
Optionally color theme or alpha can be provided.
List of possible color themes is stored in color-themes
var. These are taken from thi.ng and paletton.
Generate random color. Optionally color theme or alpha can be provided. List of possible color themes is stored in `color-themes` var. These are taken from thi.ng and paletton.
(random-gradient)
Generate random gradient function.
Generate random gradient function.
(random-palette)
Generate random palette from all collections defined in clojure2d.color namespace.
Generate random palette from all collections defined in clojure2d.color namespace.
(red c)
Returns red (first channel) value.
Returns red (first channel) value.
(reduce-colors xs number-of-colors)
(reduce-colors xs number-of-colors colorspace-or-dist)
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).
(relative-luma c)
Returns relative luminance
Returns relative luminance
(resample pal number-of-colors)
(resample pal number-of-colors 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.
(saturate col)
(saturate col amt)
Change color saturation in LCH color space.
Change color saturation in LCH color space.
(scale c v)
(scale c v alpha?)
Multiply color channels by given value, do not change alpha channel by default
Multiply color channels by given value, do not change alpha channel by default
(scale-down c)
(scale-down c alpha?)
Divide color channels by 255.0
Divide color channels by 255.0
(scale-up c)
(scale-up c alpha?)
Multiply color channels by 255.0
Multiply color channels by 255.0
(set-alpha c a)
Set alpha channel and return new color
Set alpha channel and return new color
(set-awt-alpha c a)
Set alpha channel and return Color
representation.
Set alpha channel and return `Color` representation.
(set-blue c val)
Set blue channel and return new color
Set blue channel and return new color
(set-ch0 c val)
Set red channel and return new color.
Set red channel and return new color.
(set-ch1 c val)
Set green channel and return new color.
Set green channel and return new color.
(set-ch2 c val)
Set blue channel and return new color
Set blue channel and return new color
(set-channel col channel val)
(set-channel col colorspace channel val)
Set chosen channel with given value. Works with any color space.
Set chosen channel with given value. Works with any color space.
(set-green c val)
Set green channel and return new color.
Set green channel and return new color.
(set-red c val)
Set red channel and return new color.
Set red channel and return new color.
(temperature t)
Color representing given black body temperature t
in Kelvins (or name as keyword).
Reference: CIE 1964 10 degree CMFs
Using improved interpolation functions.
Possible temperature names: :candle
, :sunrise
, :sunset
, :lightbulb
, :morning
, :moonlight
, :midday
, :cloudy-sky
, :blue-sky
, :warm
, :cool
, :white
, :sunlight
Color representing given black body temperature `t` in Kelvins (or name as keyword). Reference: CIE 1964 10 degree CMFs Using improved interpolation functions. Possible temperature names: `:candle`, `:sunrise`, `:sunset`, `:lightbulb`, `:morning`, `:moonlight`, `:midday`, `:cloudy-sky`, `:blue-sky`, `:warm`, `:cool`, `:white`, `:sunlight`
(tinter tint-color)
Creates fn to tint color using other color(s).
tint-color
Creates fn to tint color using other color(s). `tint-color`
(to-awt-color c)
Convert any color representation to java.awt.Color
.
Convert any color representation to `java.awt.Color`.
(to-color c)
Convert any color representation to Vec4
vector.
Convert any color representation to `Vec4` vector.
(to-Cubehelix c)
RGB -> Cubehelix
D3 version
Ranges:
RGB -> Cubehelix D3 version Ranges: * H: 0.0 - 360.0 * S: 0.0 - 4.61 * L: 0.0 - 1.0
(to-Cubehelix* c)
RGB -> Cubehelix, normalized
RGB -> Cubehelix, normalized
(to-GLHS c)
RGB -> GLHS
Color Theory and Modeling for Computer Graphics, Visualization, and Multimedia Applications (The Springer International Series in Engineering and Computer Science) by Haim Levkowitz
Weights: 0.2 (min), 0.1 (mid), 0.7 (max).
Ranges:
RGB -> GLHS Color Theory and Modeling for Computer Graphics, Visualization, and Multimedia Applications (The Springer International Series in Engineering and Computer Science) by Haim Levkowitz Weights: 0.2 (min), 0.1 (mid), 0.7 (max). Ranges: * L: 0.0 - 1.0 * H: 0.0 - 360.0 * S: 0.0 - 1.0
(to-HCL c)
RGB -> HCL, by Sarifuddin and Missaou.
lambda = 3.0
Returned ranges:
RGB -> HCL, by Sarifuddin and Missaou. lambda = 3.0 Returned ranges: * H: -180.0 - 180.0 * C: 0.0 - 170.0 * L: 0.0 - 135.266
RGB -> HSB(V), normalized (see to-HSV
)
RGB -> HSB(V), normalized (see [[to-HSV]])
(to-HSI c)
RGB -> HSI
Ranges:
RGB -> HSI Ranges: * H: 0.0 - 360 * S: 0.0 - 1.0 * I: 0.0 - 1.0
(to-HSL c)
RGB -> HSL
Ranges:
RGB -> HSL Ranges: * H: 0.0 - 360 * S: 0.0 - 1.0 * L: 0.0 - 1.0
(to-HSV c)
RGB -> HSV
Ranges:
RGB -> HSV Ranges: * H: 0.0 - 360 * S: 0.0 - 1.0 * V: 0.0 - 1.0
(to-HunterLAB c)
RGB -> HunterLAB
Returned ranges:
RGB -> HunterLAB Returned ranges: * L: 0.0 - 100.0 * a: -69.08 - 109.48 * b: -199.78 - 55.72
(to-HunterLAB* c)
RGB -> HunterLAB, normalized
RGB -> HunterLAB, normalized
(to-HWB c)
RGB -> HWB
HWB - A More Intuitive Hue-Based Color Model by Alvy Ray Smitch and Eric Ray Lyons, 1995-1996
Ranges:
RGB -> HWB HWB - A More Intuitive Hue-Based Color Model by Alvy Ray Smitch and Eric Ray Lyons, 1995-1996 Ranges: * H: 0.0 - 360.0 * W: 0.0 - 1.0 * B: 0.0 - 1.0
(to-IgPgTg c)
RGB -> IgPgTg
Ranges:
RGB -> IgPgTg Ranges: * Ig: 0.0 - 0.97 * Pg: -0.35 - 0.39 * Tg: -0.41 - 0.44
(to-IgPgTg* c)
RGB -> IgPgTg*, normalized
RGB -> IgPgTg*, normalized
(to-IPT c)
RGB -> IPT
Ranges:
RGB -> IPT Ranges: * I: 0.0 - 1.0 * P: -0.45 - 0.66 * T: -0.75 - 0.65
(to-JAB c)
RGB -> JzAzBz
Jab https://www.osapublishing.org/oe/abstract.cfm?uri=oe-25-13-15131
Ranges:
Reference white point set to 100.0
RGB -> JzAzBz Jab https://www.osapublishing.org/oe/abstract.cfm?uri=oe-25-13-15131 Ranges: * J: 0.0 - 0.17 * a: -0.09 - 0.11 * b: -0.156 - 0.115 Reference white point set to 100.0
(to-JCH c)
RGB -> JCH
Hue based color space derived from JAB
Ranges:
RGB -> JCH Hue based color space derived from JAB Ranges: * J: 0.0 - 0.167 * C: 0.0 - 0.159 * H: 0.0 - 360.0
(to-LAB c)
RGB -> LAB
Returned ranges:
RGB -> LAB Returned ranges: * L: 0.0 - 100.0 * a: -86.18 - 98.25 * b: -107.86 - 94.48
(to-LCH c)
RGB -> LCH
Returned ranges:
RGB -> LCH Returned ranges: * L: 0.0 - 100.0 * C: 0.0 - 133.82 * H: 0.0 - 360.0
(to-LCHuv c)
RGB -> LCHuv
Returned ranges:
RGB -> LCHuv Returned ranges: * L: 0.0 - 100.0 * C: 0.0 - 180.0 * H: 0.0 - 360.0
(to-linear v)
Gamma correction (gamma=2.4), darken
Gamma correction (gamma=2.4), darken
(to-LMS c)
RGB -> LMS, D65
Ranges: 0.0 - 100.0
RGB -> LMS, D65 Ranges: 0.0 - 100.0
(to-luma-color-hue to c)
For given color space return polar representation of the color
For given color space return polar representation of the color
(to-LUV c)
RGB -> LUV
Returned ranges:
RGB -> LUV Returned ranges: * L: 0.0 - 100.0 * u: -83.08 - 175.05 * v: -134.12 - 107.40
(to-OHTA c)
RGB -> OHTA
Returned ranges:
RGB -> OHTA Returned ranges: * I1: 0.0 - 255.0 * I2: -127.5 - 127.5 * I3: -127.5 - 127.5
(to-Okhsl c)
sRGB -> Okhsl
Ranges:
sRGB -> Okhsl Ranges: * h: 0.0 - 1.0 * s: 0.0 - 1.0 * l: 0.0 - 1.0
(to-Okhsv c)
sRGB -> Okhsv
Ranges:
sRGB -> Okhsv Ranges: * h: 0.0 - 1.0 * s: 0.0 - 1.0 * v: 0.0 - 1.0
(to-Okhwb c)
sRGB -> Okhwb
Ranges:
sRGB -> Okhwb Ranges: * h: 0.0 - 1.0 * w: 0.0 - 1.0 * b: 0.0 - 1.0
(to-Oklab c)
RGB -> Oklab
https://bottosson.github.io/posts/oklab/
RGB -> Oklab https://bottosson.github.io/posts/oklab/ * L: 0.0 - 1.0 * a: -0.234 - 0.276 * b: -0.312 - 0.199
(to-OSA c)
OSA-UCS -> RGB
https://github.com/nschloe/colorio/blob/master/colorio/_osa.py
Ranges:
Note that for some cases (like (to-OSA [18 7 4])
) function returns some extreme values.
OSA-UCS -> RGB https://github.com/nschloe/colorio/blob/master/colorio/_osa.py Ranges: * L: -13.5 - 7.14 * j (around): -20.0 - 14.0 + some extreme values * g (around): -20.0 - 12.0 + some extreme values Note that for some cases (like `(to-OSA [18 7 4])`) function returns some extreme values.
(to-OSA* c)
OSA-UCS -> RGB, normalized
Note that due to some extreme outliers, normalization is triple cubic root for g
and j
.
OSA-UCS -> RGB, normalized Note that due to some extreme outliers, normalization is triple cubic root for `g` and `j`.
(to-UCS c)
sRGB -> UCS
sRGB -> UCS * U: 0.0 - 0.63 * V: 0.0 - 1.0 * W: 0.0 - 1.57
(to-UVW c)
sRGB -> UVW
sRGB -> UVW * U: -82.15 171.81 * V: -87.16 70.82 * W: -17.0 99.0
(to-XYB c)
sRGB -> XYB
sRGB -> XYB * X: -0.015386116472573375 - 0.02810008316127735 * Y: 0.0 - 0.8453085619621623 * Z: 0.0 - 0.8453085619621623
(to-XYZ c)
sRGB -> XYZ
Returned ranges (D65):
sRGB -> XYZ Returned ranges (D65): * X: 0.0 - 95.047 * Y: 0.0 - 100.0 * Z: 0.0 - 108.883
(to-XYZ1 c)
sRGB -> XYZ, scaled to range 0-1
sRGB -> XYZ, scaled to range 0-1
(to-YCbCr c)
RGB -> YCbCr
Used in JPEG. BT-601
Ranges;
RGB -> YCbCr Used in JPEG. BT-601 Ranges; * Y: 0.0 - 255.0 * Cb: -127.5 - 127.5 * Cr: -127.5 - 127.5
(to-YCgCo c)
RGB -> YCgCo
Ranges:
RGB -> YCgCo Ranges: * Y: 0.0 - 255.0 * Cg: -127.5 - 127.5 * Co: -127.5 - 127.5
(to-YDbDr c)
RGB -> YDbDr
Ranges:
RGB -> YDbDr Ranges: * Y: 0.0 - 255.0 * Db: -340.0 - 340.0 * Dr: -340.0 - 340.0
(to-YIQ c)
RGB -> YIQ
Ranges:
RGB -> YIQ Ranges: * Y: 0.0 - 255.0 * I: -151.9 - 151.9 * Q: -133.26 - 133.26
(to-YPbPr c)
RGB -> YPbPr
Ranges:
RGB -> YPbPr Ranges: * Y: 0.0 - 255.0 * Pb: -236.6 - 236.6 * Pr: -200.8 - 200.8
(to-YUV c)
RGB -> YUV
Ranges:
RGB -> YUV Ranges: * Y: 0.0 - 255.0 * u: -111.2 - 111.2 * v: -156.8 - 156.8
(to-Yxy c)
sRGB -> Yxy
Returned ranges:
sRGB -> Yxy Returned ranges: * Y: 0.0 - 100.0 * x: 0.15 - 0.64 * y: 0.06 - 0.60
(valid-color? c)
Check if given argument is valid color.
Check is done by trying to convert to color representation.
Returns color when valid.
See also possible-color?
Check if given argument is valid color. Check is done by trying to convert to color representation. Returns color when valid. See also [[possible-color?]]
(wavelength lambda)
Returns color from given wavelength in nm
Returns color from given wavelength in nm
(weighted-average cs weights)
(weighted-average cs weights colorspace)
Average colors with weights in given colorspace
(default: :sRGB
)
Average colors with weights in given `colorspace` (default: `:sRGB`)
(whiten col)
(whiten col amt)
Change color towards white.
Works in HSB color space. Default amount is set to 0.2 and changes W channel by this amount.
See blacken
.
Change color towards white. Works in HSB color space. Default amount is set to 0.2 and changes W channel by this amount. See [[blacken]].
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close