A
A
Alexey Lebedev2014-07-13 19:22:59
JavaScript
Alexey Lebedev, 2014-07-13 19:22:59

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

3 answer(s)
V
Vladlen Grachev, 2014-07-13
@swanrnd

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.

M
Mikhail Osher, 2014-07-13
@miraage

Perhaps this question will help.
How to determine if a color is dark?

K
Konstantin Kitmanov, 2014-07-14
@k12th

Convert to HSB and see if the B is too high for the S low.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question