Files
podlite/tools/make_icons.py
T
xockoandClaude Opus 5.5 275bee3c11 MiniABS 1.2: Galician interface, larger text and touch targets
- Translate the interface to Galician (tools/translate_gl.py), including
  Galician month abbreviations for dates, which Android 2.3 lacks
- Resize for the Galaxy Mini's 240x320 screen: larger text, rows, tabs and
  buttons; all sizes now live in res/values/dimens.xml
- Redraw play/pause/refresh icons for every density; slightly brighter
  secondary text colours

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 21:29:17 +02:00

97 lines
3.0 KiB
Python

"""Draws MiniABS's PNG icons for ldpi (Galaxy Mini), mdpi and hdpi.
Android 2.x has no vector drawables, so every icon is rendered here at 4x and
downsampled for smooth edges.
"""
import os
import sys
from PIL import Image, ImageDraw
RES = sys.argv[1]
DENS = {"ldpi": 0.75, "mdpi": 1.0, "hdpi": 1.5}
AMBER = (245, 166, 35, 255)
DARK = (18, 21, 25, 255)
WHITE = (255, 255, 255, 255)
SS = 4 # supersampling
def canvas(px):
s = px * SS
return Image.new("RGBA", (s, s), (0, 0, 0, 0)), s
def save(img, px, folder, name):
out = img.resize((px, px), Image.LANCZOS)
d = os.path.join(RES, "drawable-" + folder)
os.makedirs(d, exist_ok=True)
out.save(os.path.join(d, name + ".png"))
def broadcast(d, s, cx, cy, scale, color, bg):
"""Podcast mark: a dot with two arcs on each side."""
r = s * 0.075 * scale
d.ellipse([cx - r, cy - r, cx + r, cy + r], fill=color)
w = max(1, int(s * 0.07 * scale))
for k in (0.22, 0.37):
rr = s * k * scale
box = [cx - rr, cy - rr, cx + rr, cy + rr]
d.arc(box, 140, 220, fill=color, width=w)
d.arc(box, -40, 40, fill=color, width=w)
def launcher(px, folder):
img, s = canvas(px)
d = ImageDraw.Draw(img)
m = s * 0.06
d.rounded_rectangle([m, m, s - m, s - m], radius=s * 0.2, fill=DARK, outline=AMBER, width=int(s * 0.04))
broadcast(d, s, s / 2, s * 0.44, 1.0, AMBER, DARK)
# little stand under the mark
w = s * 0.05
d.rectangle([s / 2 - w / 2, s * 0.5, s / 2 + w / 2, s * 0.74], fill=AMBER)
d.rounded_rectangle([s * 0.36, s * 0.72, s * 0.64, s * 0.78], radius=w / 2, fill=AMBER)
save(img, px, folder, "ic_launcher")
def status(px, folder):
img, s = canvas(px)
d = ImageDraw.Draw(img)
broadcast(d, s, s / 2, s / 2, 1.25, WHITE, None)
save(img, px, folder, "ic_stat")
def play(px, folder, name, color):
img, s = canvas(px)
d = ImageDraw.Draw(img)
d.polygon([(s * 0.32, s * 0.2), (s * 0.32, s * 0.8), (s * 0.82, s * 0.5)], fill=color)
save(img, px, folder, name)
def pause(px, folder, name, color):
img, s = canvas(px)
d = ImageDraw.Draw(img)
d.rectangle([s * 0.26, s * 0.2, s * 0.43, s * 0.8], fill=color)
d.rectangle([s * 0.57, s * 0.2, s * 0.74, s * 0.8], fill=color)
save(img, px, folder, name)
def refresh(px, folder):
img, s = canvas(px)
d = ImageDraw.Draw(img)
w = int(s * 0.1)
box = [s * 0.2, s * 0.2, s * 0.8, s * 0.8]
d.arc(box, 30, 320, fill=WHITE, width=w)
# arrow head at the arc's end (top right)
d.polygon([(s * 0.86, s * 0.14), (s * 0.88, s * 0.48), (s * 0.56, s * 0.36)], fill=WHITE)
save(img, px, folder, "ic_refresh")
for folder, k in DENS.items():
launcher(round(48 * k), folder)
status(round(25 * k), folder)
play(round(48 * k), folder, "ic_play", DARK)
pause(round(48 * k), folder, "ic_pause", DARK)
play(round(38 * k), folder, "ic_play_small", AMBER)
pause(round(38 * k), folder, "ic_pause_small", AMBER)
refresh(round(30 * k), folder)
print("icons ok")