Skip to content

Instantly share code, notes, and snippets.

@SquidDev
Created August 6, 2013 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SquidDev/6163422 to your computer and use it in GitHub Desktop.
Save SquidDev/6163422 to your computer and use it in GitHub Desktop.
Some colour functions to generate a function from the current time or from a string.
GenRGBColour("Pete") # Produces a colour based on Pete - generates the same colour for all Petes
GenRGBColour("Fred") # Same as above, but for Fred.
import time, hashlib
def GenRGBColour(string):
md=hashlib.md5()
md.update(string)
HexColour=md.hexdigest()
return [int(HexColour[0:2], 16), int(HexColour[2:4], 16), int(HexColour[4:6], 16)]
def GenRandomColour():
return GenRGBColour(str(time.time()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment