HexToCol.Rd
Given a color as a hex string #rrggbb, find the closest match in the table of known (named) colors.
HexToCol(hexstr, method = "rgb", metric = "euclidean")
a color or a vector of colors specified as hexadecimal string of the form "#RRGGBB" or "#RRGGBBAA"
character string specifying the color space to be used. Can be "rgb" (default) or "hsv".
character string specifying the metric to be used for calculating distances between the colors. Available options are "euclidean" (default) and "manhattan". Euclidean distances are root sum-of-squares of differences, and manhattan distances are the sum of absolute differences.
Finds the color with the minimum squared distance in RGB space.
The colorname(s) of the closest match(es) (if more than one).
ColToHex(c("lightblue", "salmon"))
#> [1] "#ADD8E6" "#FA8072"
HexToCol(c("#ADD8E6", "#FA1572"))
#> [1] "lightblue" "deeppink2"
HexToCol(Pal("Helsana"))
#> [1] "deeppink4" "darkorange2" "goldenrod1" "navajowhite3" "hotpink3"
#> [6] "skyblue3" "gold3" "gray80" "gray40" "white"
x <- ColToRgb("darkmagenta")
x[2,] <- x[2,] + 155
RgbToCol(x)
#> [1] "gray57"