"""Google Play graphics: 512×512 icon and a 1024×500 feature graphic per locale. python3 store/make_play_graphics.py Needs /profile.json from store/scene.py (the demo horizon drawn along the bottom). Writes /play-icon.png and //play/feature.png. """ import json import subprocess import sys from pathlib import Path HERE = Path(__file__).resolve().parent ROOT = HERE.parent CHROME = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome' FONTS = (ROOT / 'wasm/frontend/node_modules/@fontsource/barlow/files').as_uri() ICON = ROOT / 'assets/branding/icon-1024.png' W, H = 1024, 500 def horizon_path(profile): """Profile (360 altitudes, degrees) → SVG area path along the bottom third.""" base, gain = H, 6.0 # 1° altitude → 6 px pts = [(i * W / 359, base - 70 - alt * gain) for i, alt in enumerate(profile)] line = ' '.join(f'{x:.1f},{y:.1f}' for x, y in pts) return f'M0,{base} L{line} L{W},{base} Z', f'M{line.replace(" ", " L")}' def html(subtitle, rtl, profile): area, line = horizon_path(profile) return f'''

SkyContour

{subtitle}

''' def render(src, png, w, h): for _ in range(3): # headless Chrome occasionally exits non-zero r = subprocess.run([CHROME, '--headless=new', '--hide-scrollbars', '--allow-file-access-from-files', '--force-device-scale-factor=1', f'--window-size={w},{h}', f'--screenshot={png}', src.as_uri()], capture_output=True) if r.returncode == 0: return raise RuntimeError(f'render failed: {png}') def main(): work = Path(sys.argv[1]) meta = json.loads((HERE / 'metadata.json').read_text()) profile = json.loads((work / 'profile.json').read_text()) subprocess.run(['sips', '-z', '512', '512', str(ICON), '--out', str(work / 'play-icon.png')], check=True, capture_output=True) for locale, m in meta.items(): if locale.startswith('_'): continue out = work / locale / 'play' out.mkdir(parents=True, exist_ok=True) page = out / 'feature.html' page.write_text(html(m['subtitle'], m['app'] == 'ar', profile)) render(page, out / 'feature.png', W, H) print(locale, 'ok') if __name__ == '__main__': main()