Files
harbour-calibreweb/icons/make_icons.py
T

56 lines
1.7 KiB
Python

#!/usr/bin/env python3
"""Genera le icone dell'app: harbour-calibreweb.png (86x86) e -108 (108x108)."""
from PIL import Image, ImageDraw
BG = (46, 52, 64) # #2E3440
ACCENT = (136, 192, 208) # #88C0D0
PAGE = (229, 233, 240) # #E5E9F0
SPINE = (94, 129, 172) # #5E81AC
def draw_icon(size):
img = Image.new("RGBA", (size, size), (0, 0, 0, 0))
d = ImageDraw.Draw(img)
margin = size * 0.045
radius = size * 0.16
# sfondo arrotondato
d.rounded_rectangle([margin, margin, size - margin, size - margin],
radius=radius, fill=BG)
# libro aperto: due pagine trapezoidali + dorso
cx = size / 2
top = size * 0.34
bot = size * 0.68
half = size * 0.16
outer_l = size * 0.22
outer_r = size * 0.78
left_page = [(cx - half, top), (cx, top), (cx, bot), (outer_l, bot + size * 0.04)]
right_page = [(cx, top), (cx + half, top), (outer_r, bot + size * 0.04), (cx, bot)]
d.polygon(left_page, fill=ACCENT)
d.polygon(right_page, fill=ACCENT)
# dorso
d.rectangle([cx - size * 0.014, top, cx + size * 0.014, bot], fill=SPINE)
# righe delle pagine
lw = max(1, int(size * 0.012))
for y_frac in (0.45, 0.52, 0.59):
y = size * y_frac
d.line([(cx - half + size * 0.03, y), (outer_l + size * 0.06, y + size * 0.025)],
fill=PAGE, width=lw)
d.line([(cx + half - size * 0.03, y), (outer_r - size * 0.06, y + size * 0.025)],
fill=PAGE, width=lw)
return img
def main():
draw_icon(108).save("icons/harbour-calibreweb-108.png")
draw_icon(86).save("icons/harbour-calibreweb.png")
print("icone scritte")
if __name__ == "__main__":
main()