rgb2col: Find Named Color Closest to Given Hex RGB Colors This...

Description Usage Arguments Value Source Examples

Description

Find Named Color Closest to Given Hex RGB Colors This function calculates the distance (in CIE Lab color space) between the input colors (in RGB hex notation) and all named colors() It returns the closest named color within a given threshold distance.

Usage

1
rgb2col(cols, near = 2.3)

Arguments

cols

A vector of colors, in RGB hex notation, e.g., "\#00AE30"

near

Threshold for nearest color from colors(). The default corresponds to 1 JND in Lab space.

Value

A vector of color names, or the hex value if no color is close enough

Source

From J. Fox, R-help, 5-30-2013

Examples

1
2
3
cols <- c("#010101", "#EEEEEE", "#AA0000", "#00AA00", "#0000AA", "#AAAA00", "#AA00AA", "#00AAAA")
(nms <- rgb2col(cols))
pie(rep(1, 2*length(cols)), labels=c(rbind(cols, nms)), col=c(rbind(cols, nms)))

friendly/myutil documentation built on May 16, 2019, 3:29 p.m.