title: Calculating contrasting colours in javascript
body: <p>On one of pages we're currently working on users can change the background of the text displayed. </p>
  
  <p>We would like to automatically alter the foreground colour to maintain <em>reasonable</em> contrast of the text.</p>
  
  <p>We would also prefer the colour range to be discretionary. For example, if background is changing from white to black in 255 increments, we don't want to see 255 shades of foreground colour. In this scenario, perhaps 2 to 4, just to maintain <em>reasonable</em> contrast.</p>
  
  <p>Any UI/design/colour specialists/painters out there to whip out the formula?</p>