Skip to content

Instantly share code, notes, and snippets.

@sbp
Created March 22, 2011 16:08
Show Gist options
  • Select an option

  • Save sbp/881483 to your computer and use it in GitHub Desktop.

Select an option

Save sbp/881483 to your computer and use it in GitHub Desktop.
Colourise a CQ using a mixture of logarithmic and linear scales
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