"""Generates the Pipelines app icon: the Pipelines tab glyph (Material
account_tree, outlined) in white on the dark app background.
python3 make_icon.py OUTDIR
Writes rounded.svg (web, legacy Android), square.svg (iOS), maskable.svg (PWA)
and the Android vectors: adaptive foreground, themed monochrome and the
status-bar icon.
"""
import os
import sys
OUT = sys.argv[1]
# Material Icons "account_tree" (outlined), 24-unit grid.
# Extracted from Flutter's MaterialIcons-Regular.otf (U+EE36).
GLYPH = 'M21.984 11.016V3H15V6H9V3H2.016V11.016H9V8.016H11.016V18H15V21H21.984V12.984H15V15.984H12.984V8.016H15V11.016H21.984ZM6.984 9H3.984V5.016H6.984V9ZM17.016 15H20.016V18.984H17.016V15ZM17.016 5.016H20.016V9H17.016V5.016Z'
WHITE = '#FFFFFF'
def svg(glyph_size=34.0, rounded=True):
rx = ' rx="14"' if rounded else ''
s = glyph_size / 24
t = 32 - 12 * s
return f'''
'''
def vector(size, glyph_size, comment):
s = glyph_size / 24
t = size / 2 - 12 * s
return f'''
'''
for name, body in {
'rounded.svg': svg(),
'square.svg': svg(rounded=False),
'maskable.svg': svg(glyph_size=28, rounded=False),
}.items():
open(os.path.join(OUT, name), 'w').write(body)
# Adaptive canvas 108dp: the glyph at ~46dp sits well inside the 66dp safe zone.
open(os.path.join(OUT, 'ic_launcher_foreground.xml'), 'w').write(vector(108, 46, 'Adaptive icon foreground.'))
open(os.path.join(OUT, 'ic_launcher_monochrome.xml'), 'w').write(vector(108, 46, 'Themed (monochrome) icon.'))
open(os.path.join(OUT, 'ic_stat_pipelines.xml'), 'w').write(vector(24, 22, 'Status bar icon (Android tints it).'))
print('ok')