cr_choose_bw: Choose White or Black to Overlay On a Supplied Background...

Description Usage Arguments Value Examples

View source: R/contrast.R

Description

Selects whether black or white has the greater contrast with a user- supplied color. Useful for choosing a text color to overlay on a block-color background, like value labels over the bars of a bar chart. Calculated as per cr_get_ratio. Defaults to black in the case of a tie.

Usage

1
cr_choose_bw(col_bg)

Arguments

col_bg

A character vector of colors against which to select either black or white, whichever has maximum contrast. Supply colors as six-digit hex values preceded by '#', or named colors from colors.

Value

A character vector of values "black" or "white". The length matches the input.

Examples

1
cr_choose_bw(c("white", "gray90", "gray50", "gray10", "black"))

matt-dray/coloratio documentation built on June 2, 2021, 6:42 a.m.