Created
April 22, 2019 19:19
-
-
Save tayloraswift/e4f21804e28e398aea96c13237884eb7 to your computer and use it in GitHub Desktop.
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
import sys | |
text = sys.argv[1] | |
def hue(angle): | |
h = angle / 60 | |
x = 1 - abs(h % 2 - 1) | |
return ((1, x, 0), (x, 1, 0), (0, 1, x), (0, x, 1), (x, 0, 1), (1, 0, x))[int(h)] | |
def hexcolor(rgb): | |
return '#{:02x}{:02x}{:02x}'.format( * (int(255 * v) for v in rgb) ) | |
print(''.join('<span style=\'color: {0}\'>{1}</span>'.format((hexcolor(hue(i * 360 / len(text)))), character) for i, character in enumerate(text))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment