Created
March 22, 2011 16:08
-
-
Save sbp/881483 to your computer and use it in GitHub Desktop.
Colourise a CQ using a mixture of logarithmic and linear scales
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 colour(cq): | |
| rating = abs(cq - 100) | |
| base = math.pow(10, 1./111) # i.e. 0.5 * 1/(255 - 32 - 1) | |
| LOG = math.log(rating + 1, base) / 2 | |
| LIN = rating * 2.23 / 2 # i.e. 255 - 32 / 100 (/ 2) | |
| red, green, blue = 32, 32, 32 | |
| if cq > 100: | |
| blue += int(LOG + LIN) | |
| elif cq < 100: | |
| red += int(LOG + LIN) | |
| return red, green, blue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment