Add Python script to generate assets for larger screens

This commit is contained in:
Lonami Exo 2017-04-09 20:00:48 +02:00
parent cdd7983e84
commit 2883ced7b7
23 changed files with 58 additions and 0 deletions

View file

Before

Width:  |  Height:  |  Size: 1 KiB

After

Width:  |  Height:  |  Size: 1 KiB

View file

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

Before

Width:  |  Height:  |  Size: 656 B

After

Width:  |  Height:  |  Size: 656 B

View file

Before

Width:  |  Height:  |  Size: 818 B

After

Width:  |  Height:  |  Size: 818 B

View file

Before

Width:  |  Height:  |  Size: 3 KiB

After

Width:  |  Height:  |  Size: 3 KiB

View file

Before

Width:  |  Height:  |  Size: 964 B

After

Width:  |  Height:  |  Size: 964 B

View file

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View file

Before

Width:  |  Height:  |  Size: 564 B

After

Width:  |  Height:  |  Size: 564 B

View file

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View file

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

Before

Width:  |  Height:  |  Size: 782 B

After

Width:  |  Height:  |  Size: 782 B

View file

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View file

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

Before

Width:  |  Height:  |  Size: 670 B

After

Width:  |  Height:  |  Size: 670 B

View file

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -0,0 +1,58 @@
#!/usr/bin/python3.6
import os
from subprocess import run, DEVNULL
multipliers = [0.75, 1.0, 1.25, 1.5, 2.0, 4.0]
# Another option would be to query all IDs 'inkscape -S' as described on:
# http://tavmjong.free.fr/INKSCAPE/MANUAL/html/CommandLine-Query.html
#
# More exporting notes (arguments used and default DPI):
# http://tavmjong.free.fr/INKSCAPE/MANUAL/html/CommandLine-General.html
# http://tavmjong.free.fr/INKSCAPE/MANUAL/html/CommandLine-Export.html
ids = [
'back',
'button_down',
'button_up',
'cancel',
'credits',
'cup',
'home',
'issues',
'ok',
'palette',
'play',
'play_saved',
'replay',
'share',
'snap_off',
'snap_on',
'sound_off',
'sound_on',
'star',
'stats',
'stopwatch',
'web'
]
inkscape_default_dpi = 90
svg = 'buttons.svg'
root = '../android/assets/ui'
for multiplier in multipliers:
folder = os.path.join(root, f'x{multiplier}')
os.makedirs(folder, exist_ok=True)
dpi = int(inkscape_default_dpi * multiplier)
print('Generating assets for', folder)
for objectid in ids:
filename = os.path.join(folder, objectid + '.png')
# -z not to use the X server
# -i to select the given object id
# -j to only export that object, even with others overlapped
# -e to export a file
# -d to specify the DPI
run(f'inkscape -z -i{objectid} -j -e{filename} -d{dpi} {svg}',
shell=True, stdout=DEVNULL)