diff --git a/README.md b/README.md index c38d920..b7f3d8d 100644 --- a/README.md +++ b/README.md @@ -114,9 +114,10 @@ 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, Vorlage, Kontaktabzug während des Ingests, Karte auswerfen. In der Kamera gesperrte Fotos werden auf Wunsch getaggt. -App-Icon: `python3 scripts/make-icon.py` erzeugt `Resources/AppIcon.icns`: goldenes LK vor einem Kasten, der ins -Unendliche führt, in den Farben der App. Weitere Varianten: `fein`, `gold` sowie schwarz-weiß `monogramm`, `hell`, -`kasten`, `serif`, z. B. `python3 scripts/make-icon.py fein`. `--preview vorschau.png` zeigt alle nebeneinander. +App-Icon: `python3 scripts/make-icon.py` erzeugt `Resources/AppIcon.icns`: eine Kamerablende, halb im Schatten, +halb im warmen Licht, auf einer dunklen Metallkachel. Weitere Varianten (LK-Monogramme in Gold und Schwarz-Weiß, +der goldene Kasten): `gold`, `tunnel`, `fein`, `monogramm`, `hell`, `kasten`, `serif`, z. B. +`python3 scripts/make-icon.py gold`. `--preview vorschau.png` zeigt alle nebeneinander. ## Trikotnummern-Erkennung (Trikot + Hose) diff --git a/Resources/AppIcon.icns b/Resources/AppIcon.icns index 0bd00b2..b13f8aa 100644 Binary files a/Resources/AppIcon.icns and b/Resources/AppIcon.icns differ diff --git a/Resources/Icon/AppIcon-1024.png b/Resources/Icon/AppIcon-1024.png index 43e3d9a..4030ad5 100644 Binary files a/Resources/Icon/AppIcon-1024.png and b/Resources/Icon/AppIcon-1024.png differ diff --git a/Resources/Icon/AppIcon-256.png b/Resources/Icon/AppIcon-256.png index 18af3de..00ba6a2 100644 Binary files a/Resources/Icon/AppIcon-256.png and b/Resources/Icon/AppIcon-256.png differ diff --git a/scripts/make-icon.py b/scripts/make-icon.py index 09f47d3..866e586 100644 --- a/scripts/make-icon.py +++ b/scripts/make-icon.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 -"""Lichtkasten app icon: LK monogram in the app's black and gold, drawn from geometry (no fonts needed). -Default: the golden LK in front of a box that goes on forever (Lichtkasten). +"""Lichtkasten app icon, drawn from geometry (no fonts or images needed). +Default: a camera aperture, half in shadow and half in warm light, on a dark metal tile. +Other variants: LK monograms (gold, black and white) and the golden box that goes on forever. python3 scripts/make-icon.py # default variant → Resources/AppIcon.icns + PNGs python3 scripts/make-icon.py fein # another variant (see VARIANTS) @@ -20,7 +21,7 @@ ROOT = Path(__file__).resolve().parent.parent GRID = 1024 BODY = (100, 100, 924, 924) SS = 4 # supersampling for clean edges -DEFAULT = "tunnel" +DEFAULT = "blende" # ---------------------------------------------------------------- geometry (design units, y down) @@ -404,7 +405,182 @@ def v_serif(bold=1.0, size=1024, ss=SS): return paint(img, solid(img.width, INK_LIGHT), ImageChops.multiply(letters, m)) +# ---------------------------------------------------------------- Blende (camera aperture) + + +def radial(size, ss, center, radius, inner, outer, power=1.0, seed=5): + """Radial gradient in design units, dithered.""" + c = (np.arange(size, dtype=np.float32) + 0.5) / ss + X, Y = np.meshgrid(c - center[0], c - center[1]) + t = np.clip(np.hypot(X, Y) / radius, 0, 1) ** power + a, b = np.array(inner, np.float32), np.array(outer, np.float32) + g = a + (b - a) * t[..., None] + g += np.random.default_rng(seed).uniform(-0.5, 0.5, (size, size, 1)).astype(np.float32) + return Image.fromarray(np.dstack([np.clip(g, 0, 255), np.full((size, size), 255, np.float32)]).round().astype(np.uint8), "RGBA") + + +def inset(box, d): + return (box[0] + d, box[1] + d, box[2] - d, box[3] - d) + + +@lru_cache(maxsize=None) +def bezel(ss=SS): + """Dark metal tile: shadow, rim with a bright outer edge, recessed graphite face.""" + S = GRID * ss + img = Image.new("RGBA", (S, S), (0, 0, 0, 0)) + shape = squircle(BODY) + m = raster([shape], ss) + sh = raster([[(x, y + 12) for x, y in shape]], ss).filter(ImageFilter.GaussianBlur(16 * ss)) + img = paint(img, solid(S, (0, 0, 0, 255)), faded(sh, 0.36)) + img = paint(img, gradient(S, (58, 56, 54, 255), (9, 9, 9, 255)), m) + # bright outer edge, strongest at the top + edge = ImageChops.subtract(m, raster([squircle(inset(BODY, 3.2), 185.4 - 3.2)], ss)) + fade = Image.fromarray(np.repeat(np.linspace(250, 110, S, dtype=np.float32)[:, None], S, axis=1).astype(np.uint8)) + img = paint(img, solid(S, (238, 234, 228, 255)), ImageChops.multiply(edge, fade)) + # recessed face with a dark groove around it + fb, fr = inset(BODY, 26), 185.4 - 26 + groove = raster([squircle(inset(fb, -2.6), fr + 2.6)], ss) + img = paint(img, solid(S, (6, 6, 6, 255)), faded(groove, 0.85)) + face = raster([squircle(fb, fr)], ss) + img = paint(img, radial(S, ss, (512, 330), 660, (70, 67, 63), (13, 12, 11), power=1.05), face) + lip = ImageChops.subtract(face, raster([squircle(inset(fb, 1.8), fr - 1.8)], ss)) + img = paint(img, solid(S, (255, 255, 255, 255)), faded(lip, 0.16)) + return img, m + + +def _land(q0, q1, R): + lo, hi = 0.0, 1.0 + for _ in range(40): + mid = (lo + hi) / 2 + if math.hypot(*point_on(q0, q1, mid)) < R: + lo = mid + else: + hi = mid + return point_on(q0, q1, hi) + + +def aperture(R, r0, n=8, rot=-90.0, bend=0.0, step=1.0): + """Iris: hole polygon (n corners on radius r0), the n blade boundaries (each continues a hole edge and + bends on its way to the rim) and the n blade polygons. Coordinates relative to the centre.""" + V = [(r0 * math.cos(math.radians(rot + 360 * i / n)), r0 * math.sin(math.radians(rot + 360 * i / n))) + for i in range(n)] + curves = [] + for i in range(n): + a, b = V[i], V[(i + 1) % n] + ang = math.atan2(b[1] - a[1], b[0] - a[0]) + p, pts = b, [b] + while math.hypot(*p) < R: + ang += bend * step + p = (p[0] + math.cos(ang) * step, p[1] + math.sin(ang) * step) + pts.append(p) + pts[-1] = _land(pts[-2], pts[-1], R) + curves.append(pts) + blades = [] + for i in range(n): + prev, cur = curves[i - 1], curves[i] + a0 = math.atan2(prev[-1][1], prev[-1][0]) + arc = [(R * math.cos(a0 + k / 64 * 2 * math.pi / n), R * math.sin(a0 + k / 64 * 2 * math.pi / n)) + for k in range(65)] + blades.append(prev + arc + cur[::-1]) + return V, curves, blades + + +def strip(curve, width, side): + """Band of `width` along one side of a polyline (for the shadow a blade casts on its neighbour).""" + off = [] + for k, p in enumerate(curve): + q0, q1 = curve[max(0, k - 1)], curve[min(len(curve) - 1, k + 1)] + tx, ty = _norm_vec(q1[0] - q0[0], q1[1] - q0[1]) + off.append((p[0] - ty * width * side, p[1] + tx * width * side)) + return curve + off[::-1] + + +def _norm_vec(x, y): + l = math.hypot(x, y) or 1.0 + return x / l, y / l + + +def mix(a, b, t): + a, b = np.array(a, np.float32), np.array(b, np.float32) + return a + (b - a) * t[..., None] + + +def v_blende(bold=1.0, size=1024, ss=SS, n=8, bend=0.0020, rot=-90.0): + """Camera aperture, half in shadow and half in warm light – the light box.""" + S = GRID * ss + base_img, m = bezel(ss) + img = base_img.copy() + cx, cy, R = 512.0, 512.0, 288.0 + ring = 12.0 * bold ** 0.7 + line_w = 2.9 * bold ** 1.2 + c = (np.arange(S, dtype=np.float32) + 0.5) / ss + X, Y = np.meshgrid(c - cx, c - cy) + rho = np.hypot(X, Y) + lit = smoothstep(-3.0, 3.0, X) # 0 = shadow half, 1 = lit half + + # warm light spilling out of the lit half onto the face + outside = np.clip(rho - R, 0, None) + side = smoothstep(-0.45 * R, 0.85 * R, X) + wide = np.exp(-(outside / 74.0) ** 1.2) * side + tight = np.exp(-(outside / 13.0) ** 1.4) * side + face = np.asarray(img, np.float32) + amber, cream = np.array((255, 166, 72), np.float32), np.array((255, 236, 196), np.float32) + face[..., :3] = face[..., :3] + (amber - face[..., :3]) * (0.72 * wide)[..., None] + face[..., :3] = face[..., :3] + (cream - face[..., :3]) * (0.85 * tight)[..., None] + + # blades: shadow half dark graphite, lit half cream → warm gold towards the rim and the split + t = np.clip(rho / R, 0, 1) + dark = mix((8, 8, 9), (50, 49, 47), t ** 1.5) + light = mix((255, 255, 252), (250, 206, 150), t ** 2.1) + near_split = (1 - smoothstep(0, 0.5 * R, X)) * 0.55 + light = light + (np.array((232, 158, 88), np.float32) - light) * near_split[..., None] + blades = dark * (1 - lit[..., None]) + light * lit[..., None] + + V, curves, polys = aperture(R, 0.18 * R, n=n, rot=rot, bend=bend) + to_px = lambda pts: [(x + cx, y + cy) for x, y in pts] + # each blade a touch different (overlapping leaves catch the light differently) + for i, poly in enumerate(polys): + bm = np.asarray(raster([to_px(poly)], ss), np.float32) / 255 + blades *= (1 + (0.035 if i % 2 else -0.025) * bm * (1 + 0.6 * lit))[..., None] + # soft shadow next to every boundary, then the boundary line itself + shade = Image.new("L", (S, S), 0) + lines = Image.new("L", (S, S), 0) + dl = ImageDraw.Draw(lines) + for cur in curves: + ImageDraw.Draw(shade).polygon([(x * ss, y * ss) for x, y in to_px(strip(cur, 17.0, 1))], fill=255) + dl.line([(x * ss, y * ss) for x, y in to_px(cur)], fill=255, width=max(1, round(line_w * ss))) + hole_pts = to_px(V) + dl.line([(x * ss, y * ss) for x, y in hole_pts + hole_pts[:1]], fill=255, width=max(1, round(line_w * ss))) + shade = np.asarray(shade.filter(ImageFilter.GaussianBlur(6 * ss)), np.float32) / 255 + blades *= (1 - shade * (0.34 + 0.22 * (1 - lit)))[..., None] + lines = np.asarray(lines, np.float32) / 255 + line_col = mix((150, 147, 142), (112, 64, 28), lit) # highlight in the shadow, groove in the light + blades = blades + (line_col - blades) * (lines * (0.70 + 0.22 * lit))[..., None] + # sheen on the shadow half + sheen = np.exp(-(((X + 0.42 * R) / (0.55 * R)) ** 2 + ((Y + 0.55 * R) / (0.30 * R)) ** 2)) * (1 - lit) + blades = blades + (255 - blades) * (0.10 * sheen)[..., None] + + disc_mask = np.asarray(raster([to_px([(R * math.cos(a), R * math.sin(a)) + for a in np.linspace(0, 2 * math.pi, 720, endpoint=False)])], ss), np.float32) / 255 + hole = np.asarray(raster([hole_pts], ss), np.float32) / 255 + out = face[..., :3] * (1 - disc_mask[..., None]) + blades * disc_mask[..., None] + out = out + (np.array((5, 5, 6), np.float32) - out) * hole[..., None] + + # ring: metal on the shadow side, glowing on the lit side + ring_a = np.clip(1 - np.abs(rho - R) / (ring / 2), 0, 1) ** 0.6 + ring_dark = mix((30, 30, 31), (132, 129, 124), np.clip(0.5 - Y / (2 * R), 0, 1)) + ring_col = ring_dark * (1 - lit[..., None]) + np.array((255, 248, 232), np.float32) * lit[..., None] + out = out + (ring_col - out) * ring_a[..., None] + # thin dark line where the blades meet the ring + seat = np.clip(1 - np.abs(rho - (R - ring / 2)) / 1.4, 0, 1) + out = out * (1 - 0.55 * seat)[..., None] + + res = np.dstack([np.clip(out, 0, 255), np.asarray(img, np.float32)[..., 3]]).round().astype(np.uint8) + return Image.fromarray(res, "RGBA") + + VARIANTS = { + "blende": ("Blende", v_blende), "tunnel": ("Unendlicher Kasten", v_tunnel), "fein": ("Feiner Kasten", v_fein), "gold": ("Gold", v_gold),