Skip to contents

Convert a color to grayscale

Usage

col2grayscale(x, what = c("color", "decimal"))

Arguments

x

Color to convert to grayscale

what

Character: "color" returns a hexadecimal color, "decimal" returns a decimal between 0 and 1

Value

Character: color hex code.

Details

Uses the NTSC grayscale conversion: 0.299 * R + 0.587 * G + 0.114 * B

Author

EDG

Examples

col2grayscale("red")
#> [1] "#4C4C4C"
col2grayscale("red", "dec")
#>   red 
#> 0.299