Created
October 3, 2013 14:22
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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