from PIL import Image, ImageDraw
sizes = [16, 32, 48, 64, 128, 256]
imgs = []
for sz in sizes:
    img = Image.new('RGBA', (sz, sz), (0, 0, 0, 0))
    d = ImageDraw.Draw(img)
    d.rounded_rectangle([0, 0, sz-1, sz-1], radius=int(sz*.18), fill=(59, 110, 220, 255))
    bars = [.25, .45, .7, .9, .65, 1., .55, .8, .4, .2]
    n, mg = len(bars), sz*.13
    bw = (sz - 2*mg) / (n * 1.7)
    gap = (sz - 2*mg) / n
    mid = sz / 2
    for i, h in enumerate(bars):
        x = mg + i*gap + (gap - bw) / 2
        bh = h * sz * .36
        d.rounded_rectangle([x, mid-bh, x+bw, mid+bh], radius=bw/2, fill=(255, 255, 255, 215))
    imgs.append(img)
imgs[-1].save('icon.png')
imgs[0].save('icon.ico', format='ICO', sizes=[(s,s) for s in sizes], append_images=imgs[1:])
print('[OK] Icones generees')
