Files
photoreport/apps/desktop/scripts/make-icon.py
T
sparkandClaude Opus 5.5 31a056542e
ci / typescript (push) Failing after 40s
ci / rust (push) Successful in 1m36s
feat(desktop): Tauri shell with keychain sign-in; docs status (6/10)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HT6iXLYUUp9pJz5Kza9xCW
2026-10-11 14:46:46 +01:00

43 lines
1.6 KiB
Python

"""Draws the 1024 px source icon (same mark as the web favicon) so no binary image lives in the repo.
`pnpm --filter @photoreport/desktop icons` then derives every platform size with `tauri icon`."""
import math
import os
import struct
import zlib
N = 1024
BG, INK, ACCENT = (0x17, 0x18, 0x1A), (0xE8, 0xE9, 0xEB), (0x3B, 0x82, 0xF6)
S = N / 32 # the mark is drawn on a 32-unit grid
pixels = [[BG for _ in range(N)] for _ in range(N)]
def rect(x0, y0, x1, y1, colour):
for y in range(int(y0 * S), int(y1 * S)):
for x in range(int(x0 * S), int(x1 * S)):
pixels[y][x] = colour
HALF = 1.1 # half the stroke width
for a, b, c, d in [(8, 8, 13, 8), (8, 8, 8, 13), (19, 8, 24, 8), (24, 8, 24, 13),
(24, 19, 24, 24), (19, 24, 24, 24), (8, 24, 13, 24), (8, 19, 8, 24)]:
rect(min(a, c) - HALF, min(b, d) - HALF, max(a, c) + HALF, max(b, d) + HALF, INK)
for y in range(N):
for x in range(N):
if math.hypot(x / S - 16, y / S - 16) <= 3.2:
pixels[y][x] = ACCENT
raw = b"".join(b"\x00" + bytes(v for p in row for v in (*p, 255)) for row in pixels)
def chunk(kind, data):
return struct.pack(">I", len(data)) + kind + data + struct.pack(">I", zlib.crc32(kind + data) & 0xFFFFFFFF)
png = (b"\x89PNG\r\n\x1a\n" + chunk(b"IHDR", struct.pack(">IIBBBBB", N, N, 8, 6, 0, 0, 0))
+ chunk(b"IDAT", zlib.compress(raw, 9)) + chunk(b"IEND", b""))
out = os.path.join(os.path.dirname(__file__), "..", "src-tauri", "icons", "source.png")
os.makedirs(os.path.dirname(out), exist_ok=True)
with open(out, "wb") as f:
f.write(png)
print(f"wrote {os.path.normpath(out)}")