-
Notifications
You must be signed in to change notification settings - Fork 1
/
cspace.py
executable file
·51 lines (43 loc) · 1.33 KB
/
cspace.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python
from colorspacious import cspace_converter
from collections import OrderedDict
colors = OrderedDict()
colors['yellow'] = [0xb5, 0x89, 0x00]
colors['orange'] = [0xcb, 0x4b, 0x16]
colors['red'] = [0xdc, 0x32, 0x2f]
colors['magenta'] = [0xd3, 0x36, 0x82]
colors['violet'] = [0x6c, 0x71, 0xc4]
colors['blue'] = [0x26, 0x8b, 0xd2]
colors['cyan'] = [0x2a, 0xa1, 0x98]
colors['green'] = [0x85, 0x99, 0x00]
colors['green2'] = [0x00, 0x99, 0x00]
colors['undefined'] = [0x65, 0x7b, 0x83]
colors['ok'] = [0x32, 0xcd, 0x32]
colors['warning'] = [0xff, 0xd7, 0x00]
colors['critical'] = [0xdc, 0x14, 0x3c]
colors['unknown'] = [0xff, 0xa5, 0x00]
rgb2lab = cspace_converter("sRGB255", "CIELab")
lab2rgb = cspace_converter("CIELab", "sRGB255")
def norm(val):
return int(max(0, min(val, 255)))
for name, rgb in colors.items():
lab = rgb2lab(rgb)
lab[0] = 65.0
colors[name] = lab2rgb(lab)
print("CSS3 Variables:\n")
print(" /* SNMD Colors */")
for name, rgb in colors.items():
print(" --SNMD_{0:12} #{1:02x}{2:02x}{3:02x};".format(
name + ":",
norm(rgb[0]),
norm(rgb[1]),
norm(rgb[2]))
)
print("\n\nGPL Entries:\n")
for name, rgb in colors.items():
print("{1:3d} {2:3d} {3:3d} SNMD {0}".format(
name,
norm(rgb[0]),
norm(rgb[1]),
norm(rgb[2]))
)