4 Reads hex colors from colors.txt and prints their
5 float representations for easy copy and paste
8 from __future__ import division
9 from __future__ import print_function
12 COLOR_FILE = "colors.txt"
15 with open(COLOR_FILE, "r") as stream:
20 r = format(int(color[0:2], 16) / 255.0, ".3f")#.rstrip("0").rstrip(".")
21 g = format(int(color[2:4], 16) / 255.0, ".3f")#.rstrip("0").rstrip(".")
22 b = format(int(color[4:6], 16) / 255.0, ".3f")#.rstrip("0").rstrip(".")
24 cvar = "\"{} {} {}\"".format(r, g, b)#.ljust(19)
25 code = "({}, {}, {})".format(r, g, b)#.ljust(21)
26 comment = " ".join(tokens[1:])
28 print("{} {} {} {}".format(color, cvar, code, comment))