7 ms·
Thank you. https://github.com/Zaku-eu/colourco.de/blob/be7a41500fd1b3580c748cf139e9d8b52f67705b/client/converter.coffee#L73 https://github.com/Zaku-eu/colourco
by scottjad 13y ago
Thank you.
https://github.com/Zaku-eu/colourco.de/blob/be7a41500fd1b3580c748cf139e9d8b52f67705b/client/converter.coffee#L73 https://github.com/Zaku-eu/colourco.de/blob/be7a41500fd1b358...
or a convenient Emacs command/function:
(defun rgb-to-fgc (&optional background)
"Returns a hex RGB triplet string for a chosen color or
BACKGROUND."
(interactive)
(let ((background-rgb (color-name-to-rgb (or background
(read-color nil t))))
(m (/ 96.0 255))
(foreground-rgb (mapcar (lambda (x)
(+ x (if (> (apply #'max background-rgb)
(- 1 m))
(* m -1)
m)))
background-rgb))
(foreground (apply #'color-rgb-to-hex foreground-rgb)))
(message foreground)
foreground))