Private
Public Access
54 lines
1.9 KiB
Python
54 lines
1.9 KiB
Python
"""Draws the launcher and status-bar icons at ldpi/mdpi/hdpi (supersampled for smooth edges)."""
|
|
import os
|
|
import sys
|
|
|
|
from PIL import Image, ImageDraw
|
|
|
|
RES = sys.argv[1]
|
|
BG = (24, 24, 29, 255)
|
|
ACCENT = (247, 176, 46, 255)
|
|
DARK = (22, 19, 12, 255)
|
|
|
|
|
|
def launcher(size):
|
|
S = size * 8
|
|
im = Image.new("RGBA", (S, S), (0, 0, 0, 0))
|
|
d = ImageDraw.Draw(im)
|
|
pad = S * 0.06
|
|
d.rounded_rectangle([pad, pad, S - pad, S - pad], radius=S * 0.22, fill=BG)
|
|
# amber disc with a ring groove and a play notch: a record that is also a play button
|
|
c = S * 0.46
|
|
r = S * 0.29
|
|
d.ellipse([c - r, c - r, c + r, c + r], fill=ACCENT)
|
|
rr = r * 0.72
|
|
w = max(2, int(S * 0.018))
|
|
d.ellipse([c - rr, c - rr, c + rr, c + rr], outline=DARK, width=w)
|
|
t = r * 0.42
|
|
d.polygon([(c - t * 0.55, c - t), (c + t * 0.95, c), (c - t * 0.55, c + t)], fill=DARK)
|
|
# three level bars, lower right
|
|
bw = S * 0.045
|
|
for i, h in enumerate((0.10, 0.17, 0.13)):
|
|
x = S * 0.72 + i * bw * 1.6
|
|
d.rounded_rectangle([x, S * 0.82 - S * h, x + bw, S * 0.82], radius=bw / 2, fill=ACCENT)
|
|
return im.resize((size, size), Image.LANCZOS)
|
|
|
|
|
|
def status(size):
|
|
S = size * 8
|
|
im = Image.new("RGBA", (S, S), (0, 0, 0, 0))
|
|
d = ImageDraw.Draw(im)
|
|
c = S / 2
|
|
r = S * 0.44
|
|
d.ellipse([c - r, c - r, c + r, c + r], fill=ACCENT)
|
|
t = r * 0.45
|
|
d.polygon([(c - t * 0.55, c - t), (c + t * 0.95, c), (c - t * 0.55, c + t)], fill=(0, 0, 0, 0))
|
|
return im.resize((size, size), Image.LANCZOS)
|
|
|
|
|
|
for folder, ls, ss in (("drawable-ldpi", 36, 19), ("drawable-mdpi", 48, 25), ("drawable-hdpi", 72, 38)):
|
|
os.makedirs(os.path.join(RES, folder), exist_ok=True)
|
|
launcher(ls).save(os.path.join(RES, folder, "ic_launcher.png"))
|
|
status(ss).save(os.path.join(RES, folder, "ic_stat.png"))
|
|
launcher(192).save(os.path.join(os.path.dirname(RES.rstrip("/")), "icon-preview.png"))
|
|
print("icons written")
|