harbour-aira 0.1.0: client Sailfish per pompa di calore Aira (bridge HTTP + stato e comandi ACS)
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Genera le icone di harbour-aira (86/108/128/172 px) in icons/<size>/.
|
||||
|
||||
Disegno originale (nessun logo di terzi): sfondo blu sfumato, goccia bianca e
|
||||
un punto caldo arancione — acqua calda + pompa di calore.
|
||||
Uso: python3 scripts/make_icons.py
|
||||
"""
|
||||
from PIL import Image, ImageDraw
|
||||
|
||||
import pathlib
|
||||
|
||||
SIZES = [86, 108, 128, 172]
|
||||
BASE = 172 # si disegna grande e si ridimensiona: bordi puliti a ogni taglia
|
||||
|
||||
TOP = (12, 62, 130) # blu profondo
|
||||
BOTTOM = (24, 148, 190) # azzurro
|
||||
WARM = (255, 138, 46) # arancione
|
||||
|
||||
|
||||
def rounded_mask(size, radius):
|
||||
m = Image.new("L", (size, size), 0)
|
||||
ImageDraw.Draw(m).rounded_rectangle([0, 0, size - 1, size - 1], radius=radius, fill=255)
|
||||
return m
|
||||
|
||||
|
||||
def gradient(size):
|
||||
img = Image.new("RGB", (1, size))
|
||||
d = ImageDraw.Draw(img)
|
||||
for y in range(size):
|
||||
t = y / max(1, size - 1)
|
||||
d.point((0, y), tuple(int(TOP[i] + (BOTTOM[i] - TOP[i]) * t) for i in range(3)))
|
||||
return img.resize((size, size))
|
||||
|
||||
|
||||
def draw_icon(size):
|
||||
img = gradient(size).convert("RGBA")
|
||||
d = ImageDraw.Draw(img)
|
||||
|
||||
# goccia: cerchio + triangolo verso l'alto
|
||||
cx = size * 0.5
|
||||
cy = size * 0.60
|
||||
r = size * 0.19
|
||||
d.ellipse([cx - r, cy - r, cx + r, cy + r], fill=(255, 255, 255, 235))
|
||||
d.polygon([(cx, cy - 2.35 * r), (cx - r * 0.98, cy + r * 0.10), (cx + r * 0.98, cy + r * 0.10)],
|
||||
fill=(255, 255, 255, 235))
|
||||
# ricentra la goccia: il triangolo allunga verso l'alto
|
||||
shift = -size * 0.05
|
||||
img = img.transform(img.size, Image.AFFINE, (1, 0, 0, 0, 1, shift))
|
||||
|
||||
d = ImageDraw.Draw(img)
|
||||
# punto caldo in basso a destra, dentro la goccia
|
||||
wr = size * 0.085
|
||||
wx, wy = cx + r * 0.10, cy + r * 0.30
|
||||
for i in range(int(wr), 0, -1):
|
||||
a = int(255 * (1 - i / wr) + 90)
|
||||
d.ellipse([wx - i, wy - i, wx + i, wy + i], fill=WARM + (a,))
|
||||
|
||||
return img
|
||||
|
||||
|
||||
def main():
|
||||
master = draw_icon(BASE)
|
||||
master.putalpha(rounded_mask(BASE, int(BASE * 0.22)))
|
||||
|
||||
for s in SIZES:
|
||||
out = master.resize((s, s), Image.LANCZOS)
|
||||
outdir = pathlib.Path(f"icons/{s}x{s}")
|
||||
outdir.mkdir(parents=True, exist_ok=True)
|
||||
path = outdir / "harbour-aira.png"
|
||||
out.save(path)
|
||||
print("scritto", path)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user