forked from Pythonity/font-awesome-to-png
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathandroid_actionbar.py
61 lines (46 loc) · 1.61 KB
/
android_actionbar.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
# generating action bar icons following the design guideline
# http://developer.android.com/design/style/iconography.html
# http://developer.android.com/design/style/metrics-grids.html
from font_to_png import *
from color_util import color_hex_to_tuple
ICON_SIZE_DIP = 24
ICON_CANVAS_DIP = 32
DENSITY = [
{ "name":"mdpi", "ratio":1},
{ "name":"hdpi", "ratio":1.5},
{ "name":"xhdpi", "ratio":2},
]
LIST = [
#"play", "fire", "beaker", "bell"
"chevron-left"
]
MDPI = 1
HDPI = 1.5
XHDPI = 2
color1 = color_hex_to_tuple("#eaeaea", (int)(256*0.8))
color2 = color_hex_to_tuple("#eaeaea", (int)(256*0.3))
def main():
#config = assets[FONT_AWESOME]
config = assets[ELUSIVE]
icons = load_icon_mapping(config)
for d in DENSITY:
name = d["name"]
ratio = d["ratio"]
print "Generating images for %s" % name
text_size = (int)(ICON_SIZE_DIP * ratio)
outter_size = (int)(ICON_CANVAS_DIP * ratio)
OUTDIR = "gen-android/drawable-%s/" % name
if not path.exists(OUTDIR):
makedirs(OUTDIR)
dummy_image = new_canvas_image(config, text_size)
for s in LIST:
fname = OUTDIR + "ic_%s_normal.png" % s
print "Exporting icon %s" % fname
export_icon(config, icons[s], text_size, fname, color1,
image=dummy_image, outter_size=outter_size)
fname = OUTDIR + "ic_%s_pressed.png" % s
print "Exporting icon %s" % fname
export_icon(config, icons[s], text_size, fname, color2,
image=dummy_image, outter_size=outter_size)
if __name__ == "__main__":
main()