title: Comparing a color range using either hex or decimal in javascript
body: <p>I am extracting the main color from a picture, and then want to call a different function depending on whether it is red, blue, green, yellow, purple etc. (the more options I can have, the better). So what I would like to be able to do is:</p>
  
  <pre><code>if(color &lt; maxColorValueRed &amp;&amp; color &gt; minColorValueRed) {
  function1();
  }
  else {
  if { .....
  </code></pre>
  
  <p>Where maxColorValue and minColorValue are either hexadecimal or decimal color values, and all the values between would count as the same rough color - so specify (roughly) the minimum and maximum red colors, for example.</p>
  
  <p>So I have two questions:
  1) can I compare hexadecimals? And how? It would make life easier if I could do it with this rather than decimal.
  2) Anyone got a handy chart giving the color ranges? Ordinary charts (i.e. what I can find on google) are doing my head in . . . looking at them, I'm not even 100% sure I can specify a range like that?</p>
  
  <p>Basically, I'm not entirely sure this is even doable this way - anyone have any suggestions for getting the same end result another way?</p>
  
  <p>Thanks in advance for any help.</p>