title: Generate Random Color distinguishable to Humans
body: <p>I am trying to randomly generate a color in hex in javascript.</p>
  
  <p>However the colors generated are almost indistinguishable from eachother.<br>
  Is there a way to improve it?</p>
  
  <hr>
  
  <p>Here is the code I am using:</p>
  
  <pre><code>function randomColor(){
     var allowed = "ABCDEF0123456789", S = "#";
  
     while(S.length &lt; 7){
         S += allowed.charAt(Math.floor((Math.random()*16)+1));
     }
     return S;
  }
  </code></pre>
  
  <hr>
  
  <p>I heard something about <em>HSL</em> and <em>HSV</em> color model but can't get
  it to work in my code. Please help.</p>
  
  <p>Thanks in Advance</p>