title: Color difference/similarity% between two values with JS
body: <p>I need to compute the difference between two hex color values so the output is a percentage value. The first thing I discarted was converting the hex value into decimal, as the first one will have much higher weight than the last.</p>
  
  <p>The second option is to compute the difference between each of the RGB values and then add them all. However, the difference between <code>0, 0, 0</code> and <code>30, 30, 30</code> is much lower than the one between <code>0, 0, 0</code> and <code>90, 0, 0</code>.</p>
  
  <p><a href="https://stackoverflow.com/questions/5392061/algorithm-to-check-similarity-of-colors-based-on-rgb-values-or-maybe-hsv">This question</a> recommends using <a href="http://en.wikipedia.org/wiki/YUV" rel="noreferrer">YUV</a>, but I can't figure out how to use it to establish the difference.</p>
  
  <p>Also, <a href="https://stackoverflow.com/questions/9820655/how-can-i-establish-the-difference-between-two-hex-colours">this other question</a> has a nice formula to compute the difference and output a RGB value, but it's not quite there.</p>