Last active
August 29, 2015 14:10
-
-
Save richardjpope/789debb25ae64a373d4c to your computer and use it in GitHub Desktop.
String to colour in python
This file contains 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 string_to_colour(s): | |
s = s.lower() | |
r = ((ord(s[0])-96.0)/26)*255 | |
g = ((ord(s[int(len(s)/2)])-96.0)/26)*255 | |
b = ((ord(s[len(s)-1])-96.0)/26)*255 | |
return '#%02X%02X%02X' % (r,g,b) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
:)