-
Notifications
You must be signed in to change notification settings - Fork 233
/
styles.py
85 lines (69 loc) · 2.03 KB
/
styles.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
"""Module defining several styles.
Possible properies
* background-color
* axes
* color
* visible
* label
* color
* ticklabel
* color
* x/y/z
* color
* visible
* label
* color
* ticklabel
* color
Run:
python -m ipyvolume.style
to update the json style (needed for the js side)
"""
import os
import json
from ipyvolume import utils
styles = {}
_defaults = {
'axes': {'visible': True, 'label': {'color': 'black'}, 'ticklabel': {'color': 'black'}},
'box': {'visible': True},
}
def create(name, properties):
styles[name] = properties
return properties
light = create("light", {'background-color': 'white', 'axes': {'color': 'black'}})
default = {}
utils.dict_deep_update(default, _defaults)
utils.dict_deep_update(default, light)
dark = create(
"dark",
{
'background-color': '#000001', # for some reason we cannot set it to black!?!
'axes': {'color': 'white', 'label': {'color': 'white'}, 'ticklabel': {'color': 'white'}},
},
)
demo = create(
"demo",
{
'background-color': 'white',
'box': {'color': 'pink', 'visible': True},
'axes': {
'color': 'black',
'visible': True,
'x': {'color': '#f00', 'label': {'color': '#0f0'}, 'ticklabel': {'color': '#00f'}},
'y': {'color': '#0f0', 'label': {'color': '#00f'}, 'ticklabel': {'color': '#f00'}},
'z': {'color': '#00f', 'label': {'color': '#f00'}, 'ticklabel': {'color': '#0f0'}},
},
},
)
minimal = {'box': {'visible': False}, 'axes': {'visible': False}}
nobox = create("nobox", {'box': {'visible': False}, 'axes': {'visible': True}})
if __name__ == "__main__":
source = __file__
dest = os.path.join(os.path.dirname(source), "../js/data/style.json")
print(source, dest)
need_update = (not os.path.exists(dest)) or (os.path.getmtime(source) > os.path.getmtime(dest))
if need_update:
print(styles)
with open(dest, "w") as f:
json.dump(styles, f, indent=2)
print("wrote json")