| distance | R Documentation |
The distance() function calculates a distance measure that aims to
quantify perceptual difference between a vector of colours and a reference
colour. The measure in question is the CIE Delta E (2000), which is
calculated based on colour coordinates in Lab space. Colour contrast relates
more specifically to legibility, in the context where text in one colour is
overlaid on a background in another. The W3C definition used here ranges
between 1 (identical colours, no contrast) and 21 (black on white, maximum
contrast).
distance(shades, reference)
contrast(shades, reference)
shades |
One or more colours, in any suitable form (see |
reference |
A single reference colour. |
A numeric vector of distances or contrasts.
Jon Clayden code@clayden.org
See http://www.brucelindbloom.com/index.html?Eqn_DeltaE_CIE2000.html for CIE Delta E. The contrast measure is defined as part of the W3C Web Content Accessibility Guidelines, version 2.0, detailed at https://www.w3.org/TR/WCAG20/.
distance(c("red","green","blue"), "red")
contrast(c("red","green","blue"), "red")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.