Lurker News
hue.tools was created after spending way to much time trying to find the right tools when working with colors.

It's an attempt to create a simple but useful toolbox for common color related tasks and problems.
While it's in no way perfect or provides the tools for every use case, it has served me well in the last few months and I hope it will be useful for some of you as well.

Comments (80) 36 threads

Show all comments

Showing thread 10 of 36

just-tom3 replies#
Is it possible to know about a certain color if it's dark or light? My goal is to automatically determine whether to put a white or black text on top of a background colored box based on the answer. Is it has something to do with the temperature? I'd expect to get some value below or above 0.5.
exclipy#
Look at the L for either LAB or LCH. It'll be between 0 and 100.
Cyykratahk#
A simple function is to calculate whether the total of each RGB channel reaches a certain threshold, with different weights given to each channel. For an example, see the YIQ contrast function used by Bootstrap v4 [0].

WCAG defines their own algorithm for calculating the contrast between two colours to ensure good accessibility [1][2]. Bootstrap v5 uses this [3].
[0] https://github.com/twbs/bootstrap/blob/v4.6.1/scss/_function...
[1] https://www.w3.org/WAI/GL/wiki/Relative_luminance
[2] https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests
[3] https://github.com/twbs/bootstrap/blob/v5.1.3/scss/_function...

pabue#
Great idea. I think this will fit nicely with the info tool. Also a accessibility contrast score might also be helpful. I will take a look at that. Thanks!