pixelterm/pixelterm/resolvecolor.py
2013-09-16 15:42:00 +02:00

17 lines
447 B
Python
Executable file

#!/usr/bin/env python
def main():
import os, sys, argparse, os.path, json, re
from pixelterm import xtermcolors
# Resolve HTML-style hex RGB color codes to xterm-256color color numbers
if len(sys.argv) != 2:
print('Usage: resolvecolor.py #RRGGBB')
exit()
print(xtermcolors.closest_color(*[int(s, 16) for s in re.match('#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})', sys.argv[1]).groups()]))
if __name__ == '__main__':
main()