For a given set of colors, contrastColors returns an associated set of colors.

contrastColors(colors, how = "how_borw", alpha = FALSE)

col2Hex(colors, alpha = FALSE)

Arguments

colors

vector of any of the three kinds of R color specifications, see grDevices::col2rgb().

how

a method to contrast colors. Methods currently available are how_borw, how_cent, how_oppo and how_prop, see details.

alpha

logical value indicating whether the alpha channel (opacity) values should be returned.

Details

Based on the sum of colors' saturation how_borw returns black or white, how_prop proportionally remove or add some saturation. how_oppo opposes the color (255-x) and how_cent centers the columns, i.e. remove or add 127.

Functions

  • contrastColors: Retuns a set of colors contrasted.

  • col2Hex: Returns the hexadecimal string associates to a given vector of colors.

See also

Examples

contrastColors('blue')
#> [1] "#ffffff"
contrastColors('blue', how = 'how_prop')
#> [1] "#bfbfff"