2017-04-09 18:00:48 +00:00
|
|
|
#!/usr/bin/python3.6
|
|
|
|
|
|
|
|
import os
|
2017-05-09 15:36:36 +00:00
|
|
|
import sys
|
2017-04-09 18:00:48 +00:00
|
|
|
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',
|
2017-07-18 08:32:32 +00:00
|
|
|
'effects',
|
2017-04-09 18:00:48 +00:00
|
|
|
'home',
|
|
|
|
'issues',
|
|
|
|
'ok',
|
|
|
|
'palette',
|
|
|
|
'play',
|
|
|
|
'play_saved',
|
2017-07-08 09:32:39 +00:00
|
|
|
'power_off',
|
2017-04-09 18:00:48 +00:00
|
|
|
'replay',
|
|
|
|
'share',
|
|
|
|
'snap_off',
|
|
|
|
'snap_on',
|
|
|
|
'sound_off',
|
|
|
|
'sound_on',
|
|
|
|
'star',
|
|
|
|
'stats',
|
|
|
|
'stopwatch',
|
|
|
|
'web'
|
|
|
|
]
|
|
|
|
|
2017-05-07 16:29:31 +00:00
|
|
|
cells = [
|
|
|
|
'basic',
|
2017-05-09 15:23:28 +00:00
|
|
|
'bubble',
|
2017-07-12 13:36:28 +00:00
|
|
|
'ghost',
|
2017-09-09 11:32:25 +00:00
|
|
|
'drop',
|
2017-09-09 17:33:42 +00:00
|
|
|
'snowflake',
|
2017-09-09 18:30:03 +00:00
|
|
|
'grass',
|
|
|
|
'sun'
|
2017-05-07 16:29:31 +00:00
|
|
|
]
|
|
|
|
|
2017-04-09 18:00:48 +00:00
|
|
|
inkscape_default_dpi = 90
|
|
|
|
svg = 'buttons.svg'
|
|
|
|
root = '../android/assets/ui'
|
2017-05-09 15:36:36 +00:00
|
|
|
gen_only = sys.argv[1:]
|
2017-04-09 18:00:48 +00:00
|
|
|
|
|
|
|
for multiplier in multipliers:
|
|
|
|
folder = os.path.join(root, f'x{multiplier}')
|
|
|
|
os.makedirs(folder, exist_ok=True)
|
2017-09-09 11:32:25 +00:00
|
|
|
|
2017-04-09 18:00:48 +00:00
|
|
|
dpi = int(inkscape_default_dpi * multiplier)
|
|
|
|
print('Generating assets for', folder)
|
|
|
|
for objectid in ids:
|
2017-05-09 15:36:36 +00:00
|
|
|
if gen_only and objectid not in gen_only:
|
|
|
|
continue
|
2017-04-09 18:00:48 +00:00
|
|
|
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)
|
2017-09-09 11:32:25 +00:00
|
|
|
|
2017-05-07 16:29:31 +00:00
|
|
|
folder = os.path.join(folder, 'cells')
|
|
|
|
os.makedirs(folder, exist_ok=True)
|
|
|
|
for cellid in cells:
|
2017-05-09 15:36:36 +00:00
|
|
|
if gen_only and cellid not in gen_only:
|
|
|
|
continue
|
2017-05-07 16:29:31 +00:00
|
|
|
filename = os.path.join(folder, cellid + '.png')
|
|
|
|
run(f'inkscape -z -i{cellid} -j -e{filename} -d{dpi} {svg}',
|
|
|
|
shell=True, stdout=DEVNULL)
|