Add Python script to generate assets for larger screens
Before Width: | Height: | Size: 1 KiB After Width: | Height: | Size: 1 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 656 B After Width: | Height: | Size: 656 B |
Before Width: | Height: | Size: 818 B After Width: | Height: | Size: 818 B |
Before Width: | Height: | Size: 3 KiB After Width: | Height: | Size: 3 KiB |
Before Width: | Height: | Size: 964 B After Width: | Height: | Size: 964 B |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 564 B After Width: | Height: | Size: 564 B |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 782 B After Width: | Height: | Size: 782 B |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 670 B After Width: | Height: | Size: 670 B |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
58
original-resources/gen-ui-png.py
Executable 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)
|
||||
|