0

I am trying to make a function in java script that get a hex color code and return true if the color is more deep (close to black color), or false if the color is more bright (close to the white color).

Any ideas?

Mr Lord
  • 150
  • 1
  • 4
  • 18
  • Depends on your definition of close... One may say two colors are close if no RGB components are more that 30 units away from each other. Then 0,0,0 and 28,30,25 are close. – AHB May 21 '17 at 19:05
  • I have a background image that change and I have a text on the image, so I need the function to know if to change to text to bright or black. – Mr Lord May 21 '17 at 19:09

1 Answers1

0

Regarding the parsing part take a look at this answer, then you'll have RGB if they're close to 0 the color is dark and if they're close to 255 the color is bright.

Community
  • 1
  • 1
PRAISER
  • 793
  • 7
  • 15