Windows showed the default executable icon, and the tray drew a plain "T" at run time. A usage gauge in the provider colours now serves all three (D8). tools/icon/make_icon.py renders it with Pillow, a development-only dependency, into a multi-size ICO for Windows and a PNG for X11. Its test checks every size and that a fresh run reproduces the committed files. Refs #17
68 lines
2.3 KiB
Python
68 lines
2.3 KiB
Python
#!/usr/bin/env python3
|
|
"""D8: render the shared usage gauge. Requires development-only Pillow 11.3.0."""
|
|
import argparse
|
|
from pathlib import Path
|
|
|
|
from PIL import Image, ImageDraw
|
|
|
|
SIZES = (16, 20, 24, 32, 40, 48, 64, 128, 256)
|
|
ASSETS = Path(__file__).resolve().parents[2] / 'src' / 'FinalToken.App' / 'Assets'
|
|
|
|
|
|
def render(size):
|
|
scale = size * 8
|
|
image = Image.new('RGBA', (scale, scale))
|
|
draw = ImageDraw.Draw(image)
|
|
|
|
def box(a, b, c, d):
|
|
return tuple(round(n * scale) for n in (a, b, c, d))
|
|
|
|
draw.rounded_rectangle(box(.025, .025, .975, .975), radius=round(.20 * scale),
|
|
fill='#1a1a19', outline='#52514e', width=round(.025 * scale))
|
|
gauge = box(.17, .17, .83, .83)
|
|
width = round(.115 * scale)
|
|
draw.arc(gauge, 135, 405, fill='#383835', width=width)
|
|
draw.arc(gauge, 135, 265, fill='#d95926', width=width)
|
|
draw.arc(gauge, 267, 353, fill='#3987e5', width=width)
|
|
# One chunky pointer survives the 16 px downsample; there are no small-size hairlines.
|
|
draw.line(box(.50, .53, .64, .37), fill='#f0efec', width=round(.075 * scale))
|
|
draw.ellipse(box(.445, .475, .555, .585), fill='#f0efec')
|
|
return image.resize((size, size), Image.Resampling.LANCZOS)
|
|
|
|
|
|
def write_assets(output):
|
|
output.mkdir(parents=True, exist_ok=True)
|
|
images = [render(size) for size in SIZES]
|
|
images[-1].save(output / 'FinalToken.ico', sizes=[(s, s) for s in SIZES], append_images=images[:-1])
|
|
images[-1].save(output / 'FinalToken.png')
|
|
|
|
|
|
def contact_sheet(path):
|
|
sizes = (16, 24, 32, 48, 256)
|
|
sheet = Image.new('RGB', (512, 640))
|
|
draw = ImageDraw.Draw(sheet)
|
|
for column, background in enumerate(('#f9f9f7', '#0d0d0d')):
|
|
left = column * 256
|
|
draw.rectangle((left, 0, left + 255, 639), fill=background)
|
|
y = 24
|
|
for size in sizes:
|
|
icon = render(size)
|
|
sheet.paste(icon, (left + (256 - size) // 2, y), icon)
|
|
y += size + 32
|
|
path.parent.mkdir(parents=True, exist_ok=True)
|
|
sheet.save(path)
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument('--out', type=Path, default=ASSETS)
|
|
parser.add_argument('--contact-sheet', type=Path)
|
|
args = parser.parse_args()
|
|
write_assets(args.out)
|
|
if args.contact_sheet:
|
|
contact_sheet(args.contact_sheet)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|