enforce player chat color to be readable
Posted: Tue Feb 13, 2018 12:35 pm
to everyone: please leave feedback if you agree or disagree to this. commenting will bump it up in the thread overview. i'd like to know everyones opinion on this. strawpoll.me/15064935
corresponding reddit post: /r/factorio/7xht6p
r, g and b are red, green and blue and should be between or equal to 0 and 1
PPS: someone should fix your phpbb forum css to allow formatting as above. maybe just introduce paragraphs into bbcode. (i just wrapped the text content in
corresponding reddit post: /r/factorio/7xht6p
simple and easy explaination of the problem:
- low contrast between text and background
- if you use steam in home streaming or similar, it will introduce artefacts as seen in both of my screenshots, making this even worse
effected scenarios:
- twitch streaming
- youtube videos
- colorblind / visually handicapped people
- steam in home streaming
- nvidia shield
- in general everything that records your screen
- bad / cheap screens
- desired user experience
- …
possible fix:
- increase text contrast
- maybe only color the player name and not the text. most chat clients do this for a good reason. this would improve readability even further
- introduce a system that pins chat color to high brightness colors either through rgb pinning as suggested below or through HSL rules (wich would essentially have the same outcome)
- in addition to that, it might be a good idea to have either a bigger contrast outline around text or just to add a solid dark background color to console text
- maybe only allow dark colors for entities like the player sprite etc. and ditch dark colors all together from text. (thinking about the minimap etc.)
suggested pseudocode:
constraints:r, g and b are red, green and blue and should be between or equal to 0 and 1
Code: Select all
// smallest possible number in IEEE 754.
// i don't know what you use internally. just replace it with the fitting constant.
const double epsilon = 2.220446049250313e-16;
// figure out the peak value across all color channels.
double m = max(r, g, b);
// prevents division by zero and epsilon exploitation
if (m <= epsilon) {
// enforce white if the color would be black
player.chatcolor = rgb(1.0, 1.0, 1.0);
} else {
double factor = 1.0 / m;
player.chatcolor = rgb(r * factor, g * factor, b * factor);
}
sidenote:
- don't let people input the floating point epsilon or else the calculated factor will be 0, wich results in black chat color.
just write a unit test for that.
it's also a good idea to only allow positive numbers. (i don't know if you currently do)
examples:
- 0.02 0.19 0.012 would become 0.105263158 1 0.063157895 through the suggested pseudocode from above
(image taken during a night cycle) the following is essentially unreadable even if you scale it up.
note the fact that the artefacts you see are straight from steam in home streaming and not screenshot image compression.
bright text like the bright green, orange and white in this screenshot are perfectly readable even at a distance.
greetings from a fellow german software engineer
PPS: someone should fix your phpbb forum css to allow formatting as above. maybe just introduce paragraphs into bbcode. (i just wrapped the text content in
- wich is a bad thing. i've dealt with phpbb source code before so.. i know it's possible without modding it)