Re: Retrieving color names and hex values using list-colors-display for coding purposes
Heime <[email protected]> Sat, 18 Jul 2026 01:11:38 +0000
| Newsgroups | gmane.emacs.help |
|---|---|
| Message-ID | <kmj13mm24C1Jxvqo_WlOpukgMTHw5ArRQMeKySN2SGYFhccPalF3OGINvudEwnz2KLOmyYVXLEzlemR_9bDzvZk-gyufzPhvmxWW11VUzso=@protonmail.com> |
On Saturday, July 18th, 2026 at 3:38 AM, Eli Zaretskii <[email protected]> wrote= : > > Date: Fri, 17 Jul 2026 14:55:28 +0000 > > From: Heime <[email protected]> > > Cc: [email protected], [email protected], [email protected] > > > > > > > > > > > > Sent with Proton Mail secure email. > > > > On Saturday, July 18th, 2026 at 2:34 AM, Eli Zaretskii <[email protected]> w= rote: > > > > > > Date: Fri, 17 Jul 2026 14:28:11 +0000 > > > > From: Heime <[email protected]> > > > > Cc: uzibalqa <[email protected]>, [email protected], help-gnu-emac= [email protected] > > > > > > > > > > > > > > > > > > > > > > > > Sent with Proton Mail secure email. > > > > > > > > On Saturday, July 18th, 2026 at 1:33 AM, Eli Zaretskii <[email protected]= g> wrote: > > > > > > > > > > Date: Fri, 17 Jul 2026 13:22:13 +0000 > > > > > > From: uzibalqa <[email protected]> > > > > > > Cc: Heime <[email protected]>, [email protected], help= [email protected] > > > > > > > > > > > > If the advice is always to use #RRRRGGGGBBBB, which is also alw= ays the advice > > > > > > for my cases, then how (list-colors-display) showing me #RRGGB= B follows the > > > > > > advice you described? To follow your advice, display #RRRRGGGG= BBBB, not > > > > > > the currently displayed #RRGGBB. > > > > > > > > > > Are you writing list-colors-display? If not, why is it important= that > > > > > it shows 6-digit RGB values? > > > > > > > > Because colour-values on the name are in range 0-65535, a range tha= t > > > > definitly requires hex RRRR and not hex RR. The hex value is uniqu= e, > > > > consequently using RR instead of RRRR is incorrect. > > > > > > > > Multiple (0-65535) values map to the same #RR value, breaking uniqu= eness > > > > and accuracy. Colour accuracy matters for contrast calculations, a= ccessibility, > > > > and precise colour matching. The emphasis on the importance of 6-d= igit > > > > hex values is that they uniquely and accurately represent the colou= r in > > > > the standard hex format. > > > > > > All of the above are reasons to use 16-bit values for each RGB > > > component. That way, you don't lose accuracy when specifying a color= . > > > > > > list-colors-display is an interactive function in facemenu.el, which is > > part of GNU Emacs. It should look at the range of values and determine > > whether #RRRRGGGGBBBB should be used as display. >=20 > Not necessarily. It works with a list of 256 colors, so the full list > available on the platform is not relevant. I can take the RGB values, for instance 60000, get 60000/65536, which is 0.915, and reduce to 256 colours via 0.915*256 to get 234. Such a mapping from 16-bit values to 8-bit values should be ok. Looks to me that I can take #RRRRGGGGBBBB and obtain a close #RRGGBB. Basically, the same colour name gives slightly different colour depending on the terminal supported colours, whether 256 or 16, etc. The same colou= r name does not render exactly the same on different torminal systems. > Once again, please don't look at that command as guidance for which > RGB specifications to use in your programs. But I can use the colour names? I could then make my own hex conversions and compute contrast values. Could I rely on the colour names from=20 (defined-colors). The names should be identical to the ones from=20 list-colors-display, right?