]> git.xonotic.org Git - xonotic/mediasource.git/blob - gfx/luma_add/colors/print-float.py
Initialize experimental Luma redesign, to support in-code additive colorization
[xonotic/mediasource.git] / gfx / luma_add / colors / print-float.py
1 #!/usr/bin/env python
2
3 """
4 Reads hex colors from colors.txt and prints their
5 float representations for easy copy and paste
6 """
7
8 from __future__ import division
9 from __future__ import print_function
10
11
12 COLOR_FILE = "colors.txt"
13
14
15 with open(COLOR_FILE, "r") as stream:
16         for line in stream:
17                 tokens = line.split()
18                 color = tokens[0]
19
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(".")
23
24                 cvar = "\"{} {} {}\"".format(r, g, b)#.ljust(19)
25                 code = "({}, {}, {})".format(r, g, b)#.ljust(21)
26                 comment = " ".join(tokens[1:])
27
28                 print("{}  {}  {} {}".format(color, cvar, code, comment))