-
Notifications
You must be signed in to change notification settings - Fork 0
/
css.py
65 lines (56 loc) · 2.03 KB
/
css.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
import os, sys, json
import numpy as np
filename = 'stylesheet.csspy.css'
def CSS(dictionary): # CSS
css = ''
for key, value in dictionary.items():
css += key + ' {'
for k, v in value.items():
css += k + ': ' + v + ';'
css += '}'
css += '\n'
with open(filename, 'w') as f:
f.write(css)
return css
def Hex(color): # HEX color
return '#' + color
def Hsl(h, s, l): # HSL color
return 'hsl(%d, %d%%, %d%%)' % (h, s, l)
def Rgb(r, g, b): # RGB color
return 'rgb(%d, %d, %d)' % (r, g, b)
def Rgba(r, g, b, a): # RGBA color
return 'rgba(%d, %d, %d, %d)' % (r, g, b, a)
def Hsla(h, s, l, a): # HSLA color
return 'hsla(%d, %d%%, %d%%, %d)' % (h, s, l, a)
def Hsv(h, s, v): # HSV color
return 'hsv(%d, %d%%, %d%%)' % (h, s, v)
def Hsva(h, s, v, a): # HSVA color
return 'hsva(%d, %d%%, %d%%, %d)' % (h, s, v, a)
def px(value): # Pixels
return str(value) + 'px'
bold = 'bold' # font-weight bold
bolder = 'bolder' # font-weight bolder
lighter = 'lighter' # font-weight lighter
normal = 'normal' # font-weight normal
italic = 'italic' # font-style italic
oblique = 'oblique' # font-style oblique
underline = 'underline' # text-decoration underline
overline = 'overline' # text-decoration overline
line_through = 'line-through' # text-decoration line-through
none = 'none' # text-decoration none
capitalize = 'capitalize' # text-transform capitalize
uppercase = 'uppercase' # text-transform uppercase
lowercase = 'lowercase' # text-transform lowercase
inherit = 'inherit' # text-transform inherit
initial = 'initial' # text-transform initial
unset = 'unset' # text-transform unset
left = 'left' # text-align left
right = 'right' # text-align right
center = 'center' # text-align center
justify = 'justify' # text-align justify
justify_all = 'justify-all' # text-align justify-all
start = 'start' # text-align start
end = 'end' # text-align end
match_parent = 'match-parent' # text-align match-parent
inherit = 'inherit' # text-align inherit
initial = 'initial' # text-align initial