v0.87.1: one app icon (lint.jpg, wave's corner radius) on desktop and andTunes 0.4.2; quitting no longer segfaults
The swap-a-PNG icon is gone: scripts/make_icons.py renders packaging/lint.jpg into packaging/lintunes.png and the andTunes launcher. Quitting ends with os._exit once aboutToQuit has saved everything — Python's teardown of the QApplication wrapper segfaulted on every quit.
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Make LinTunes' one app icon from packaging/lint.jpg: the picture squared
|
||||
from its centre with its corners rounded at wave's radius (16 % of the
|
||||
side), as packaging/lintunes.png (desktop, 512 px) and andTunes' launcher
|
||||
(andtunes/app/src/main/res/drawable-nodpi/ic_launcher.png, 192 px) — the
|
||||
same icon on both. Re-run after changing lint.jpg; the outputs are
|
||||
committed, and the APK needs `andtunes/build.py --ship` to carry it."""
|
||||
from pathlib import Path
|
||||
|
||||
from PIL import Image, ImageDraw
|
||||
|
||||
HERE = Path(__file__).resolve().parent.parent
|
||||
SOURCE = HERE / "packaging" / "lint.jpg"
|
||||
CORNER = 0.16 # corner radius, as a fraction of the side
|
||||
DESKTOP = HERE / "packaging" / "lintunes.png"
|
||||
ANDROID = (HERE / "andtunes" / "app" / "src" / "main" / "res"
|
||||
/ "drawable-nodpi" / "ic_launcher.png")
|
||||
|
||||
|
||||
def rounded(img: Image.Image, size: int) -> Image.Image:
|
||||
img = img.convert("RGB").resize((size, size), Image.LANCZOS)
|
||||
# Drawn at 4x and shrunk, so the corners are smooth rather than stepped.
|
||||
big = size * 4
|
||||
mask = Image.new("L", (big, big), 0)
|
||||
ImageDraw.Draw(mask).rounded_rectangle(
|
||||
(0, 0, big - 1, big - 1), radius=big * CORNER, fill=255)
|
||||
out = img.convert("RGBA")
|
||||
out.putalpha(mask.resize((size, size), Image.LANCZOS))
|
||||
return out
|
||||
|
||||
|
||||
def main() -> None:
|
||||
src = Image.open(SOURCE)
|
||||
side = min(src.size) # square it up from the centre
|
||||
left, top = (src.width - side) // 2, (src.height - side) // 2
|
||||
src = src.crop((left, top, left + side, top + side))
|
||||
rounded(src, 512).save(DESKTOP)
|
||||
rounded(src, 192).save(ANDROID)
|
||||
print(f"Wrote {DESKTOP.relative_to(HERE)} and {ANDROID.relative_to(HERE)}.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user