[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Face color changes
From: |
Juri Linkov |
Subject: |
Face color changes |
Date: |
Sun, 26 Dec 2004 21:57:38 +0200 |
User-agent: |
Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux) |
I noticed that some face colors are bad choices. The worst example
is "RosyBrown" used for font-lock-string-face on light backgrounds.
It has high intensity which corresponds to light colors. No wonder
that this color is hardly visible on light backgrounds.
I got the formula from x_alloc_nearest_color_1 to calculate a dark color
nearest to "rosybrown". The code is below:
(let* ((frame (selected-frame))
(color-values (mapcar (lambda (v) (lsh v -8))
(x-color-values "rosybrown" frame)))
(c-r (nth 0 color-values))
(c-g (nth 1 color-values))
(c-b (nth 2 color-values)))
(list-colors-display
(delq nil (mapcar
(lambda (c) (and (eq (color-mode (cadr c)) 'dark) (cadr c)))
(sort (mapcar
(lambda (c)
(let* ((c-values (mapcar
(lambda (v) (lsh v -8))
(x-color-values (car c) frame)))
(d-r (- c-r (nth 0 c-values)))
(d-g (- c-g (nth 1 c-values)))
(d-b (- c-b (nth 2 c-values))))
(list (+ (* d-r d-r) (* d-g d-g) (* d-b d-b)) (car
c))))
(list-colors-duplicates))
(lambda (a b) (< (car a) (car b))))))
"*Colors-Nearest*"))
(defun color-mode (bg-color)
(let ((frame (selected-frame)))
(if (let ((bg-color-values (x-color-values bg-color frame))
(white-values (x-color-values "white" frame)))
(>= (+ (* (nth 0 bg-color-values) 0.30)
(* (nth 1 bg-color-values) 0.59)
(* (nth 2 bg-color-values) 0.11))
(* (+ (* (nth 0 white-values) 0.30)
(* (nth 1 white-values) 0.59)
(* (nth 2 white-values) 0.11))
.5)))
'light 'dark)))
It suggests to replace "rosybrown" by "plum4" or "PaleVioletRed4", and
"orchid" (for font-lock-builtin-face) by "MediumOrchid3" or "DarkOrchid3".
If this is correct, other face colors could be improved as well
to match their background mode (i.e. to use light colors on dark
backgrounds, and dark colors on light backgrounds).
--
Juri Linkov
http://www.jurta.org/emacs/
- Face color changes,
Juri Linkov <=
- Re: Face color changes, Miles Bader, 2004/12/26
- Re: Face color changes, Eli Zaretskii, 2004/12/27
- Re: Face color changes, Miles Bader, 2004/12/27
- Re: Face color changes, Eli Zaretskii, 2004/12/27
- RE: Face color changes, Drew Adams, 2004/12/27
- Re: Face color changes, Eli Zaretskii, 2004/12/27
- RE: Face color changes, Drew Adams, 2004/12/27
- Re: Face color changes, Eli Zaretskii, 2004/12/27
- RE: Face color changes, Drew Adams, 2004/12/29
- Re: Face color changes, Alex Schroeder, 2004/12/29