#!/usr/bin/env python3 """Generate the Health app icon set from one mark: a live heartbeat trace. python3 assets/icon-src/make.py # needs `resvg` and `magick` (Homebrew) The mark is a bold ECG trace in the dashboard's blue → violet → pink gradient that fades in from the left and ends in a glowing "now" dot, like the live point on a chart. The background is the app's near-black (#0d0d0f) with a violet glow. Writes the SVG sources next to this file and the PNGs into assets/images/: icon.png 1024 opaque (iOS + fallback) android-icon-background.png 1024 opaque (adaptive background) android-icon-foreground.png 1024 alpha (adaptive foreground, inside the 66dp safe zone) android-icon-monochrome.png 1024 alpha (themed icon, white glyph) splash-icon.png 512 alpha (splash, glyph only) favicon.png 64 opaque (web) """ import os import subprocess HERE = os.path.dirname(os.path.abspath(__file__)) IMAGES = os.path.join(HERE, '..', 'images') BG_CENTER, BG_EDGE = '#1d1a33', '#0b0b0e' TRACE = [(0, '#3fc8f2'), (0.5, '#7c6cf7'), (1, '#f06bc0')] # blue → accent violet → pink # x in 0..1 across the glyph, y in -1..1 (negative = up) PULSE = [(0.00, 0), (0.22, 0), (0.29, -0.17), (0.35, 0.0), (0.40, 0), (0.49, -1.0), (0.59, 0.82), (0.67, -0.20), (0.72, 0), (0.90, 0)] def svg(size, body, defs=''): return (f'{defs}{body}\n') def background(size): defs = (f'' f'') return defs, f'' def pulse(size, scale, mono=False, glow=True, shift=0.0, halo=1.55): """scale = glyph width as a fraction of the canvas.""" w = size * scale amp, stroke = w * 0.42, w * 0.105 c = size / 2 left = c - shift * w - w / 2 pts = [(left + x * w, c + amp * 0.08 + y * amp) for x, y in PULSE] if mono: # no fade in a single colour: start the trace later instead pts = [(left + 0.12 * w, pts[0][1])] + pts[2:] d = 'M' + ' L'.join(f'{x:.1f} {y:.1f}' for x, y in pts) ex, ey = pts[-1] line = (f'') if mono: return '', line.format(s='#fff') + f'' stops = ''.join(f'' for p, col in TRACE) defs = (f'{stops}' f'' f'' f'' f'' f'' f'' f'' f'') trace = line.format(s='url(#pl)') body = '' if glow: body += f'{trace}' body += f'' body += f'{trace}' body += (f'') body += f'' return defs, body def main(): bd, bb = background(1024) # iOS: full-bleed, glyph spans 76% (Apple rounds the corners itself) gd, gb = pulse(1024, 0.76) sources = { 'icon': (1024, svg(1024, bb + gb, bd + gd)), 'background': (1024, svg(1024, bb, bd)), # Android adaptive: shifted left (the trace fades in) so the dot + halo clear the 66dp safe circle 'foreground': (1024, svg(1024, *reversed(pulse(1024, 0.55, shift=0.045, halo=1.35)))), # themed icons read best a little smaller than the colour glyph 'monochrome': (1024, svg(1024, *reversed(pulse(1024, 0.46, mono=True, glow=False, shift=0.045)))), 'splash': (512, svg(512, *reversed(pulse(512, 0.94, glow=False)))), } out = { 'icon': 'icon.png', 'background': 'android-icon-background.png', 'foreground': 'android-icon-foreground.png', 'monochrome': 'android-icon-monochrome.png', 'splash': 'splash-icon.png', } for name, (size, text) in sources.items(): src = os.path.join(HERE, f'{name}.svg') with open(src, 'w') as f: f.write(text) png = os.path.join(IMAGES, out[name]) subprocess.run(['resvg', '-w', str(size), '-h', str(size), src, png], check=True) # iOS rejects icons with an alpha channel; the web favicon is the icon at 64px icon = os.path.join(IMAGES, 'icon.png') subprocess.run(['magick', icon, '-background', BG_EDGE, '-alpha', 'remove', '-alpha', 'off', icon], check=True) bgp = os.path.join(IMAGES, 'android-icon-background.png') subprocess.run(['magick', bgp, '-alpha', 'off', bgp], check=True) subprocess.run(['magick', icon, '-resize', '64x64', os.path.join(IMAGES, 'favicon.png')], check=True) print('wrote', ', '.join(out.values()), 'favicon.png') if __name__ == '__main__': main()