chroma_contrast: Contrast between two colors

Description Usage Arguments Value Examples

View source: R/chroma-utils.R

Description

Computes the WCAG contrast ratio between two colors. A minimum contrast of 4.5:1 is recommended to ensure that text is still readable against a background color.

Usage

1
chroma_contrast(color1, color2)

Arguments

color1

Hexadecimal string or a name for color.

color2

Hexadecimal string or a name for color.

Value

a numeric value

Examples

1
2
3
4
5
6
7
8
chroma_contrast("pink", "hotpink")


# black on light grey => good
chroma_contrast("#e3e3e3", "black")

# black on dark grey => bad
chroma_contrast("#393939", "black")

dreamRs/colorscale documentation built on April 17, 2020, 8:38 a.m.