-
Notifications
You must be signed in to change notification settings - Fork 1
/
colortest.py
67 lines (57 loc) · 1.42 KB
/
colortest.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
'''
Outputs an HTML webpage to stdout to visualize a set of colors
'''
def mkColor(name, color):
''' Converts a `name` and `rgb` (any CSS format) to a few CSS lines '''
return '.color-{} {{\n\tcolor: {}\n}}\n'.format(name, color)
CSS_COLORS = {
'white': 'Beige',
'black': 'DarkSlateGrey',
'blue': 'DarkSlateBlue',
'green': 'ForestGreen',
'lightred': 'Tomato',
'red': 'Crimson',
'magenta': 'MediumVioletRed',
'brown': 'Chocolate',
'yellow': 'GoldenRod',
'lightgreen': 'LightGreen',
'cyan': 'LightSeaGreen',
'lightcyan': 'LightSkyBlue',
'lightblue': 'RoyalBlue',
'lightmagenta': 'HotPink',
'darkgray': 'DimGrey',
'gray': 'LightSlateGrey',
}
css = ''
for color in CSS_COLORS:
css += mkColor(color, CSS_COLORS[color])
css += '''
table {
width: 40%;
padding: 30px;
}
'''
content = ''
for color in CSS_COLORS:
content += ('<tr><td>{}</td><td class="color-{}">{}</td>' +
'<td style="background-color: {}; padding-left:200px;">' +
'</td></tr>\n').format(
color, color, color, CSS_COLORS[color])
content = '''<table style="background-color: white; color: black; float: left">
{}
</table>
<table style="background-color: black; color: white;">
{}
</table>
'''.format(content, content)
page = '''
<html>
<head>
<style>
''' + css + '''
</style>
</head>
<body>
''' + content + '''
</html>'''
print(page)