2

I have a color in hex format ex (c3d8f7 (light blue), 303f5a (dark blue)). How to find out if that color is light or dark?

StoneHeart
  • 14,982
  • 31
  • 66
  • 83

1 Answers1

3

Very rough algorithm: Convert the color to HSV and check e.g. if V is above (light) 75% or below (dark) 25%.

Ocaso Protal
  • 18,151
  • 8
  • 74
  • 79
  • Are you know a function in javascript to convert hex to hsv? – StoneHeart Jan 20 '12 at 14:45
  • 1
    This link should help: http://matthaynes.net/blog/2008/08/07/javascript-colour-functions/ – Ocaso Protal Jan 20 '12 at 14:51
  • @sam360 See: http://stackoverflow.com/questions/359612/how-to-change-rgb-color-to-hsv (and maybe http://stackoverflow.com/questions/74148/how-to-convert-numbers-between-hexadecimal-and-decimal-in-c) – Ocaso Protal Aug 21 '14 at 12:56