Skip to content

Instantly share code, notes, and snippets.

@gnuton
Created October 3, 2013 14:22
Show Gist options
  • Select an option

  • Save gnuton/6810680 to your computer and use it in GitHub Desktop.

Select an option

Save gnuton/6810680 to your computer and use it in GitHub Desktop.
Small routine which converts a score to a color. 0.6 is the max value of the score
def color(score, max_score):
# proportion: max_score : 255 = score : x
nrmlzScore = int(score * 255 /max_score)
hueValue = (str(hex(abs(255 - nrmlzScore)))[2:])
colorHexStr = "#%s%s%s" %(hueValue,hueValue,hueValue)
print "%s -> %s" % (score, colorHexStr)
return colorHexStr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment