864 |
(if (< mag 1) 0 (acos (/ (+ r g b) mag))))) |
(if (< mag 1) 0 (acos (/ (+ r g b) mag))))) |
865 |
|
|
866 |
(defun tty-color-approximate (rgb &optional frame) |
(defun tty-color-approximate (rgb &optional frame) |
867 |
"Given a list of 3 rgb values in RGB, find the color in `tty-color-alist' |
"Find the color in `tty-color-alist' that best approximates RGB. |
868 |
which is the best approximation in the 3-dimensional RGB space, |
Value is a list of the form \(NAME INDEX R G B\). |
869 |
and return its description. |
The argument RGB should be an rgb value, that is, a list of three |
870 |
|
integers in the 0..65535 range. |
|
Value is a list of the form \(NAME INDEX R G B\). Note that the returned |
|
|
NAME is not necessarily the same string as the argument COLOR, because |
|
|
the latter might need to be approximated if it is not supported directly. |
|
|
|
|
|
Each value of the RGB triplet should be in the range 0..65535 range. |
|
871 |
FRAME defaults to the selected frame." |
FRAME defaults to the selected frame." |
872 |
(let* ((color-list (tty-color-alist frame)) |
(let* ((color-list (tty-color-alist frame)) |
873 |
(candidate (car color-list)) |
(candidate (car color-list)) |