unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#30295: CSS mode colour highlighting makes text hard to read
@ 2018-01-30 16:55 Richard Copley
  2018-02-01 21:17 ` Juri Linkov
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Copley @ 2018-01-30 16:55 UTC (permalink / raw)
  To: 30295

In CSS mode, the value "green" or "#0f0" or "rgba(0,255,0,0.5)" is
displayed with a white foreground and a 100%-green background, which
is difficult to see.

A white foreground is chosen on even lighter colours, for example,
"#5e5" and "#87e087".

See functions css--contrasty-color in textmodes/css-mode.el and
color-distance in src/xfaces.c, and
<https://debbugs.gnu.org/cgi/bugreport.cgi?bug=25525>, and
<https://www.compuphase.com/cmetric.htm>.

If the color-distance is to be used, the appropriate formula is:

(if (> (color-distance name "black") (color-distance name "white"))
"black" "white")

That formula still maps "green" to "white", but it does at least map
lighter colours such as "#38e038" to "black".

For what it's worth, in my inexpert opinion it makes more sense to
compare the luma against that of mid-grey as Tom originally proposed.





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

* bug#30295: CSS mode colour highlighting makes text hard to read
  2018-01-30 16:55 bug#30295: CSS mode colour highlighting makes text hard to read Richard Copley
@ 2018-02-01 21:17 ` Juri Linkov
  2018-02-01 23:03   ` Richard Copley
  0 siblings, 1 reply; 4+ messages in thread
From: Juri Linkov @ 2018-02-01 21:17 UTC (permalink / raw)
  To: Richard Copley; +Cc: 30295

> In CSS mode, the value "green" or "#0f0" or "rgba(0,255,0,0.5)" is
> displayed with a white foreground and a 100%-green background, which
> is difficult to see.
>
> A white foreground is chosen on even lighter colours, for example,
> "#5e5" and "#87e087".
>
> See functions css--contrasty-color in textmodes/css-mode.el and
> color-distance in src/xfaces.c, and
> <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=25525>, and
> <https://www.compuphase.com/cmetric.htm>.
>
> If the color-distance is to be used, the appropriate formula is:
>
> (if (> (color-distance name "black") (color-distance name "white"))
> "black" "white")
>
> That formula still maps "green" to "white", but it does at least map
> lighter colours such as "#38e038" to "black".
>
> For what it's worth, in my inexpert opinion it makes more sense to
> compare the luma against that of mid-grey as Tom originally proposed.

Indeed, luma is more suitable than mid-grey, customizing
‘list-colors-sort’ to “luminance” shows that distinguishable colors with
the black foreground start closer to the beginning of the color list.

Or we could use both luma and distance like in ‘shr-color-visible’
with two customizable options:
‘shr-color-visible-luminance-min’ and
‘shr-color-visible-distance-min’.





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

* bug#30295: CSS mode colour highlighting makes text hard to read
  2018-02-01 21:17 ` Juri Linkov
@ 2018-02-01 23:03   ` Richard Copley
  2020-06-15 20:12     ` Simen Heggestøyl
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Copley @ 2018-02-01 23:03 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 30295

On 1 February 2018 at 21:17, Juri Linkov <juri@linkov.net> wrote:

>> If the color-distance is to be used, the appropriate formula is:
>>
>> (if (> (color-distance name "black") (color-distance name "white"))
>> "black" "white")
[...]
>> For what it's worth, in my inexpert opinion it makes more sense to
>> compare the luma against that of mid-grey as Tom originally proposed.
>
> Indeed, luma is more suitable than mid-grey, customizing
> ‘list-colors-sort’ to “luminance” shows that distinguishable colors with
> the black foreground start closer to the beginning of the color list.

I think you and I are in agreement, but to clarify (just in case), the
two options I was talking about were:

1: Choose black if the colour is closer to white than black, in the
color-distance metric (like the Lisp expression I wrote).

2 (better): Choose black if the colour's luma is greater than the luma
of mid-grey, where by mid-grey I meant "#808080", and where I don't
particularly mind what "luma" means.

Eli also mentioned the idea of using the complementary colour (see
#25525) but that can look quite unpleasant due to chromostereopsis,
depending on the surrounding colours. Colour-blind people might also
find it difficult (I'm not sure).

> Or we could use both luma and distance like in ‘shr-color-visible’
> with two customizable options:
> ‘shr-color-visible-luminance-min’ and
> ‘shr-color-visible-distance-min’.

Thanks, a trove of useful functions are in "shr-color.el" and
"color.el". Using color-rgb-to-hsl and extracting the luminance would
make for readable code for option 2.





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

* bug#30295: CSS mode colour highlighting makes text hard to read
  2018-02-01 23:03   ` Richard Copley
@ 2020-06-15 20:12     ` Simen Heggestøyl
  0 siblings, 0 replies; 4+ messages in thread
From: Simen Heggestøyl @ 2020-06-15 20:12 UTC (permalink / raw)
  To: Richard Copley; +Cc: Mattias Engdegård, 30295-done

The problem with these colors should now be fixed with Mattias' recent
changes in commit 68ae6faa7f1b4c348740667f98fbf1d1ce5a7979 on
master. Closing.

-- Simen





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

end of thread, other threads:[~2020-06-15 20:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-30 16:55 bug#30295: CSS mode colour highlighting makes text hard to read Richard Copley
2018-02-01 21:17 ` Juri Linkov
2018-02-01 23:03   ` Richard Copley
2020-06-15 20:12     ` Simen Heggestøyl

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).