#!/usr/bin/env python3 """Genera le icone di harbour-server (86/108/128/172 px). Motivo: piastrina scura con una traccia "battito" verde — lo stesso segno che l'app mostra quando tutto è in ordine. """ from pathlib import Path from PIL import Image, ImageDraw ROOT = Path(__file__).resolve().parent.parent SIZES = (86, 108, 128, 172) BG = (20, 24, 28) TRACE = (67, 160, 71) DIM = (110, 120, 128) # Traccia in coordinate 0..100 (x, y): parte piatta, picco, coda piatta. TRACE_POINTS = [ (6, 52), (30, 52), (38, 30), (46, 74), (54, 44), (62, 52), (94, 52), ] def draw(size: int) -> Image.Image: scale = 4 # disegno in grande e riduco: linee pulite anche a 86 px S = size * scale img = Image.new("RGBA", (S, S), (0, 0, 0, 0)) d = ImageDraw.Draw(img) radius = int(S * 0.22) d.rounded_rectangle([0, 0, S - 1, S - 1], radius=radius, fill=BG) pts = [(int(x * S / 100), int(y * S / 100)) for x, y in TRACE_POINTS] width = max(2, int(S * 0.045)) d.line(pts, fill=TRACE, width=width, joint="curve") # Tre tacche in basso: i "parametri" sotto la traccia. for i, x in enumerate((22, 50, 78)): y0 = int(S * 0.78) h = int(S * (0.10 + 0.04 * i)) d.rounded_rectangle( [int(x * S / 100) - width, y0 - h, int(x * S / 100) + width, y0], radius=width, fill=DIM, ) return img.resize((size, size), Image.LANCZOS) def main() -> None: for size in SIZES: out = ROOT / "icons" / f"{size}x{size}" out.mkdir(parents=True, exist_ok=True) path = out / "harbour-server.png" draw(size).save(path) print("scritto", path) if __name__ == "__main__": main()