Open japhb opened 2 years ago
Yes, the nick coloring is still a bit hacky. This was partially also caused by the fact that we were still playing with the layout, and the background color. I guess now it's time to get a little more specific. Thanks for the report and the reminder :-)
https://www.w3.org/TR/2018/REC-WCAG21-20180605/#dfn-relative-luminance <- a formula to check contrast. https://github.com/Asqatasun/Contrast-Finder <- an example of a generator (in Java).
camelia
is the worst offender in terms of colors :)
Accepting PR's for the colorize-nick logic :-)
Just for the reference, maybe this would be helpful (and maybe not):
glasbey_dark
seems to be an interesting option. Basically, it is a set of 100 maximally distinct colors that can be used on white background. Is 100 enough? I don't know :)For a single page 100 is enough, but if it's a per-user colors saved...
Again, IMO the easiest solution is to write a contrast value checker and when deciding a color for the user, just roll the random against the checker until we get a contrast one. Any opinions why that'd be a bad idea?
@Altai-man fine by me. PR's or code examples welcome!
Currently the dynamic username coloring can choose colors that are very close to the background (light yellow on white, for instance). In addition, extremely dark or light colors are hard to distinguish from each other, as they effectively desaturate towards black or white respectively. (Desaturated colors with similar lightness are hard to distinguish in general, but I mention the light and dark cases because it's not always obvious that they are de facto desaturated.)
The color choices should be distributed such that they all have a minimum contrast to the background (choosing a maximum lightness if the background is bright, or minimum lightness if the background is dark), and otherwise distributed around color space in such a way that they are relatively well spaced perceptually.
Note that algorithms for this already exist (it's a really common problem), but many of them are unnecessarily complex for the username coloring use case, because they are trying to squeeze out the last bit of perceptual advantage for much more finicky use cases (such as reducing image palettes for compression).