Contributor
- Joined
- Jan 19, 2018
- Messages
- 648
Browsing the forums usernames and colored text seems too dark to me on the dark theme.
As a test I tried playing with some code to automatically lighten up text colors and I think it's a good improvement.
I'm not quite sure if you'd want to use this code for all colored text in dark mode but that might be worth considering.
And here's the difference it makes:
As a test I tried playing with some code to automatically lighten up text colors and I think it's a good improvement.
I'm not quite sure if you'd want to use this code for all colored text in dark mode but that might be worth considering.
Code:
$('[style^=color]').each(function(){
var color = $(this).css('color').split('(')[1].split(')')[0].split(', ');
var r = Number(color[0]), g = Number(color[1]), b = Number(color[2]);
var ave = 0.2126*r + 0.7152*g + 0.0722*b;
if (ave == 0) {
$(this).css({'color': '#FFFFFF'});
return;
}
var ratio = 150 / ave;
r = Math.round(Math.max(Math.min(ratio*r, 255), 0));
g = Math.round(Math.max(Math.min(ratio*g, 255), 0));
b = Math.round(Math.max(Math.min(ratio*b, 255), 0));
$(this).css({'color': 'rgb('+r+', '+g+', '+b+')'});
});
And here's the difference it makes: