Files
stemify/ios/scripts/make-icon.py
T
rootandClaude Opus 5.5 ac0e962105 New app icon: glowing stem-colored capsules on a night gradient (dev 37)
Generator in ios/scripts/make-icon.py renders release, dev (sash),
dark and tinted variants.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 16:59:51 -08:00

102 lines
5.5 KiB
Python

"""Run from a venv with resvg-py and pillow: python make-icon.py OUTDIR
Stemify app icon: six stem-colored capsules (the app's stem palette) glowing on a deep night background.
Usage: make.py OUTDIR -> icon.png, icon-dev.png, icon-dev-dark.png, icon-dev-tinted.png"""
import io, sys
import resvg_py
from PIL import Image
S = 1024
# vocals, drums, bass, guitar, piano, other (PlaybackManager stem colors)
STEMS = [0xFF7AB6, 0xFFB547, 0x7C8CFF, 0xFF8A5C, 0xB48CFF, 0x4CD07D]
HEIGHTS = [300, 510, 390, 620, 455, 330]
W, GAP = 78, 30
def hx(c): return f"#{c:06X}"
def mix(c, t, k):
a = [(c >> s) & 255 for s in (16, 8, 0)]; b = [(t >> s) & 255 for s in (16, 8, 0)]
return "#" + "".join(f"{round(x + (y - x) * k):02X}" for x, y in zip(a, b))
def svg(mode="color", sash=False):
tint = mode == "tinted"
total = len(STEMS) * W + (len(STEMS) - 1) * GAP
x0 = (S - total) / 2
cy = S / 2 + 6
defs, glow, bars, shine = [], [], [], []
for i, (c, h) in enumerate(zip(STEMS, HEIGHTS)):
if tint: c = 0xFFFFFF
x, y = x0 + i * (W + GAP), cy - h / 2
defs.append(f'<linearGradient id="g{i}" x1="0" y1="0" x2="0" y2="1">'
f'<stop offset="0" stop-color="{mix(c, 0xFFFFFF, 0.38)}"/>'
f'<stop offset="0.55" stop-color="{hx(c)}"/>'
f'<stop offset="1" stop-color="{mix(c, 0x000000, 0.18 if not tint else 0.45)}"/></linearGradient>')
r = W / 2
glow.append(f'<rect x="{x}" y="{y}" width="{W}" height="{h}" rx="{r}" fill="{hx(c)}"/>')
bars.append(f'<rect x="{x}" y="{y}" width="{W}" height="{h}" rx="{r}" fill="url(#g{i})"/>')
# glassy highlight down the left edge
shine.append(f'<rect x="{x + W * 0.2}" y="{y + W * 0.32}" width="{W * 0.17}" height="{max(h * 0.42, 40)}" '
f'rx="{W * 0.085}" fill="#FFFFFF" opacity="0.22"/>')
if tint:
bg = '<rect width="1024" height="1024" fill="#000"/>'
aura = ""
else:
bg = ('<radialGradient id="bg" cx="0.5" cy="0.42" r="0.78">'
'<stop offset="0" stop-color="#211A3A"/><stop offset="0.55" stop-color="#110E1F"/>'
'<stop offset="1" stop-color="#05040A"/></radialGradient>'
'<rect width="1024" height="1024" fill="url(#bg)"/>')
# soft colored light pooling behind the bars
aura = ('<g filter="url(#aura)" opacity="0.55">'
f'<circle cx="330" cy="420" r="190" fill="{hx(STEMS[0])}"/>'
f'<circle cx="690" cy="400" r="200" fill="{hx(STEMS[4])}"/>'
f'<circle cx="520" cy="660" r="210" fill="{hx(STEMS[2])}"/>'
f'<circle cx="760" cy="640" r="150" fill="{hx(STEMS[5])}"/>'
f'<circle cx="290" cy="650" r="150" fill="{hx(STEMS[1])}"/></g>'
'<rect width="1024" height="1024" fill="#05040A" opacity="0.45"/>')
vignette = ('<radialGradient id="vig" cx="0.5" cy="0.5" r="0.72"><stop offset="0.6" stop-color="#000" stop-opacity="0"/>'
'<stop offset="1" stop-color="#000" stop-opacity="0.55"/></radialGradient>'
'<rect width="1024" height="1024" fill="url(#vig)"/>') if not tint else ""
sash_svg = ""
if sash:
sash_svg = ('<linearGradient id="sash" x1="0" y1="1" x2="1" y2="0">'
'<stop offset="0" stop-color="#FF9BD0"/><stop offset="1" stop-color="#C9A8FF"/></linearGradient>'
'<g transform="translate(222,222) rotate(-45)">'
'<rect x="-420" y="-58" width="840" height="116" fill="url(#sash)"/>'
'<line x1="-420" y1="-44" x2="420" y2="-44" stroke="#FFF" stroke-opacity="0.75" stroke-width="5" stroke-dasharray="18 14"/>'
'<line x1="-420" y1="44" x2="420" y2="44" stroke="#FFF" stroke-opacity="0.75" stroke-width="5" stroke-dasharray="18 14"/>'
'<text x="-30" y="30" text-anchor="middle" font-family="DejaVu Sans" font-weight="bold" font-size="88" '
'fill="#3A1F4D" opacity="0.45" transform="translate(4,5)">dev</text>'
'<text x="-30" y="30" text-anchor="middle" font-family="DejaVu Sans" font-weight="bold" font-size="88" fill="#FFF">dev</text>'
'<path transform="translate(118,-4) scale(2.6)" fill="#FFF" '
'd="M0 9 C-9 3 -12 -3 -8 -8 C-5 -11 -1 -10 0 -6 C1 -10 5 -11 8 -8 C12 -3 9 3 0 9 Z"/></g>')
return f'''<svg xmlns="http://www.w3.org/2000/svg" width="1024" height="1024" viewBox="0 0 1024 1024">
<defs>{"".join(defs)}
<filter id="aura" x="-50%" y="-50%" width="200%" height="200%"><feGaussianBlur stdDeviation="110"/></filter>
<filter id="glow" x="-50%" y="-50%" width="200%" height="200%"><feGaussianBlur stdDeviation="26"/></filter>
<filter id="drop" x="-50%" y="-50%" width="200%" height="200%"><feGaussianBlur stdDeviation="10"/></filter>
</defs>
{bg}{aura}
<g filter="url(#glow)" opacity="{0.25 if tint else 0.7}">{"".join(glow)}</g>
<g filter="url(#drop)" opacity="0.5" transform="translate(0,14)">{"".join(g.replace('fill="#', 'fill="#000" data-c="') for g in glow)}</g>
<g>{"".join(bars)}</g>
<g>{"".join(shine)}</g>
{vignette}{sash_svg}
</svg>'''
def png(s, path, gray=False):
im = Image.open(io.BytesIO(bytes(resvg_py.svg_to_bytes(svg_string=s)))).convert("RGB")
(im.convert("L") if gray else im).save(path, optimize=True)
out = sys.argv[1]
png(svg(), f"{out}/icon.png")
png(svg(sash=True), f"{out}/icon-dev.png")
png(svg(sash=True), f"{out}/icon-dev-dark.png")
png(svg("tinted", sash=True), f"{out}/icon-dev-tinted.png", gray=True)
open(f"{out}/icon.svg", "w").write(svg())