unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Face color changes
@ 2004-12-26 19:57 Juri Linkov
  2004-12-26 23:49 ` Miles Bader
                   ` (2 more replies)
  0 siblings, 3 replies; 39+ messages in thread
From: Juri Linkov @ 2004-12-26 19:57 UTC (permalink / raw)


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/

^ permalink raw reply	[flat|nested] 39+ messages in thread

end of thread, other threads:[~2005-01-04  9:08 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-12-26 19:57 Face color changes Juri Linkov
2004-12-26 23:49 ` Miles Bader
2004-12-27  8:28   ` Eli Zaretskii
2004-12-27  8:47     ` Jan D.
2004-12-27 22:35       ` Richard Stallman
2004-12-27  8:50     ` Miles Bader
2004-12-27 11:15       ` Eli Zaretskii
2004-12-27 17:16         ` Drew Adams
2004-12-27 17:32           ` Eli Zaretskii
2004-12-27 17:44             ` Drew Adams
2004-12-27 21:49               ` Eli Zaretskii
2004-12-29  7:41                 ` Drew Adams
2004-12-29 15:31                   ` Alex Schroeder
2004-12-29 19:38                     ` Robert J. Chassell
2004-12-29 20:00                     ` Robert J. Chassell
2004-12-30 16:43                   ` Richard Stallman
2004-12-28  2:52             ` Juri Linkov
2004-12-28 17:25               ` Richard Stallman
2004-12-28 20:16               ` Eli Zaretskii
2004-12-29  4:38                 ` Richard Stallman
2004-12-29  5:04                 ` Juri Linkov
2004-12-29 15:26                   ` Alex Schroeder
2004-12-30  0:22                     ` Richard Stallman
2004-12-30 14:18                       ` Alex Schroeder
2004-12-30 20:59                         ` Richard Stallman
2004-12-30  1:27                     ` Miles Bader
2004-12-30 14:15                       ` Alex Schroeder
2004-12-30 16:43                       ` Richard Stallman
2004-12-30 21:16                         ` Miles Bader
2005-01-01  5:24                           ` Richard Stallman
2005-01-03 18:17                             ` Kevin Rodgers
2005-01-04  3:36                               ` Richard Stallman
2005-01-04  9:08                           ` Juri Linkov
2004-12-27 22:35           ` Richard Stallman
2004-12-28  2:57         ` Juri Linkov
2004-12-27 18:06   ` Richard Stallman
2004-12-27  8:12 ` Eli Zaretskii
2004-12-28  4:57 ` Richard Stallman
2004-12-28 20:31   ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).