* Frame background mode
@ 2004-12-26 19:52 Juri Linkov
2004-12-27 8:04 ` Eli Zaretskii
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Juri Linkov @ 2004-12-26 19:52 UTC (permalink / raw)
I suggest to improve the formula used to determine whether the
background is light or dark. The new formula uses the optimal
weighting coefficients for RGB color components to reflect the
perception of color luminance.
Index: lisp/faces.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/faces.el,v
retrieving revision 1.297
diff -u -r1.297 faces.el
--- lisp/faces.el 23 Dec 2004 18:28:13 -0000 1.297
+++ lisp/faces.el 26 Dec 2004 18:44:06 -0000
@@ -1536,11 +1536,15 @@
'dark)
((equal bg-color "unspecified-fg") ; inverted colors
'light)
- ((>= (apply '+ (x-color-values bg-color frame))
- ;; Just looking at the screen, colors whose
- ;; values add up to .6 of the white total
- ;; still look dark to me.
- (* (apply '+ (x-color-values "white" frame)) .6))
+ ((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)
(t 'dark)))
(display-type
The most noticeable consequence of such change is that many green
colors (which really look like light colors) are moved to `light'
category.
Here is the code that displays the color changes between old and new
formulas (it needs the patch to facemenu.el I sent earlier):
(let ((frame (selected-frame)) diff-list new-dark-list new-light-list)
(dolist (color (list-colors-duplicates))
(let* ((bg-color (car color))
(old (if (>= (apply '+ (x-color-values bg-color frame))
(* (apply '+ (x-color-values "white" frame)) .6))
'light 'dark))
(new (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)))
(if (eq new 'light)
(setq new-light-list (cons color new-light-list))
(setq new-dark-list (cons color new-dark-list)))
(unless (eq old new)
(insert (format "%-22s %-5s %s\n" bg-color old new))
(setq diff-list (cons color diff-list)))))
(list-colors-display (reverse diff-list) "*Colors-Diff*")
(list-colors-display (reverse new-dark-list) "*Colors-Dark*")
(list-colors-display (reverse new-light-list) "*Colors-Light*"))
The changes in color mode it computes are the following (the second
column shows the mode computed by the old formula, the third column
by the new formula):
light slate gray dark light
medium slate blue light dark
deep sky blue dark light
dark turquoise dark light
cadet blue dark light
medium sea green dark light
light sea green dark light
spring green dark light
lawn green dark light
green dark light
chartreuse dark light
medium spring green dark light
lime green dark light
yellow green dark light
goldenrod dark light
dark goldenrod dark light
peru dark light
chocolate dark light
orange dark light
dark orange dark light
tomato dark light
magenta light dark
snow4 dark light
seashell4 dark light
AntiqueWhite4 dark light
LemonChiffon4 dark light
cornsilk4 dark light
ivory4 dark light
honeydew4 dark light
LavenderBlush4 dark light
MistyRose4 dark light
azure4 dark light
SlateBlue2 light dark
SteelBlue3 dark light
DeepSkyBlue1 dark light
DeepSkyBlue2 dark light
LightCyan4 dark light
PaleTurquoise4 dark light
turquoise3 dark light
cyan3 dark light
SeaGreen3 dark light
PaleGreen3 dark light
SpringGreen1 dark light
SpringGreen2 dark light
SpringGreen3 dark light
green1 dark light
green2 dark light
chartreuse1 dark light
chartreuse2 dark light
chartreuse3 dark light
OliveDrab3 dark light
DarkOliveGreen3 dark light
khaki4 dark light
LightYellow4 dark light
yellow3 dark light
gold2 dark light
gold3 dark light
goldenrod2 dark light
goldenrod3 dark light
DarkGoldenrod1 dark light
DarkGoldenrod2 dark light
DarkGoldenrod3 dark light
IndianRed2 dark light
sienna1 dark light
sienna2 dark light
sienna3 dark light
tan3 dark light
chocolate1 dark light
chocolate2 dark light
salmon3 dark light
LightSalmon3 dark light
orange1 dark light
orange2 dark light
orange3 dark light
DarkOrange1 dark light
DarkOrange2 dark light
coral1 dark light
coral2 dark light
tomato1 dark light
tomato2 dark light
HotPink3 dark light
PaleVioletRed3 dark light
maroon1 light dark
magenta1 light dark
magenta2 light dark
MediumOrchid3 light dark
DarkOrchid1 light dark
DarkOrchid2 light dark
thistle4 dark light
gray51 dark light
gray52 dark light
gray53 dark light
gray54 dark light
gray55 dark light
gray56 dark light
gray57 dark light
gray58 dark light
gray59 dark light
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Frame background mode
2004-12-26 19:52 Frame background mode Juri Linkov
@ 2004-12-27 8:04 ` Eli Zaretskii
2004-12-27 17:36 ` Drew Adams
2004-12-27 20:15 ` Juri Linkov
2004-12-28 4:57 ` Richard Stallman
2004-12-28 20:42 ` Luc Teirlinck
2 siblings, 2 replies; 11+ messages in thread
From: Eli Zaretskii @ 2004-12-27 8:04 UTC (permalink / raw)
Cc: emacs-devel
> From: Juri Linkov <juri@jurta.org>
> Date: Sun, 26 Dec 2004 21:52:54 +0200
>
> I suggest to improve the formula used to determine whether the
> background is light or dark.
Do we really need this so close to a pretest start? The new formula
will certainly change some backgrounds from dark to light and vice
versa, which will potentially annoy some users whose color
customizations will need to be reworked.
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: Frame background mode
2004-12-27 8:04 ` Eli Zaretskii
@ 2004-12-27 17:36 ` Drew Adams
2004-12-27 21:53 ` Eli Zaretskii
2004-12-27 20:15 ` Juri Linkov
1 sibling, 1 reply; 11+ messages in thread
From: Drew Adams @ 2004-12-27 17:36 UTC (permalink / raw)
Cc: emacs-devel
> I suggest to improve the formula used to determine whether the
> background is light or dark.
Do we really need this so close to a pretest start?
Dunno. Maybe not.
The new formula will certainly change some backgrounds from dark
to light and vice versa, which will potentially annoy some users
whose color customizations will need to be reworked.
That argument seems independent of _when_ such a change might be made; it
does not argue for not making the change _now_.
I think Juri is on the right track with this change. And experimentation
could help refine the formula.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Frame background mode
2004-12-27 8:04 ` Eli Zaretskii
2004-12-27 17:36 ` Drew Adams
@ 2004-12-27 20:15 ` Juri Linkov
2004-12-27 22:09 ` Eli Zaretskii
1 sibling, 1 reply; 11+ messages in thread
From: Juri Linkov @ 2004-12-27 20:15 UTC (permalink / raw)
Cc: emacs-devel
"Eli Zaretskii" <eliz@gnu.org> writes:
> The new formula will certainly change some backgrounds from dark to
> light and vice versa,
The new formula will affect only users who have background color set
to one of 98 colors I listed in the previous message.
> which will potentially annoy some users whose color customizations
> will need to be reworked.
No color customization needs to be reworked. The only change needed
for users affected by the new formula is to customize frame-background-mode
user option.
If even such small change is undesirable then maybe it's better to
leave the old formula alone, and to add a new condition keyword
(e.g. `min-background') that will specify the minimum color intensity
(a fraction between 0 and 1) and will use the new formula, for instance:
((class color) (min-colors 88) (min-background 0.5))
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Frame background mode
2004-12-27 17:36 ` Drew Adams
@ 2004-12-27 21:53 ` Eli Zaretskii
0 siblings, 0 replies; 11+ messages in thread
From: Eli Zaretskii @ 2004-12-27 21:53 UTC (permalink / raw)
Cc: juri, emacs-devel
> From: "Drew Adams" <drew.adams@oracle.com>
> Date: Mon, 27 Dec 2004 09:36:20 -0800
> Cc: emacs-devel@gnu.org
>
> The new formula will certainly change some backgrounds from dark
> to light and vice versa, which will potentially annoy some users
> whose color customizations will need to be reworked.
>
> That argument seems independent of _when_ such a change might be made; it
> does not argue for not making the change _now_.
Yes, it does: changing color defaults tends to prompt a long series of
patches, critique to those patches, discussions, counter-patches, etc.
That is a wrong way to get closer to the pretest.
> I think Juri is on the right track with this change.
I didn't say he wasn't, I just said that it should be postponed. It's
not a critical issue, so it could wait, IMHO.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Frame background mode
2004-12-27 20:15 ` Juri Linkov
@ 2004-12-27 22:09 ` Eli Zaretskii
2004-12-28 2:48 ` Juri Linkov
0 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2004-12-27 22:09 UTC (permalink / raw)
Cc: emacs-devel
> From: Juri Linkov <juri@jurta.org>
> Date: Mon, 27 Dec 2004 22:15:08 +0200
> Cc: emacs-devel@gnu.org
>
> The new formula will affect only users who have background color set
> to one of 98 colors I listed in the previous message.
98 colors is not a small number.
> No color customization needs to be reworked. The only change needed
> for users affected by the new formula is to customize frame-background-mode
> user option.
If they can figure out that this is what they need to do, yes. I
suspect most users will not know that, and instead will go and change
colors right away.
> If even such small change is undesirable
I don't know if it is undesirable, but Emacs did use the current
recipe since about day one.
> then maybe it's better to
> leave the old formula alone, and to add a new condition keyword
> (e.g. `min-background') that will specify the minimum color intensity
> (a fraction between 0 and 1) and will use the new formula, for instance:
>
> ((class color) (min-colors 88) (min-background 0.5))
I'm probably missing something, because I don't see how is this
different from your original suggestion.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Frame background mode
2004-12-27 22:09 ` Eli Zaretskii
@ 2004-12-28 2:48 ` Juri Linkov
2004-12-28 4:49 ` Eli Zaretskii
0 siblings, 1 reply; 11+ messages in thread
From: Juri Linkov @ 2004-12-28 2:48 UTC (permalink / raw)
Cc: emacs-devel
"Eli Zaretskii" <eliz@gnu.org> writes:
>> then maybe it's better to
>> leave the old formula alone, and to add a new condition keyword
>> (e.g. `min-background') that will specify the minimum color intensity
>> (a fraction between 0 and 1) and will use the new formula, for instance:
>>
>> ((class color) (min-colors 88) (min-background 0.5))
>
> I'm probably missing something, because I don't see how is this
> different from your original suggestion.
The original suggestion was to change the formula for computing
conditions (background light) and (background dark) which will
affect most current faces.
The suggestion above affects none of the current faces and will be
applied for faces that will take advantage of the new `min-background'
keyword. This idea is not for the incoming release because many faces
need to be changed to use this keyword.
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Frame background mode
2004-12-28 2:48 ` Juri Linkov
@ 2004-12-28 4:49 ` Eli Zaretskii
0 siblings, 0 replies; 11+ messages in thread
From: Eli Zaretskii @ 2004-12-28 4:49 UTC (permalink / raw)
Cc: emacs-devel
> Cc: emacs-devel@gnu.org
> From: Juri Linkov <juri@jurta.org>
> Date: Tue, 28 Dec 2004 04:48:06 +0200
>
> The original suggestion was to change the formula for computing
> conditions (background light) and (background dark) which will
> affect most current faces.
>
> The suggestion above affects none of the current faces and will be
> applied for faces that will take advantage of the new `min-background'
> keyword.
If the idea is to add the `min-background' keyword to most of the
faces, the effect will be the same, right?
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Frame background mode
2004-12-26 19:52 Frame background mode Juri Linkov
2004-12-27 8:04 ` Eli Zaretskii
@ 2004-12-28 4:57 ` Richard Stallman
2004-12-28 20:42 ` Luc Teirlinck
2 siblings, 0 replies; 11+ messages in thread
From: Richard Stallman @ 2004-12-28 4:57 UTC (permalink / raw)
Cc: emacs-devel
I don't agree with the new classification that your code does.
Several of the colors that it calls "light", I believe are dark.
For instance, light slate gray, cadet blue, dark sea green,
light sea green (!), and gray59 all seem like light colors to me.
I made the test by modifying list-colors-display to display the chosen
color in the background, with foregrounds of white and of black. That
way I can compare the visibility of both white and black against this
background. If black is more visible against it, it is a light color.
If white is more visible against it, it is a dark color.
This is with my screen gamma set to 1.5, since it is an LCD screen.
It could be that this LCD screen needs a different gamma value.
I don't know how to tell what is "correct". (It is a Thinkpad T21.)
How about if you try this exercise on your screen, and tweak the
threshold and see if you can get good results?
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Frame background mode
2004-12-26 19:52 Frame background mode Juri Linkov
2004-12-27 8:04 ` Eli Zaretskii
2004-12-28 4:57 ` Richard Stallman
@ 2004-12-28 20:42 ` Luc Teirlinck
2004-12-29 0:19 ` Juri Linkov
2 siblings, 1 reply; 11+ messages in thread
From: Luc Teirlinck @ 2004-12-28 20:42 UTC (permalink / raw)
Cc: emacs-devel
Juri Linkov wrote:
I suggest to improve the formula used to determine whether the
background is light or dark. The new formula uses the optimal
weighting coefficients for RGB color components to reflect the
perception of color luminance.
and:
+ (>= (+ (* (nth 0 bg-color-values) 0.30)
+ (* (nth 1 bg-color-values) 0.59)
+ (* (nth 2 bg-color-values) 0.11))
Where did you get the .30 .59 .11 from?
The way colors are perceived, including their brightness, depends on
many things. Your monitor, your eyes, the background colors you are
currently looking at (background color of your screen, color of your
walls), the kind of light that is present other than the light
produced by your computer (daylight, artificial light, the exact
wavelength distribution of that artificial light, no additional
light...), the intensity and angle of that light and so on.
If you have an abnormal color vision, like me (I am a very abnormal
trichromat) you have to customize your monitor. Customizing every
single color for every single program you are using is hopeless.
If I use the default settings of my monitor, the most basic color,
white, 255 255 255, looks to me like light green with some shade of
light blue, in other words, a greenish cyan. It probably looks
perfectly white to most other people. (Actually, if I allow direct
sunlight to hit my monitor, it turns white, even for me.) Green,
0 255 0 looks tremendously brighter than blue, 0 0 255, which in turn
looks tremendously brighter than red, 255 0 0. I can _see_ red text
on a black background, but not read it. Same with cyan on white,
which is actually cyan on lighter and greener cyan. Same with yellow
on white, which is actually light green on a more bluish light green.
So I have to customize my monitor. The question is: what strategy do
I need to use to customize it? What I did is I tried to make red,
green and blue equally bright. Now, under my usual (day)light
conditions, white looks white and I have less trouble with
unreadability due to bad (for me) color combinations. If I allow
direct sunlight to hit my monitor, then my de-cyanized white turns
bright rose, but I better not allow that to happen anyway. Ideally, I
would need different customizations of my monitor for day and night
use, but the difference, while noticeable, is not really big enough to
be worth that trouble.
If I understand correctly the old code assumed that red, green and
blue have exactly the same brightness. For my monitor, eye and usual
conditions, that is actually correct, because I made it correct.
Again, if I understood correctly, your code assumes that green is, to
some specified degree, brighter than red, which is brighter than blue.
Again, where did you get these numbers from? What brightness relation
do people who construct monitors _try_ to achieve under which
conditions?
I agree with Eli that it is better not to mess with this until after
the release.
Sincerely,
Luc.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Frame background mode
2004-12-28 20:42 ` Luc Teirlinck
@ 2004-12-29 0:19 ` Juri Linkov
0 siblings, 0 replies; 11+ messages in thread
From: Juri Linkov @ 2004-12-29 0:19 UTC (permalink / raw)
Cc: emacs-devel
Luc Teirlinck <teirllm@dms.auburn.edu> writes:
> Juri Linkov wrote:
> + (>= (+ (* (nth 0 bg-color-values) 0.30)
> + (* (nth 1 bg-color-values) 0.59)
> + (* (nth 2 bg-color-values) 0.11))
>
> Where did you get the .30 .59 .11 from?
When I looked at different colors in the GIMP color selector,
I noticed that the graphical marker changes its color to black
on light colors, and to white on dark colors. Then I looked
at the GIMP source code for its idea about color intensity and
found that it uses these numbers.
But these coefficients were not invented by GIMP authors, of course.
They are scientifically measured weightings that reflect the relative
sensitivity of human vision to red, green, and blue. These numbers
work for the average person who didn't change the default relative
brightness of monitor color components. That is why they are good
for the default formula.
The strongest argument so far to not change the formula now is that it
will change background modes for some users.
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2004-12-29 0:19 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-12-26 19:52 Frame background mode Juri Linkov
2004-12-27 8:04 ` Eli Zaretskii
2004-12-27 17:36 ` Drew Adams
2004-12-27 21:53 ` Eli Zaretskii
2004-12-27 20:15 ` Juri Linkov
2004-12-27 22:09 ` Eli Zaretskii
2004-12-28 2:48 ` Juri Linkov
2004-12-28 4:49 ` Eli Zaretskii
2004-12-28 4:57 ` Richard Stallman
2004-12-28 20:42 ` Luc Teirlinck
2004-12-29 0:19 ` Juri Linkov
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.