BGTextColor: Determine text color based on background color

Description Usage Arguments Value Source Examples

View source: R/visualization.R

Description

Determine text color based on background color

Usage

1
2
3
4
5
6
7
BGTextColor(
  background,
  threshold = 186,
  w3c = FALSE,
  dark = "black",
  light = "white"
)

Arguments

background

A vector of background colors; supports R color names and hexadecimal codes

threshold

Intensity threshold for light/dark cutoff; intensities greater than theshold yield dark, others yield light

w3c

Use W3C formula for calculating background text color; ignores threshold

dark

Color for dark text

light

Color for light text

Value

A named vector of either dark or light, depending on background; names of vector are background

Source

https://stackoverflow.com/questions/3942878/how-to-decide-font-color-in-white-or-black-depending-on-background-color

Examples

1
BGTextColor(background = c('black', 'white', '#E76BF3'))

Seurat documentation built on Jan. 13, 2021, 7:11 p.m.