#!/usr/bin/env python3 """Render the dmg background from the landing page's ascii-hand recipe. Reuses the exact ingredients of apps/landing/public/index.html — the two hand density maps, the glyph ramp, the drifting noise field, purple on near-black — but frozen at one instant and composed for the 660x400 pt drag-to-Applications window (app icon at x=165, Applications at x=495, both at y=195). Outputs dist/macos/dmg-background.png (1x) and dmg-background@2x.png; scripts/package-macos.sh pairs them into a hidpi tiff with tiffutil. Both outputs are committed so CI never needs Pillow — rerun this only when changing the artwork. Usage: python3 scripts/dmg-background.py """ import os from PIL import Image, ImageDraw, ImageFont ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) FONT = os.path.join(ROOT, "crates/ui/assets/fonts/GeistMono.ttf") OUT = os.path.join(ROOT, "dist/macos") # Window geometry in points; must match the dmgbuild settings in # scripts/package-macos.sh. W, H = 660, 400 BG = (6, 4, 10) # --bg PURPLE = (139, 92, 246) # --purple RAMP = [" ", " ", " ", ".", ":", ">", "~", "×", "*", "#"] # Landing cell is 12x14 css px with a 10px font; the dmg window is smaller # than the closing section, so the hands render at reduced scale. SCALE = 0.6 CW, CH, FS = 12 * SCALE, 14 * SCALE, 10 * SCALE # Frozen instant of the drifting field (t = ms * 0.00022 on the landing). T = 1.35 HAND_DOWN = """70635533333633333633666666306605333200222100100000000000 78873333333336333333666363366653333032220001001000000000 00899777763333333333336333333605333330222000011000000000 78999999999963363333333333333663333530222021101000000000 66777889999998633333333333333333633333322220011101000000 63336667899999983333333333333333333333320022200101000000 78333336789999998633333333333333333300302220210010000000 69863336778999999973333333333333333333032222211100100000 79986333366778999997333333333333333333333022200101100000 77777333333678999999963333333333333333330222000000100000 33333333336777899999998636333333333333033222021001110000 33377663333366677899999986333333333333333222220101000000 33333333333333333367899999763333333333333002221111000000 33333333333333333337778999888633333333300222021001000000 33333333333333333333367999988733333333333222220000010000 33333333333333333333368999998883333333333202201010100000 33333333333333333333668888898777333333303222222010000000 33333333333333333333887368999888733330333222000011000000 33333333333333333333876689999989873333330020220011000000 33333333333333333333677778888999977333330222220010000000 33333333333333333336677333336789987733302200211001100000 33333333333333333333787333333367766606332220010000000000 33333333333333333337897333333336787633322222010110000000 33333333333333333337333333333333337803322002110100000000 33333333333333333333333333333333333007022000000100000000 33333333333333333333336333333333333336642220011100000000 33333333333333333333367333333330333332064020010110000000 03333333333333333333337733333030333222034210100000000000 33333333333333333333336633333333002202202020100000000000 02303333333333333333333333333303022222000000010000000000 22033030333333333333333363333333222202211001100000000000 20202333033333330333303353333322222000011101000000000000 02022220333333333333333773000222220201010001000000000000 22222022223333333333333332022220022010010010000000000000 02020022222222233333322222022020010100000000000000000000 10020202002222020202222200022000101100000000000000000000 10001022202222022202222220020111000000010000000000000000 10010100220200202002002020201001000000000000000000000000 11000110100012200202200100100001111000000000000000000000 10001110110110101111011001000011000000000000000000000000 00001001100111001101000010011000000000000000000000000000 00000110000100110010101110010000000000000000000000000000 00000000000000000100110000000000000000000000000000000000""" HAND_UP = """000000000011011000020000000000003230000202000000 000000000010000200333300030303330030332200020000 000000000002202333033444044044044430002000000220 000001002020033334000440040404005044402040122020 000110002003300004400505055555055404044422300322 001000022330034044555555555500505555544000443002 000012230300344555555056660875665505004022204300 110000302304040650606660768833666555350553244443 010000000404420656666670679933666635555530334044 000020330040550555366776689933666633333555530000 022200300440706666666766688733666633330665330540 112000304555233666666666667833366633336635533304 020300005675333366666666668836336333366666633333 022033442200633336666666667638863666666666330330 000334405230773333786366666789967666666663333533 000030445533333333798666337999973366666633336633 020034455553333333338999999999983366663333363335 223330005503333373337899998999976333633333333333 003334005566333366783367888999763336633363333333 203400440566633333886336789987633333366633333333 233304455566633333766679999766333333333333333333 033044555556663333333777998873333333333333333333 033445555566666333337999999973333333333333333333 033402405556666633333789988733333333333333333333 003444455505336663333333333333636333333633330333 200300005555633663333333333333766633333333333333 003034055555566366663333333333386763633333333333 003004542500666336633333333333878676763333333333 002030045555336633363333333333377766663333333330 000000304053333366336333333333377877663333330333 000000304523333336333333333333678877666333333332 000003340202333303333633333333377877666333333022 010122002222203333533663333333336777770633333222 001100002222220333335333333333333670767650332020 000000123332222233353333333333333367076665040022 000100000020200202035533003330033036777055404222""" def field(x, y, t): import math a, b = x * 0.55, y * 0.35 v = math.sin(a + 2.1 * math.sin(b * 0.9 + t) + t * 0.7) * math.cos( b - 1.7 * math.sin(a * 0.6 - t * 0.8) ) return 0.5 + 0.5 * v def draw_hand(draw, font, data, ox, px, py, s): """Paint one hand with its top-left cell at point (px, py). Alpha fades near the window's top and bottom edges — the same visual as the landing's css mask, but window-relative so cropped hands dissolve into the edges instead of vanishing. """ grid = data.split("\n") for y, row in enumerate(grid): pos = (py + y * CH) / H fade = min(1.0, max(0.0, pos) / 0.12, max(0.0, 1 - pos) / 0.12) if fade <= 0: continue for x, ch in enumerate(row): base = int(ch) / 9 if not base: continue v = base * (0.72 + 0.58 * field(x + ox, y, T)) g = RAMP[min(len(RAMP) - 1, int(v * len(RAMP)))] if g == " ": continue alpha = min(0.85, (0.16 + v * 0.5) * 1.25) * fade cx, cy = (px + x * CW + 2 * SCALE) * s, (py + y * CH + 2 * SCALE) * s if cx < -CW * s or cy < -CH * s or cx > W * s or cy > H * s: continue draw.text((cx, cy), g, font=font, fill=PURPLE + (round(alpha * 255),)) def render(s, path): """Render the full background at pixel scale s (1 or 2).""" img = Image.new("RGB", (W * s, H * s), BG) layer = Image.new("RGBA", img.size, (0, 0, 0, 0)) draw = ImageDraw.Draw(layer) font = ImageFont.truetype(FONT, round(FS * s)) # hand-down descends from the top-left, fingers reaching toward the app # icon; hand-up rises behind Applications on the right — the same # corner-to-corner pairing as the landing closing section. draw_hand(draw, font, HAND_DOWN, 101, -70, -30, s) draw_hand(draw, font, HAND_UP, 811, 390, 130, s) # drag hint: a run of ramp chevrons between the two icons, brightening # toward Applications. chev = ImageFont.truetype(FONT, round(15 * s)) for i, cx in enumerate(range(285, 386, 25)): alpha = 0.28 + i * 0.13 draw.text( (cx * s, 188 * s), "›", font=chev, fill=PURPLE + (round(alpha * 255),) ) img.paste(layer, (0, 0), layer) img.save(path) print(f"wrote {os.path.relpath(path, ROOT)} ({img.size[0]}x{img.size[1]})") render(1, os.path.join(OUT, "dmg-background.png")) render(2, os.path.join(OUT, "dmg-background@2x.png"))