Match RGB codes (color codes, HTML colors) to names easily and precisely.
Color names and shades are taken from Name that Color JavaScript by Chirag Mehta and Color Name & Hue by Colblindor.
It’s available on Melpa:
M-x package-install name-this-color
Or you can just dump name-this-color.el
in your load path somewhere.
Add this to the big comment block at the top:
;; Package-Requires: ((name-this-color "0.2.0"))
Returns the name of the color represented by color code or the name of the closest alternative.
code
should be a string naming a color (for example, “white”) or a string
specifying a color’s RGB components (for example, “#ff12ec” or “f0f0f0”). Note
that only valid color names (per color.el
) and RGB codes (6 characters,
possibly prepended by a ‘#’) are recognized.
(ntc-name-this-color "#f3f3f3") ; "White Smoke"
(ntc-name-this-color "white") ; "White"
(ntc-name-this-color "#0c0000") ; "Free Speech Red"
(ntc-name-this-color "ff12ec") ; "Magenta"
Returns the shade of the color represented by color code or the shade of the closest alternative.
Shade could be one of the following: Red, Orange, Brown, Yellow, Green, Blue, Violet, Gray, or White.
code
should be a string naming a color (for example, “white”) or a string
specifying a color’s RGB components (for example, “#ff12ec” or “f0f0f0”). Note
that only valid color names (per color.el
) and RGB codes (6 characters,
possibly prepended by a ‘#’) are recognized.
(ntc-shade-this-color "#f3f3f3") ; "White"
(ntc-shade-this-color "white") ; "White"
(ntc-shade-this-color "#0c0000") ; "Red"
(ntc-shade-this-color "ff12ec") ; "Violet"
- Change the API, prefix all methods with
ntc-
, per elisp coding guidelines
- Initial code drop