book_reader_app / generate_icons.py
randusertry's picture
Upload 11 files
3e6b783 verified
"""Generate PWA icons with a book graphic."""
from PIL import Image, ImageDraw
def make_icon(size, path):
img = Image.new("RGB", (size, size), color=(26, 26, 46))
draw = ImageDraw.Draw(img)
# Draw a simple open book shape
m = size // 8 # margin
cx = size // 2
cy = size // 2
# Left page
draw.polygon([
(cx, m + size // 6),
(m, m),
(m, size - m),
(cx, size - m - size // 6),
], fill=(233, 69, 96))
# Right page
draw.polygon([
(cx, m + size // 6),
(size - m, m),
(size - m, size - m),
(cx, size - m - size // 6),
], fill=(200, 50, 80))
# Spine line
draw.line([(cx, m + size // 6), (cx, size - m - size // 6)], fill=(26, 26, 46), width=max(2, size // 64))
# Page lines on left
for i in range(4):
y = m + size // 4 + i * (size // 8)
draw.line([(m + size // 6, y), (cx - size // 10, y)], fill=(26, 26, 46), width=max(1, size // 128))
img.save(path)
make_icon(192, "static/icon-192.png")
make_icon(512, "static/icon-512.png")
print("Icons generated.")