Files

30 lines
1.1 KiB
Python
Raw Permalink Normal View History

import sys
from PIL import Image, ImageDraw, ImageFont
out = sys.argv[1]
S = 1024
# background: rounded square, calm vertical gradient (no gloss)
grad = Image.new("RGBA", (S, S))
top, bot = (112, 112, 236), (78, 78, 206)
gd = ImageDraw.Draw(grad)
for y in range(S):
t = y / (S - 1)
gd.line([(0, y), (S, y)], fill=tuple(int(top[i] + (bot[i] - top[i]) * t) for i in range(3)) + (255,))
mask = Image.new("L", (S, S), 0)
m = 56
ImageDraw.Draw(mask).rounded_rectangle([m, m, S - m, S - m], radius=int(S * 0.21), fill=255)
img = Image.new("RGBA", (S, S), (0, 0, 0, 0))
img.paste(grad, (0, 0), mask)
# solid bell: render outline glyph, flood-fill the outside, everything else = bell
font = ImageFont.truetype(r"C:\Windows\Fonts\SegoeIcons.ttf", 520)
g = Image.new("L", (S, S), 0)
gdraw = ImageDraw.Draw(g)
bbox = gdraw.textbbox((0, 0), "\uEA8F", font=font)
w, h = bbox[2] - bbox[0], bbox[3] - bbox[1]
gdraw.text(((S - w) / 2 - bbox[0], (S - h) / 2 - bbox[1] + 6), "\uEA8F", font=font, fill=255)
ImageDraw.floodfill(g, (2, 2), 128)
solid = g.point(lambda v: 0 if v == 128 else 255)
img.paste(Image.new("RGBA", (S, S), (255, 255, 255, 255)), (0, 0), solid)
img.save(out)