Answer the question
In order to leave comments, you need to log in
How to determine white color, or close to it in Javascript?
There is a chat in which the user can specify any color of the nickname.
The background in the chat is white.
The user sets the color through color HTML 5, the output is something #FF00FF.
The prohibition of white color does nothing. Start using light blue, pink or gray.
Can I somehow programmatically define a shade of white that will not be visible in the chat?
Answer the question
In order to leave comments, you need to log in
Enter a certain threshold of lightness (experimentally select), lighter than which the color will be prohibited. Translate the color in grayscale (0.299*R + 0.587*G + 0.114*B) and compare with the threshold value: if it is lower, skip it, if not, do not allow this color to be set.
Perhaps this question will help.
How to determine if a color is dark?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question