Skip to content

Instantly share code, notes, and snippets.

@tayloraswift
Created April 22, 2019 19:19
Show Gist options
  • Save tayloraswift/e4f21804e28e398aea96c13237884eb7 to your computer and use it in GitHub Desktop.
Save tayloraswift/e4f21804e28e398aea96c13237884eb7 to your computer and use it in GitHub Desktop.
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