Something went wrong. Try again.
Your thinking partner.
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152#!/usr/bin/env python3"""Regenerate Co's icon, adaptive foreground, and splash wordmark.
Run from the repository root after dependencies are installed:
uv run --with pillow scripts/make-icons.py"""
from pathlib import Path
from PIL import Image, ImageDraw, ImageFont
ROOT = Path(__file__).resolve().parent.parentOUTPUT = ROOT / "assets" / "images"FONT = ROOT / "assets" / "fonts" / "Around-Regular.ttf"CHARCOAL = (10, 10, 10)PAPER = (255, 255, 255)
def wordmark(size: int, canvas: int, color: tuple[int, int, int, int]) -> Image.Image: image = Image.new("RGBA", (canvas, canvas), (0, 0, 0, 0)) draw = ImageDraw.Draw(image) font = ImageFont.truetype(str(FONT), size) bounds = draw.textbbox((0, 0), "co", font=font, stroke_width=0) width = bounds[2] - bounds[0] height = bounds[3] - bounds[1] draw.text( ((canvas - width) / 2 - bounds[0], (canvas - height) / 2 - bounds[1]), "CO", font=font, fill=color, ) return image
def main() -> None: if not FONT.exists(): raise SystemExit(f"Missing {FONT.relative_to(ROOT)}; run `bun install` first.")
icon = Image.new("RGBA", (1024, 1024), CHARCOAL + (255,)) icon.alpha_composite(wordmark(430, 1024, PAPER + (255,))) icon.convert("RGB").save(OUTPUT / "icon.png")
wordmark(380, 1024, PAPER + (255,)).save(OUTPUT / "icon-foreground.png") wordmark(220, 512, PAPER + (255,)).save(OUTPUT / "splash-icon.png") print("wrote assets/images/{icon,icon-foreground,splash-icon}.png")
if __name__ == "__main__": main()