diff --git a/README.md b/README.md index 25a6d08..c38d920 100644 --- a/README.md +++ b/README.md @@ -114,9 +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, 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` (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. +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. ## Trikotnummern-Erkennung (Trikot + Hose) diff --git a/Resources/AppIcon.icns b/Resources/AppIcon.icns index e917412..0bd00b2 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 cd08551..43e3d9a 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 34293a7..18af3de 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 7e32786..09f47d3 100644 --- a/scripts/make-icon.py +++ b/scripts/make-icon.py @@ -1,8 +1,9 @@ #!/usr/bin/env python3 -"""Lichtkasten app icon: black and white LK monogram, drawn from geometry (no fonts needed). +"""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). 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 fein # 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. @@ -19,7 +20,7 @@ ROOT = Path(__file__).resolve().parent.parent GRID = 1024 BODY = (100, 100, 924, 924) SS = 4 # supersampling for clean edges -DEFAULT = "monogramm" +DEFAULT = "tunnel" # ---------------------------------------------------------------- geometry (design units, y down) @@ -234,9 +235,23 @@ def faded(mask, alpha): return mask.point(lambda v: int(v * alpha)) +# app palette (Sources/Lichtkasten/Views/Theme.swift): warm graphite ground, amber light +GOLD = (242, 181, 68) # LK.amber +GOLD_LIGHT = (255, 228, 156) +GOLD_DEEP = (190, 126, 36) + +BODIES = { + # top colour, bottom colour, top light, rim colour, rim opacity + "dark": ((36, 36, 39), (8, 8, 9), 10, (255, 255, 255), 0.16), + "light": ((255, 255, 255), (226, 226, 230), 0, (0, 0, 0), 0.10), + "warm": ((40, 33, 24), (10, 8, 6), 8, GOLD, 0.26), +} + + @lru_cache(maxsize=None) -def body(dark, ss=SS): - """Shadow, squircle body with gradient, inner hairline and soft top light.""" +def body(style, ss=SS): + """Shadow, squircle body with gradient, inner hairline (rim).""" + top, bottom, light, rim, rim_alpha = BODIES[style] S = GRID * ss img = Image.new("RGBA", (S, S), (0, 0, 0, 0)) shape = squircle(BODY) @@ -244,37 +259,137 @@ def body(dark, ss=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) + img = paint(img, gradient(S, top + (255,), bottom + (255,), light=light), 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)) + img = paint(img, solid(S, rim + (255,)), faded(ImageChops.subtract(m, inner), rim_alpha)) return img, m + +def gold_fill(mask, ss=SS): + """Gold with light from above: light gold at the top of the letters, amber, deep gold at the bottom.""" + S = GRID * ss + ys = np.nonzero(np.asarray(mask).max(axis=1))[0] + y0, y1 = (ys.min(), ys.max()) if len(ys) else (0, S - 1) + t = np.clip((np.arange(S, dtype=np.float32) - y0) / max(1, y1 - y0), 0, 1) + stops = [(0.0, GOLD_LIGHT), (0.45, GOLD), (1.0, GOLD_DEEP)] + col = np.zeros((S, 3), np.float32) + for (t0, c0), (t1, c1) in zip(stops, stops[1:]): + sel = (t >= t0) & (t <= t1) + f = ((t[sel] - t0) / (t1 - t0))[:, None] + col[sel] = np.array(c0, np.float32) * (1 - f) + np.array(c1, np.float32) * f + img = np.empty((S, S, 4), np.uint8) + img[..., :3] = np.repeat(col[:, None, :], S, axis=1).round().astype(np.uint8) + img[..., 3] = 255 + return Image.fromarray(img, "RGBA") + + +def smoothstep(e0, e1, x): + t = np.clip((x - e0) / (e1 - e0), 0, 1) + return t * t * (3 - 2 * t) + + +def tunnel(ss=SS, front=292.0, step=0.30, frames=18, line=7.0, inner_fade=(86.0, 170.0), walls=1.0, bloom=0.38): + """A square box seen from the front that goes on forever: golden frames at equal depth steps + (screen size front/(1+i·step)), corner edges to the vanishing point, walls lit from the opening.""" + S = GRID * ss + c = (np.arange(S, dtype=np.float32) + 0.5) / ss - GRID / 2 + X, Y = np.meshgrid(c, c) + ax, ay = np.abs(X), np.abs(Y) + d = np.maximum(ax, ay) # square "radius" + inside = d <= front + near = np.clip(d / front, 0, 1) # 1 at the opening, 0 at infinity + # walls: top lit most, sides less, floor least – all fading into the depth + top_wall = (Y < 0) & (ay >= ax) + floor = (Y > 0) & (ay >= ax) + wall = np.where(top_wall, 1.0, np.where(floor, 0.42, 0.66))[..., None] + base = np.array((66, 50, 30), np.float32) + rgb = base * walls * wall * (near ** 1.7)[..., None] + # golden frames + lines = np.zeros_like(d) + for i in range(frames): + z = 1 + i * step + f = front / z + if f < inner_fade[0]: + break + t = line * z ** -1.0 + strength = z ** -1.15 * (1.0 if i == 0 else 0.9) * smoothstep(inner_fade[0], inner_fade[1], f) + lines = np.maximum(lines, (np.abs(d - f) <= t / 2) * strength) + # corner edges of the box + edge_t = line * 0.8 * np.maximum(near, 0.05) ** 0.85 + edges = (np.abs(ax - ay) / math.sqrt(2) <= edge_t / 2) & inside + lines = np.maximum(lines, edges * near ** 1.3 * smoothstep(inner_fade[0], inner_fade[1] * 1.15, d)) + gold = np.array(GOLD, np.float32) + rgb = rgb * (1 - lines[..., None]) + gold * lines[..., None] + # the gold lines glow a little: light box + glow = np.asarray(Image.fromarray((lines * 255).astype(np.uint8)).filter(ImageFilter.GaussianBlur(7 * ss)), + np.float32) / 255 + rgb = rgb + gold * (bloom * glow * inside)[..., None] + rgb += np.random.default_rng(11).uniform(-0.5, 0.5, rgb.shape[:2] + (1,)).astype(np.float32) # no banding + alpha = (d <= front + line / 2).astype(np.float32) + out = np.dstack([np.clip(rgb, 0, 255), alpha * 255]).round().astype(np.uint8) + return Image.fromarray(out, "RGBA") + + # ---------------------------------------------------------------- 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) +def lettering(img, m, polys, ss, shadow=True): + """Gold letters floating in front: soft shadow, dark halo that separates them from the lines, gold fill.""" + letters = raster(polys, ss) + if shadow: + sh = letters.filter(ImageFilter.GaussianBlur(9 * ss)) + shadow_layer = Image.new("RGBA", img.size, (0, 0, 0, 0)) + shadow_layer.paste(solid(img.width, (4, 3, 2, 255)), (0, 7 * ss), faded(sh, 0.75)) + img = Image.alpha_composite(img, shadow_layer) + halo = letters.filter(ImageFilter.GaussianBlur(10 * ss)).point(lambda v: min(255, v * 2)) + img = paint(img, solid(img.width, (8, 6, 4, 255)), ImageChops.multiply(faded(halo, 0.9), m)) + return paint(img, gold_fill(letters, ss), ImageChops.multiply(letters, m)) + + +def v_tunnel(bold=1.0, size=1024, ss=SS): + img, m = body("warm", ss) + small = size <= 64 + box = tunnel(ss, frames=(2 if size <= 32 else 3) if small else 18, + line=7.0 * (1.9 if small else 1.0) * (1.25 if size == 128 else 1.0), + step=0.42 if small else 0.30) + img = Image.alpha_composite(img, box) + return lettering(img, m, lk_ligature(512, 512, cap=272, w=31, bold=bold), ss) + + +def v_fein(bold=1.0, size=1024, ss=SS): + """Calmer 3D box: thin lines, barely lit walls, no glow.""" + img, m = body("warm", ss) + small = size <= 64 + box = tunnel(ss, front=286, frames=(2 if size <= 32 else 3) if small else 12, step=0.42 if small else 0.34, + line=(5.0 if not small else 9.0) * (1.25 if size == 128 else 1.0), + inner_fade=(120.0, 200.0), walls=0.45, bloom=0.0) + img = Image.alpha_composite(img, box) + return lettering(img, m, lk_ligature(512, 512, cap=262, w=30, bold=bold), ss) + + +def v_gold(bold=1.0, size=1024, ss=SS): + img, m = body("warm", ss) + return lettering(img, m, lk_ligature(512, 506, bold=bold), ss, shadow=False) + + +def v_monogramm(bold=1.0, size=1024, ss=SS): + img, m = body("dark", 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) +def v_hell(bold=1.0, size=1024, ss=SS): + img, m = body("light", 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) +def v_kasten(bold=1.0, size=1024, ss=SS): + img, m = body("dark", 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, @@ -283,13 +398,16 @@ def v_kasten(bold=1.0, ss=SS): 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) +def v_serif(bold=1.0, size=1024, ss=SS): + img, m = body("dark", 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 = { + "tunnel": ("Unendlicher Kasten", v_tunnel), + "fein": ("Feiner Kasten", v_fein), + "gold": ("Gold", v_gold), "monogramm": ("Monogramm", v_monogramm), "hell": ("Hell", v_hell), "kasten": ("Kasten", v_kasten), @@ -303,8 +421,9 @@ 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 + ss = SS if size >= 512 else (2 if size >= 256 else 1) + big = fn(bold=bold, size=size, ss=ss) + img = big.reduce(ss) if ss > 1 else big # box filter: exact coverage, no ringing return img if size == 1024 else img.resize((size, size), Image.LANCZOS) @@ -319,8 +438,8 @@ def write(name): 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.""" +def preview(path, names=None): + """Comparison sheet: variants large, plus Dock sizes on a light and a dark background.""" from PIL import ImageFont def font(size): @@ -332,7 +451,7 @@ def preview(path): pass return ImageFont.load_default() - names, col, pad = list(VARIANTS), 480, 44 + names, col, pad = names or 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): @@ -353,7 +472,7 @@ def preview(path): if __name__ == "__main__": args = sys.argv[1:] if args[:1] == ["--preview"]: - preview(args[1] if len(args) > 1 else "icon-preview.png") + preview(args[1] if len(args) > 1 else "icon-preview.png", args[2:] or None) sys.exit() name = args[0] if args else DEFAULT if name not in VARIANTS: