hex_to_name: Convert HEX to colour name
Description
Reverse lookup using the bundled name database. When an exact match is not
found, you can return the nearest named colour (fallback = TRUE, the
default) or NA (fallback = FALSE).
Usage
hex_to_name(hex, fallback = TRUE, distance = c("lab", "oklch", "rgb", "hsl"))Value
Character vector of colour names (or NA).
Arguments
- hex
Character vector of hex colour strings.
- fallback
TRUE (default) to return the nearest named colour when
no exact match exists, or FALSE to return NA.
- distance
Distance metric for nearest-colour fallback: one of "lab"
(default), "oklch", "rgb", or "hsl".
Examples
Run this codehex_to_name("#c93f38")
hex_to_name("#111114", fallback = TRUE)
Run the code above in your browser using DataLab