#!/usr/bin/env python3 """Genera le icone dell'app nelle 4 dimensioni richieste da Sailfish. Uso: python3 icons/make_icons.py Output: icons/x/harbour-thinq.png """ from pathlib import Path from PIL import Image, ImageDraw SIZES = (86, 108, 128, 172) ROOT = Path(__file__).resolve().parent def rounded(draw, box, radius, fill): draw.rounded_rectangle(box, radius=radius, fill=fill) def make_icon(size: int) -> Image.Image: scale = 4 # si disegna grande e si riduce: bordi puliti a 86 px s = size * scale img = Image.new("RGBA", (s, s), (0, 0, 0, 0)) d = ImageDraw.Draw(img) # sfondo: quadrato arrotondato, gradiente verticale azzurro -> blu radius = int(s * 0.22) for i in range(s): t = i / max(1, s - 1) r = int(0x5E + (0x0E - 0x5E) * t) g = int(0xD2 + (0x6F - 0xD2) * t) b = int(0xF0 + (0xA8 - 0xF0) * t) d.line([(0, i), (s, i)], fill=(r, g, b, 255)) mask = Image.new("L", (s, s), 0) ImageDraw.Draw(mask).rounded_rectangle([0, 0, s - 1, s - 1], radius=radius, fill=255) img.putalpha(mask) # corpo della lavatrice: rettangolo bianco con l'oblò body = [int(s * 0.20), int(s * 0.18), int(s * 0.80), int(s * 0.84)] rounded(d, body, int(s * 0.05), (255, 255, 255, 240)) # pannello dei comandi panel_h = int(s * 0.09) d.rectangle([body[0], body[1], body[2], body[1] + panel_h], fill=(210, 225, 235, 255)) # oblò: cerchio (anello scuro + acqua chiara) cx = (body[0] + body[2]) // 2 cy = int(s * 0.56) r_out = int(s * 0.21) d.ellipse([cx - r_out, cy - r_out, cx + r_out, cy + r_out], fill=(30, 70, 110, 255)) r_in = int(r_out * 0.78) d.ellipse([cx - r_in, cy - r_in, cx + r_in, cy + r_in], fill=(150, 210, 240, 255)) # riflesso d.ellipse([cx - int(r_in * 0.62), cy - int(r_in * 0.78), cx - int(r_in * 0.05), cy - int(r_in * 0.18)], fill=(255, 255, 255, 150)) return img.resize((size, size), Image.LANCZOS) def main() -> None: for size in SIZES: out_dir = ROOT / f"{size}x{size}" out_dir.mkdir(parents=True, exist_ok=True) icon = make_icon(size) icon.save(out_dir / "harbour-thinq.png") print(f"scritta {out_dir / 'harbour-thinq.png'}") if __name__ == "__main__": main()