Kaleido/scripts/generate_brand_tiles.py
Elijah c7fbc5a314
All checks were successful
Validate and publish Kaleido / android (push) Successful in 2m19s
Release 0.1.7 with a colored launcher banner and icon
The banner and app icon keep the unchanged six-facet mark but replace
the flat black background with a diagonal light: deep sea-glass at the
top right fading through near-black to a warm tan glow at the bottom
left, with a soft vignette and nothing over the aperture. A small
generator rebuilds both drawables from brand_mark.xml.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 12:23:47 -07:00

29 lines
2 KiB
Python

"""Generate the launcher banner and app icon vector drawables from brand_mark.xml.
The mark is copied unchanged; only the background is drawn here: a diagonal light from
deep sea-glass (top right) through near-black to a warm tan glow (bottom left), echoing the
mark's cool and warm facets, with a soft vignette. Nothing covers the mark's dark aperture.
"""
import pathlib,re
ROOT=pathlib.Path(__file__).resolve().parents[1]
DRAWABLE=ROOT/'app/src/main/res/drawable'
MARK=re.findall(r'<path [^>]*/>',(DRAWABLE/'brand_mark.xml').read_text())
def color(hex6,alpha):return f'#{round(alpha*255):02X}{hex6}'
def gradient(kind,attrs,stops):
items=''.join(f'<item android:offset="{o}" android:color="{c}"/>' for o,c in stops)
return f'<aapt:attr name="android:fillColor"><gradient android:type="{kind}" {attrs}>{items}</gradient></aapt:attr>'
def tile(width,height,mark_scale,mark_x,mark_y):
cx,cy=width/2,height/2;rect=f'M0,0h{width}v{height}h-{width}z'
light=gradient('linear',f'android:startX="{width}" android:startY="0" android:endX="0" android:endY="{height}"',
[(0,'#FF1B403C'),(.5,'#FF101414'),(1,'#FF30241A')])
vignette=gradient('radial',f'android:centerX="{cx}" android:centerY="{cy}" android:gradientRadius="{width*.62:.1f}"',
[(.35,color('000000',0)),(1,color('000000',.45))])
group=f'<group android:translateX="{mark_x}" android:translateY="{mark_y}" android:scaleX="{mark_scale}" android:scaleY="{mark_scale}">'+''.join(MARK)+'</group>'
return ('<vector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:aapt="http://schemas.android.com/aapt" '
f'android:width="{width}dp" android:height="{height}dp" android:viewportWidth="{width}" android:viewportHeight="{height}">'
f'<path android:pathData="{rect}">{light}</path><path android:pathData="{rect}">{vignette}</path>'+group+'</vector>\n')
(DRAWABLE/'banner.xml').write_text(tile(320,180,1.6,108.8,38.8))
(DRAWABLE/'icon.xml').write_text(tile(108,108,1,22,22))
print('Wrote banner.xml and icon.xml')