Neues App-Icon: LK-Monogramm in Schwarz-Weiß

- Icon aus Geometrie gezeichnet (keine Schriften nötig), Form wie Apples macOS-Vorlage mit
  kontinuierlichen Ecken, feine Innenkante, entrauschter Verlauf
- Optische Größen: 32/64/128 px mit kräftigeren Strichen, damit das Monogramm im Dock lesbar bleibt
- Varianten monogramm (Standard), hell, kasten, serif; --preview zeigt alle nebeneinander
- install.sh aktualisiert Finder/Dock-Icon-Cache, wenn sich das Icon geändert hat

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012bGzgsxrmbBhDzeMV2L57D
This commit is contained in:
Lichtkasten DevandClaude Opus 5.5 committed 2026-11-05 00:38:44 +00:00
1 parent 93ecdf03fc
commit f18f1bd9a9
7 files changed
+367 -94

No files matched your search

+1
View File
@@ -4,3 +4,4 @@ build/
*.xcodeproj/xcuserdata/ *.xcodeproj/xcuserdata/
DerivedData/ DerivedData/
.DS_Store .DS_Store
__pycache__/
+3 -1
View File
@@ -114,7 +114,9 @@ Alle Häkchen lassen sich im Vorlagen-Editor (⌘⇧T) pro Feld ändern.
- Ingest wie in PM: Karten-Liste, inkrementell, gesperrte/RAW-Filter, Umbenennen mit fortlaufender Sequenz, - Ingest wie in PM: Karten-Liste, inkrementell, gesperrte/RAW-Filter, Umbenennen mit fortlaufender Sequenz,
Vorlage, Kontaktabzug während des Ingests, Karte auswerfen. In der Kamera gesperrte Fotos werden auf Wunsch getaggt. Vorlage, Kontaktabzug während des Ingests, Karte auswerfen. In der Kamera gesperrte Fotos werden auf Wunsch getaggt.
App-Icon: `scripts/make-icon.py` erzeugt `Resources/AppIcon.icns`. App-Icon: `python3 scripts/make-icon.py` erzeugt `Resources/AppIcon.icns` (LK-Monogramm, schwarz-weiß).
Weitere Varianten: `hell`, `kasten`, `serif`, z. B. `python3 scripts/make-icon.py kasten`.
`python3 scripts/make-icon.py --preview vorschau.png` zeigt alle nebeneinander.
## Trikotnummern-Erkennung (Trikot + Hose) ## Trikotnummern-Erkennung (Trikot + Hose)
Binary file not shown.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 234 KiB

After

Width:  |  Height:  |  Size: 195 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 17 KiB

+10
View File
@@ -13,7 +13,17 @@ if pgrep -x Lichtkasten >/dev/null; then
for _ in {1..20}; do pgrep -x Lichtkasten >/dev/null || break; sleep 0.5; done for _ in {1..20}; do pgrep -x Lichtkasten >/dev/null || break; sleep 0.5; done
fi fi
ICON_CHANGED=0
cmp -s build/Lichtkasten.app/Contents/Resources/AppIcon.icns \
/Applications/Lichtkasten.app/Contents/Resources/AppIcon.icns 2>/dev/null || ICON_CHANGED=1
rm -rf /Applications/Lichtkasten.app rm -rf /Applications/Lichtkasten.app
cp -R build/Lichtkasten.app /Applications/ cp -R build/Lichtkasten.app /Applications/
echo "✅ Installiert: /Applications/Lichtkasten.app" echo "✅ Installiert: /Applications/Lichtkasten.app"
# neues Icon gleich in Finder und Dock zeigen (macOS hält Icons sonst im Cache)
touch /Applications/Lichtkasten.app
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister \
-f /Applications/Lichtkasten.app >/dev/null 2>&1 || true
if [ "$ICON_CHANGED" = 1 ]; then killall Dock 2>/dev/null || true; fi
open /Applications/Lichtkasten.app open /Applications/Lichtkasten.app
+353 -93
View File
@@ -1,101 +1,361 @@
from PIL import Image, ImageDraw, ImageFilter, ImageChops #!/usr/bin/env python3
"""Lichtkasten app icon: black and white LK monogram, drawn from geometry (no fonts needed).
python3 scripts/make-icon.py # default variant → Resources/AppIcon.icns + PNGs
python3 scripts/make-icon.py kasten # another variant (see VARIANTS)
python3 scripts/make-icon.py --preview x.png # comparison sheet of all variants
Needs Pillow and numpy. Layout follows Apple's macOS icon template: 1024 grid, 824 body, 100 margin.
"""
import math import math
S=2048 # supersampled import sys
def lerp(a,b,t): return tuple(int(a[i]+(b[i]-a[i])*t) for i in range(len(a))) from functools import lru_cache
def vgrad(w,h,top,bot): from pathlib import Path
g=Image.new('RGBA',(w,h))
d=ImageDraw.Draw(g)
for y in range(h):
d.line([(0,y),(w,y)],fill=lerp(top,bot,y/(h-1)))
return g
def squircle_mask(size, box, n=5.0):
m=Image.new('L',(size,size),0); d=ImageDraw.Draw(m)
x0,y0,x1,y1=box; cx=(x0+x1)/2; cy=(y0+y1)/2; a=(x1-x0)/2; b=(y1-y0)/2
pts=[]
for i in range(720):
t=2*math.pi*i/720; c=math.cos(t); s=math.sin(t)
pts.append((cx+a*math.copysign(abs(c)**(2/n),c), cy+b*math.copysign(abs(s)**(2/n),s)))
d.polygon(pts,fill=255); return m
def rrect_mask(size,box,r):
m=Image.new('L',size,0); ImageDraw.Draw(m).rounded_rectangle(box,radius=r,fill=255); return m
img=Image.new('RGBA',(S,S),(0,0,0,0)) import numpy as np
pad=int(S*0.098); box=(pad,pad,S-pad,S-pad) from PIL import Image, ImageChops, ImageDraw, ImageFilter
# drop shadow of body
sh=Image.new('RGBA',(S,S),(0,0,0,0)); shm=squircle_mask(S,(box[0],box[1]+30,box[2],box[3]+30))
sh.putalpha(shm.point(lambda v:int(v*0.45))); sh=sh.filter(ImageFilter.GaussianBlur(40)); img=Image.alpha_composite(img,sh)
# body: deep graphite → midnight blue
body=vgrad(S,S,(52,58,72,255),(16,19,28,255)); bm=squircle_mask(S,box)
layer=Image.new('RGBA',(S,S),(0,0,0,0)); layer.paste(body,(0,0),bm); img=Image.alpha_composite(img,layer)
# light table panel (glowing) ROOT = Path(__file__).resolve().parent.parent
pw,ph=int(S*0.60),int(S*0.46); px=(S-pw)//2; py=int(S*0.30) GRID = 1024
glow=Image.new('RGBA',(S,S),(0,0,0,0)); gd=ImageDraw.Draw(glow) BODY = (100, 100, 924, 924)
gd.rounded_rectangle((px-60,py-60,px+pw+60,py+ph+60),radius=120,fill=(255,214,140,170)) SS = 4 # supersampling for clean edges
glow=glow.filter(ImageFilter.GaussianBlur(90)); glow.putalpha(ImageChops.multiply(glow.getchannel('A'),bm)) DEFAULT = "monogramm"
img=Image.alpha_composite(img,glow)
panel=vgrad(pw,ph,(255,250,236,255),(255,226,170,255))
pm=rrect_mask((pw,ph),(0,0,pw-1,ph-1),70)
img.paste(panel,(px,py),pm)
# subtle grid lines on the light table
grid=Image.new('RGBA',(S,S),(0,0,0,0)); gdd=ImageDraw.Draw(grid)
for i in range(1,6):
x=px+pw*i//6; gdd.line([(x,py+20),(x,py+ph-20)],fill=(210,160,90,60),width=4)
for j in range(1,4):
y=py+ph*j//4; gdd.line([(px+20,y),(px+pw-20,y)],fill=(210,160,90,60),width=4)
img=Image.alpha_composite(img,grid)
def slide(cx,cy,w,angle,photo): # ---------------------------------------------------------------- geometry (design units, y down)
s=Image.new('RGBA',(w,w),(0,0,0,0)); d=ImageDraw.Draw(s)
d.rounded_rectangle((0,0,w-1,w-1),radius=int(w*0.09),fill=(250,250,246,255))
iw,ih=int(w*0.66),int(w*0.46); ix=(w-iw)//2; iy=int(w*0.20)
ph=photo(iw,ih); s.paste(ph,(ix,iy),rrect_mask((iw,ih),(0,0,iw-1,ih-1),10))
# label strip
d.rounded_rectangle((ix,iy+ih+int(w*0.07),ix+int(iw*0.55),iy+ih+int(w*0.11)),radius=8,fill=(200,200,195,255))
s=s.rotate(angle,resample=Image.BICUBIC,expand=True)
shadow=Image.new('RGBA',s.size,(0,0,0,0)); shadow.putalpha(s.getchannel('A').point(lambda v:int(v*0.35)))
shadow=shadow.filter(ImageFilter.GaussianBlur(22))
return s,shadow
def photo_stadium(w,h):
p=vgrad(w,h,(24,70,140,255),(255,150,70,255)); d=ImageDraw.Draw(p)
d.rectangle((0,int(h*0.68),w,h),fill=(28,120,70,255)) # pitch
for k in range(5): d.line([(int(w*k/4),int(h*0.68)),(int(w*(k/4-0.1)),h)],fill=(40,140,85,255),width=5)
d.ellipse((int(w*0.62),int(h*0.15),int(w*0.80),int(h*0.15)+int(w*0.18)),fill=(255,236,190,255)) # floodlight/sun
return p
def photo_mountain(w,h):
p=vgrad(w,h,(120,170,220,255),(230,235,240,255)); d=ImageDraw.Draw(p)
d.polygon([(0,h),(int(w*0.35),int(h*0.35)),(int(w*0.6),int(h*0.75)),(int(w*0.78),int(h*0.45)),(w,h)],fill=(52,70,95,255))
return p
for (cx,cy,w,ang,ph) in [(int(S*0.40),int(S*0.53),int(S*0.30),8,photo_mountain),(int(S*0.60),int(S*0.52),int(S*0.33),-6,photo_stadium)]: def rect(x0, y0, x1, y1):
s,shadow=slide(cx,cy,w,ang,ph) return [(x0, y0), (x1, y0), (x1, y1), (x0, y1)]
ox,oy=cx-s.size[0]//2,cy-s.size[1]//2
img.alpha_composite(shadow,(ox+14,oy+26)); img.alpha_composite(s,(ox,oy))
# loupe
L=Image.new('RGBA',(S,S),(0,0,0,0)); ld=ImageDraw.Draw(L)
lcx,lcy,lr=int(S*0.64),int(S*0.62),int(S*0.105)
ld.line([(lcx+int(lr*0.72),lcy+int(lr*0.72)),(lcx+int(lr*1.32),lcy+int(lr*1.32))],fill=(30,32,40,255),width=int(S*0.045))
ld.ellipse((lcx-lr,lcy-lr,lcx+lr,lcy+lr),outline=(30,32,40,255),width=int(S*0.028))
ld.ellipse((lcx-lr+30,lcy-lr+30,lcx+lr-30,lcy+lr-30),fill=(200,225,255,70))
ld.arc((lcx-lr+70,lcy-lr+70,lcx+lr-70,lcy+lr-70),200,250,fill=(255,255,255,200),width=18)
lsh=Image.new('RGBA',(S,S),(0,0,0,0)); lsh.putalpha(L.getchannel('A').point(lambda v:int(v*0.4))); lsh=lsh.filter(ImageFilter.GaussianBlur(20))
img.alpha_composite(lsh,(10,22)); img=Image.alpha_composite(img,L)
# PM-style tag check (accent) bottom-left of panel def _hit(p, d, q, e):
T=Image.new('RGBA',(S,S),(0,0,0,0)); td=ImageDraw.Draw(T) """Intersection of the lines p + t·d and q + s·e."""
tx,ty,ts=int(S*0.235),int(S*0.645),int(S*0.12) det = d[0] * e[1] - d[1] * e[0]
td.rounded_rectangle((tx,ty,tx+ts,ty+ts),radius=int(ts*0.22),fill=(232,64,52,255)) t = ((q[0] - p[0]) * e[1] - (q[1] - p[1]) * e[0]) / det
td.line([(tx+ts*0.24,ty+ts*0.53),(tx+ts*0.43,ty+ts*0.72),(tx+ts*0.78,ty+ts*0.30)],fill=(255,255,255,255),width=int(ts*0.13),joint='curve') return (p[0] + t * d[0], p[1] + t * d[1])
tsh=Image.new('RGBA',(S,S),(0,0,0,0)); tsh.putalpha(T.getchannel('A').point(lambda v:int(v*0.35))); tsh=tsh.filter(ImageFilter.GaussianBlur(16))
img.alpha_composite(tsh,(8,18)); img=Image.alpha_composite(img,T)
# soft top sheen
shm2=Image.new('L',(S,S),0); ImageDraw.Draw(shm2).ellipse((-S*0.3,-S*0.75,S*1.3,S*0.42),fill=70) def hcut(y):
shm2=ImageChops.multiply(shm2.filter(ImageFilter.GaussianBlur(120)),squircle_mask(S,box)) return ((0.0, y), (1.0, 0.0))
sl=Image.new('RGBA',(S,S),(255,255,255,0)); sl.putalpha(shm2); img=Image.alpha_composite(img,sl)
out=img.resize((1024,1024),Image.LANCZOS)
out.save('/home/user/Lichtkasten/Resources/Icon/AppIcon-1024.png') def vcut(x):
out.save('/home/user/Lichtkasten/Resources/AppIcon.icns', sizes=[(16,16),(32,32),(64,64),(128,128),(256,256),(512,512),(1024,1024)]) return ((x, 0.0), (0.0, 1.0))
out.resize((256,256),Image.LANCZOS).save('/home/user/Lichtkasten/Resources/Icon/AppIcon-256.png')
print('ok')
def along(p0, p1):
return (p0, (p1[0] - p0[0], p1[1] - p0[1]))
def band(p0, p1, w, cut0, cut1):
"""Straight stroke of width w on the centre line p0→p1, ends cut by the lines cut0 / cut1."""
dx, dy = p1[0] - p0[0], p1[1] - p0[1]
n = math.hypot(dx, dy)
ox, oy = -dy / n * w / 2, dx / n * w / 2
a, b = (p0[0] + ox, p0[1] + oy), (p0[0] - ox, p0[1] - oy)
d = (dx, dy)
return [_hit(a, d, *cut0), _hit(b, d, *cut0), _hit(b, d, *cut1), _hit(a, d, *cut1)]
def point_on(p0, p1, t):
return (p0[0] + (p1[0] - p0[0]) * t, p0[1] + (p1[1] - p0[1]) * t)
# Apple's continuous corner (as UIKit draws it): one corner from the edge point 1.5287·r away,
# local coordinates (u = distance from the vertical edge, v = from the horizontal edge), in units of r.
_CORNER = [
((1.52866483, 0.0), (1.08849323, 0.0), (0.86840689, 0.0), (0.66993427, 0.06549600)),
((0.66993427, 0.06549600), None, None, (0.63149399, 0.07491100)),
((0.63149399, 0.07491100), (0.37282392, 0.16905899), (0.16906013, 0.37282401), (0.07491176, 0.63149399)),
((0.07491176, 0.63149399), None, None, (0.06549569, 0.66993493)),
((0.06549569, 0.66993493), (0.0, 0.86840701), (0.0, 1.08849299), (0.0, 1.52866483)),
]
def _corner_points(steps=48):
pts = []
for p0, c1, c2, p3 in _CORNER:
if c1 is None:
pts.append(p3)
continue
for i in range(1, steps + 1):
t = i / steps
a, b, c, d = (1 - t) ** 3, 3 * (1 - t) ** 2 * t, 3 * (1 - t) * t * t, t ** 3
pts.append((a * p0[0] + b * c1[0] + c * c2[0] + d * p3[0], a * p0[1] + b * c1[1] + c * c2[1] + d * p3[1]))
return [_CORNER[0][0]] + pts
def squircle(box, radius=None):
"""macOS app icon shape: rounded rectangle with continuous corners (r = 185.4 on the 824 body)."""
x0, y0, x1, y1 = box
r = radius if radius is not None else (x1 - x0) * 185.4 / 824
local = _corner_points()
maps = [
lambda u, v: (x1 - u * r, y0 + v * r), # top right
lambda u, v: (x1 - v * r, y1 - u * r), # bottom right
lambda u, v: (x0 + u * r, y1 - v * r), # bottom left
lambda u, v: (x0 + v * r, y0 + u * r), # top left
]
return [f(u, v) for f in maps for u, v in local]
def bbox(polys):
xs = [x for p in polys for x, _ in p]
ys = [y for p in polys for _, y in p]
return min(xs), min(ys), max(xs), max(ys)
def centred(polys, cx, cy):
x0, y0, x1, y1 = bbox(polys)
dx, dy = cx - (x0 + x1) / 2, cy - (y0 + y1) / 2
return [[(x + dx, y + dy) for x, y in p] for p in polys]
# ---------------------------------------------------------------- letters
def k_parts(xk, top, base, w, reach, arm_w=None, leg_w=None, junction=0.64, branch=0.36, leg_reach=None):
"""Geometric K: stem at xk, arm to the cap height, leg springing from the arm down to `base`."""
arm_w = arm_w or w * 0.94
leg_w = leg_w or w
sc = xk + w / 2
h = base - top
arm_end = (xk + reach, top)
joint = (sc, top + junction * h)
leg_start = point_on(joint, arm_end, branch)
leg_end = (xk + (leg_reach if leg_reach is not None else reach * 1.06), base)
return [
rect(xk, top, xk + w, base),
band(joint, arm_end, arm_w, vcut(sc), hcut(top)),
band(leg_start, leg_end, leg_w, along(joint, arm_end), hcut(base)),
]
def lk_ligature(cx, cy, cap=330, w=30.0, bold=1.0):
"""L and K sharing the baseline: the K stands on the L's foot, the foot runs out into the K's leg."""
w *= bold
wf = w * 0.92 # horizontals a touch lighter (optical)
top, base = 0.0, cap
xk = w + 0.25 * cap # inner space between the two stems: a quarter of the cap height
k = k_parts(xk, top, base, w, reach=0.60 * cap, junction=0.63)
leg = k[2]
inner_bottom = min(x for x, y in leg if abs(y - base) < 1e-6)
outer_bottom = max(x for x, y in leg if abs(y - base) < 1e-6)
# foot ends inside the leg, so the outline runs from the baseline straight into the leg's outer edge
rise = wf * (outer_bottom - inner_bottom) / (base - min(y for _, y in leg))
foot = rect(0, base - wf, (inner_bottom + outer_bottom - rise) / 2, base)
polys = [rect(0, top, w, base), foot] + k
return centred(polys, cx, cy)
def lk_pair(cx, cy, cap=250, w=20.0, bold=1.0):
"""L and K as two letters (for the framed variant)."""
w *= bold
wf = w * 0.92
foot_len = 0.50 * cap
l = [rect(0, 0, w, cap), rect(0, cap - wf, foot_len, cap)]
xk = foot_len + 0.16 * cap
k = k_parts(xk, 0, cap, w, reach=0.56 * cap, junction=0.62)
return centred(l + k, cx, cy)
def lk_serif(cx, cy, cap=260, bold=1.0):
"""High-contrast (Didone) L and K: heavy stems, hairline serifs and arm."""
ws, wh = 46 * bold, 7.5 * bold ** 1.6 # stem, hairline
e = 0.105 * cap # serif reach beside a stem
sh = wh * 1.15 # serif thickness
top, base = 0.0, cap
polys = []
# L
foot_end = ws + 0.47 * cap
beak = 0.22 * cap
polys += [
rect(0, top, ws, base),
rect(-e, top, ws + e, top + sh), # top serif
rect(-e, base - wh * 1.5, foot_end, base), # foot (a bit heavier than a hairline)
[(foot_end - wh * 3.0, base - wh * 1.5), (foot_end - wh * 1.0, base - beak),
(foot_end, base - beak), (foot_end, base)], # beak: wedge rising from the foot
]
# K
xk = foot_end + 0.20 * cap
sc = xk + ws / 2
arm_end = (xk + 0.58 * cap, top + sh)
joint = (sc, top + 0.60 * cap)
leg_start = point_on(joint, arm_end, 0.40)
leg_end = (xk + 0.64 * cap, base - sh * 0.5)
leg = band(leg_start, leg_end, ws * 0.92, along(joint, arm_end), hcut(base - sh * 0.5))
polys += [
rect(xk, top, xk + ws, base),
rect(xk - e, top, xk + ws + e, top + sh),
rect(xk - e, base - sh, xk + ws + e, base),
band(joint, arm_end, wh * 1.7, vcut(sc), hcut(top + sh)),
rect(arm_end[0] - e * 1.25, top, arm_end[0] + e * 0.85, top + sh), # arm serif
leg,
]
low = [x for x, y in leg if y > base - sh]
polys.append(rect(min(low) - e * 0.75, base - sh, max(low) + e * 0.75, base)) # leg serif
return centred(polys, cx, cy)
# ---------------------------------------------------------------- raster helpers
def raster(polys, ss=SS, holes=()):
m = Image.new("L", (GRID * ss, GRID * ss), 0)
d = ImageDraw.Draw(m)
for p in polys:
d.polygon([(x * ss, y * ss) for x, y in p], fill=255)
for p in holes:
d.polygon([(x * ss, y * ss) for x, y in p], fill=0)
return m
def gradient(size, top, bottom, light=0.0, seed=7):
"""Vertical gradient with a soft light from the top centre; dithered so dark tones don't band."""
yy, xx = np.mgrid[0:size, 0:size].astype(np.float32) / (size - 1)
t = yy[..., None]
a, b = np.array(top, np.float32), np.array(bottom, np.float32)
g = a + (b - a) * t
if light:
d = np.sqrt(((xx - 0.5) * 1.15) ** 2 + (yy + 0.10) ** 2)
g[..., :3] += (light * np.clip(1 - d / 0.95, 0, 1) ** 2)[..., None]
g[..., :3] += np.random.default_rng(seed).uniform(-0.5, 0.5, (size, size, 1)).astype(np.float32)
return Image.fromarray(np.clip(g, 0, 255).round().astype(np.uint8), "RGBA")
def solid(size, rgba):
return Image.new("RGBA", (size, size), rgba)
def paint(canvas, fill, mask):
layer = Image.new("RGBA", canvas.size, (0, 0, 0, 0))
layer.paste(fill, (0, 0), mask)
return Image.alpha_composite(canvas, layer)
def faded(mask, alpha):
return mask.point(lambda v: int(v * alpha))
@lru_cache(maxsize=None)
def body(dark, ss=SS):
"""Shadow, squircle body with gradient, inner hairline and soft top light."""
S = GRID * ss
img = Image.new("RGBA", (S, S), (0, 0, 0, 0))
shape = squircle(BODY)
m = raster([shape], ss)
# drop shadow in the template margin
sh = raster([[(x, y + 10) for x, y in shape]], ss).filter(ImageFilter.GaussianBlur(14 * ss))
img = paint(img, solid(S, (0, 0, 0, 255)), faded(sh, 0.32))
if dark:
fill = gradient(S, (36, 36, 39, 255), (8, 8, 9, 255), light=10)
else:
fill = gradient(S, (255, 255, 255, 255), (226, 226, 230, 255), light=0)
img = paint(img, fill, m)
# hairline just inside the edge (defines the shape on any Dock background)
inner = raster([squircle((BODY[0] + 2.2, BODY[1] + 2.2, BODY[2] - 2.2, BODY[3] - 2.2), 185.4 - 2.2)], ss)
ring = ImageChops.subtract(m, inner)
img = paint(img, solid(S, (255, 255, 255, 255) if dark else (0, 0, 0, 255)), faded(ring, 0.16 if dark else 0.10))
return img, m
# ---------------------------------------------------------------- variants
INK_LIGHT = (246, 245, 242, 255) # warm white
INK_DARK = (17, 17, 18, 255)
def v_monogramm(bold=1.0, ss=SS):
img, m = body(True, ss)
letters = raster(lk_ligature(512, 506, bold=bold), ss)
return paint(img, solid(img.width, INK_LIGHT), ImageChops.multiply(letters, m))
def v_hell(bold=1.0, ss=SS):
img, m = body(False, ss)
letters = raster(lk_ligature(512, 506, bold=bold), ss)
return paint(img, solid(img.width, INK_DARK), ImageChops.multiply(letters, m))
def v_kasten(bold=1.0, ss=SS):
img, m = body(True, ss)
letters = lk_pair(512, 512, cap=214, w=19, bold=bold)
f, t = 262, 9.0 * bold ** 0.7 # frame: half size, line width
frame = raster([rect(512 - f, 512 - f, 512 + f, 512 + f)], ss,
holes=[rect(512 - f + t, 512 - f + t, 512 + f - t, 512 + f - t)])
mark = ImageChops.lighter(raster(letters, ss), frame)
return paint(img, solid(img.width, INK_LIGHT), ImageChops.multiply(mark, m))
def v_serif(bold=1.0, ss=SS):
img, m = body(True, ss)
letters = raster(lk_serif(512, 512, cap=262, bold=bold), ss)
return paint(img, solid(img.width, INK_LIGHT), ImageChops.multiply(letters, m))
VARIANTS = {
"monogramm": ("Monogramm", v_monogramm),
"hell": ("Hell", v_hell),
"kasten": ("Kasten", v_kasten),
"serif": ("Serif", v_serif),
}
# ---------------------------------------------------------------- output
def render(name, size=1024):
"""Icon at `size` px. Small sizes are drawn with heavier strokes (optical sizing)."""
fn = VARIANTS[name][1]
bold = 1.0 if size >= 256 else (1.18 if size >= 128 else (1.40 if size >= 64 else 1.75))
big = fn(bold=bold)
img = big.reduce(SS) # box filter: exact coverage, no ringing
return img if size == 1024 else img.resize((size, size), Image.LANCZOS)
def write(name):
icon = render(name)
extra = [render(name, s) for s in (32, 64, 128, 256, 512)]
out = ROOT / "Resources"
(out / "Icon").mkdir(parents=True, exist_ok=True)
icon.save(out / "Icon" / "AppIcon-1024.png")
extra[3].save(out / "Icon" / "AppIcon-256.png")
icon.save(out / "AppIcon.icns", append_images=extra)
print(f"AppIcon.icns ← {VARIANTS[name][0]}")
def preview(path):
"""Comparison sheet: every variant large, plus Dock sizes on a light and a dark background."""
from PIL import ImageFont
def font(size):
for f in ("/usr/share/fonts/opentype/inter/Inter-SemiBold.otf", "/System/Library/Fonts/SFNS.ttf",
"/System/Library/Fonts/Helvetica.ttc"):
try:
return ImageFont.truetype(f, size)
except OSError:
pass
return ImageFont.load_default()
names, col, pad = list(VARIANTS), 480, 44
sheet = Image.new("RGBA", (pad + len(names) * (col + pad), 1010), (232, 232, 235, 255))
d = ImageDraw.Draw(sheet)
for i, n in enumerate(names):
x = pad + i * (col + pad)
d.text((x + 8, 34), f"{chr(65 + i)} {VARIANTS[n][0]}", font=font(34), fill=(22, 22, 24, 255))
sheet.alpha_composite(render(n).resize((col, col), Image.LANCZOS), (x, 92))
for j, bg in enumerate([(250, 250, 252, 255), (28, 28, 30, 255)]):
y = 92 + col + 24 + j * 186
d.rounded_rectangle((x, y, x + col, y + 166), radius=30, fill=bg)
ix = x + 22
for s in (128, 64, 32):
sheet.alpha_composite(render(n, s), (ix, y + (166 - s) // 2))
ix += s + 30
sheet.convert("RGB").save(path)
print(f"Vorschau → {path}")
if __name__ == "__main__":
args = sys.argv[1:]
if args[:1] == ["--preview"]:
preview(args[1] if len(args) > 1 else "icon-preview.png")
sys.exit()
name = args[0] if args else DEFAULT
if name not in VARIANTS:
sys.exit(f"Unbekannte Variante {name!r}. Möglich: {', '.join(VARIANTS)}")
write(name)