How to decide if the color of the letters is white or black depending on the background?

1

I would like to know how to change the color of the letters dynamically with JavaScript, as well as the Color Picker de Google for example when the background is black the white letters and vice versa.

To find the Color Picker de Google just look for color picker on that page and you will know what I mean.

Any help is accepted either RGB ranges or a JavaScript plugin.

Thank you in advance for reading.

    
asked by Thunder 06.12.2018 в 22:04
source

1 answer

1

I did a small Codepen answering the question thanks to the source of these other questions, it's this link is answered as getting the RGB of a Hexadecimal String in this other is answered as to decide the color of the lyrics depending on the background, in this I found another Codepen where is the formula using JQuery.

By coupling all these formulas I got the expected result.

If you like, you can compare it with the Color Picker de Google.

    
answered by 07.12.2018 в 00:34