File indexing completed on 2025-01-05 04:00:26
0001 #!/usr/bin/env python3 0002 0003 import sys 0004 import os 0005 import re 0006 import argparse 0007 sys.path.insert(0, os.path.join( 0008 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 0009 "lib" 0010 )) 0011 from lottie.parsers.svg.importer import parse_color 0012 from lottie import NVector 0013 from lottie import __version__ 0014 0015 0016 def _parse_color(color): 0017 # Inkscape colors 0018 if re.match(r"^[0-9a-fA-F]{8}$", color): 0019 return NVector(*( 0020 int(color[i:i+2], 16) / 0xff 0021 for i in range(0, 8, 2) 0022 )) 0023 return parse_color(color) 0024 0025 0026 0027 parser = argparse.ArgumentParser( 0028 description="Converts a CSS color into a normalized array, as used in lottie" 0029 ) 0030 parser.add_argument("--version", "-v", action="version", version="%(prog)s - python-lottie " + __version__) 0031 parser.add_argument( 0032 "color", 0033 help="Color to inspect (in one of the CSS color formats)" 0034 ) 0035 0036 if __name__ == "__main__": 0037 ns = parser.parse_args() 0038 print(_parse_color(ns.color).components)