element-meta icon indicating copy to clipboard operation
element-meta copied to clipboard

Add more colors to display name color palette

Open vranki opened this issue 5 years ago • 10 comments

Screenshot from 2020-11-02 20-31-43

Description

The color palette to choose colors for display names is very small and there are lot of color clashes. In the example screenshot you notice that these users have the same color:

  • tulir & makayou
  • bullwinkle & @bullwinkle
  • μμ, mewmew & mrkeen

Modern computers can display much more colors, and Element should have a much larger palette to pick them from to avoid clashes. IRC clients have solved the issue by having a much larger palette.

I think the same palette & hash algorithm is used by Element Android so the issue is valid also for it.

Version information

Element Desktop 1.7.10 / Ubuntu 20.04

Implementation idea

Calculate hue & saturation values from mxid hash and use them with brightness value to "generate" actual RGB values. Brightness could be adjusted by client to have dark colors on bright background and vice versa.

vranki avatar Nov 02 '20 18:11 vranki

Even more broadly, generally more colors and their variations for different nicks. One cool tech @vranki already figured, whoeheartedly welcomed idea :)

olmari avatar Nov 02 '20 18:11 olmari

These colours are chosen to fit in with the colour scheme of the app and be to have enough contrast to be distinguishable from one another. Generating completely random colours from the complete spectrum would probably generate a lot of colours that didn't have enough contrast from one another to be visually distinguishable anyway, I'd expect? We could potentially consider this as a feature, but please use the 'feature' template rather than 'bug'.

dbkr avatar Nov 03 '20 11:11 dbkr

However colour would technically work, I feel there are way too few of variations... Sure, I can see some colours/"shadings"/variations are hard for certain colourblind peoples and whatnot to distinguish, but at the moment no one is able to when such does not exist. :) So introducing more variations for colours there would ease many of us daily use of Element, while situation for less able ones would more or less stay as is, should one not distinguish, for example, red and lighter red (pink?) etc.

olmari avatar Nov 03 '20 11:11 olmari

Pidgin starts with these 24 colors (defined in pidgin/gtknickcolors.h) image Then, in generate_nick_colors (at pidgin/gtkconv.c:7861), it filters this list based on whether they are different enough from the background, the color used for mentions, and regular text. (it calculates some luminance contrast ratio and makes sure it's bigger than some threshold)

/* first we look through the list of "good" colors: colors that differ from every other color in the
 * list.  only some of them will differ from the background color though. lets see if we can find
 * numcolors of them that do
 */

Then, it might have less colors than desired, so it generates some at random:

/* we might not have found numcolors in the last loop.  if we did, we'll never enter this one.
 * if we did not, lets just find some colors that don't conflict with the background.  its
 * expensive to find colors that not only don't conflict with the background, but also do not
 * conflict with each other.
 */

This way it ends up with 220 colors that are readable, but are not guaranteed to be different from eachother. For small chats, though, the initial "seed" colors will be enough, so they will definitely be different, but you still get some variance for larger groups.

This approach is kind of overkill, but it really does the job without having to come up with tons of colors for every theme.

baltitenger avatar Jan 11 '21 09:01 baltitenger

Calculate hue & saturation values from mxid hash and use them with brightness value to "generate" actual RGB values. Brightness could be adjusted by client to have dark colors on bright background and vice versa.

This is how nheko does it. It works quite well in my experience:

Screenshots from synapse admins and gitter rooms
dark Light Dark w/ collisions Light w/ collisions
image image image image

Of course, there are still some collisions. Often enough, though, the colors are slightly different.

MayeulC avatar Jun 01 '21 09:06 MayeulC

One problem I find particularly disgusting about this is that even in rooms with just 2 persons, sometimes both have the same color:

The screenshot is not much friendly but you get the point. This is a private conversation:

imagen

yajo avatar Sep 15 '21 11:09 yajo

Screenshot from 2021-10-03 02-35-45 Here is a pretty artistic example of the problem. Two active users get the same color and it's really hard to distinguish them.

vranki avatar Oct 02 '21 23:10 vranki

Tangentially related: https://github.com/matrix-org/matrix-spec/issues/835

unknown-user-9246102101 avatar Jul 05 '23 19:07 unknown-user-9246102101

This feature would be quite an enhancement. It's an important if not the main reason why people ask for a feature to "Remove username color randomization" (https://github.com/element-hq/element-meta/issues/2115) or to "Allow users to change the color of their names" (https://github.com/element-hq/element-meta/discussions/842, https://github.com/element-hq/element-meta/issues/841 and https://github.com/matrix-org/matrix-spec/issues/835).

noraj avatar Oct 08 '25 17:10 noraj

In addition to a larger color palette for display names, having a unique color for the current user would also help, it would make color clash impossible with the current user, only between other users. Of course this color would only be local and other users would see the display name of that user with a random color on their client. So for the current user color, the user could choose between a 0xFFFFFF (16777215 true colors) palette, since it would only apply to this one person and only locally. Personally, I would pick a color that is not in the server color palette.

noraj avatar Oct 08 '25 18:10 noraj