View source: R/compute_CMClc.R
CMClc | R Documentation |
Compute the difference between two colors, using the CMC l:c metric. https://en.wikipedia.org/wiki/Color_difference#CMC_l:c_(1984).
CMClc(x, y, l = 1, c = 1)
x , y |
colors specified as hex strings or named R colors. |
l , c |
weighting factors for lightness and chromacity. |
A number quantifying the difference between x and y (or a vector thereof).
deltaE
for another (probably more consistent) metric of difference between colors and color_distance
for a numerical definition of the distance between two colors.
CMClc("pink", "hotpink")
CMClc("pink", "blue")
# NB: his definition of distance is not symetrical
CMClc("pink", "blue")
CMClc("blue", "pink")
# The computation can be vectorised
# For example to find the closest color in an array of possibilities
clrs <- rainbow(20)
show_col("pink", clrs)
d <- CMClc("pink", clrs)
show_col("pink", clrs[which.min(d)])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.