The sword: tray icon, favicon, header logo and a backdrop for the web UI

- The-Kurgan-Sword.png is the source. kurgan/assets/make_assets.py cleans it
  (drops the white fringe left by the cut-out, smooths the edge to about a
  pixel) and builds everything from it:
  - kurgan/assets/kurgan.ico: the tray icon, 16-256 px, cropped to the
    crossguard; sizes of 32 px and under are brightened a little so the
    metal still reads on a dark taskbar.
  - web/static/favicon.ico: the same crop, 16-48 px.
  - web/static/logo.png: the header logo, the whole sword with the cut-off
    blade faded out.
  - web/static/sword-vertical.png: the whole sword turned 90 degrees
    clockwise.
- tray.py: ICON_PATH replaces the drawn power-tank icon (make_icon is gone).
  app.py already imports ICON_PATH; it went in with f717f7a.
- style.css: the vertical sword is a fixed backdrop below the header, lined
  up with the right edge of the tiles; the cards are 90% opaque so it shows
  through. 90% keeps the grey text at 4.5:1 contrast or better over the
  sword in both themes; 80% dropped it to 3.4:1.
- favicon.svg removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
paulandClaude Opus 5.5 committed 2026-12-05 18:25:27 +13:00
1 parent f717f7a82f
commit 8cc1e9223f
12 files changed
+153 -53

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

+127
View File
@@ -0,0 +1,127 @@
"""Make The Kurgan's logo and icons from the source photo, The-Kurgan-Sword.png (repo root).
.venv\\Scripts\\python.exe -m kurgan.assets.make_assets [source.png]
Writes:
kurgan/assets/sword.png the whole sword, cleaned and trimmed (master copy)
kurgan/assets/hilt.png 512 px square: the crossguard centred and as large as it fits
kurgan/assets/kurgan.ico the tray icon (16-256 px), from the hilt
kurgan/web/static/logo.png the web UI's header logo: the whole sword, the cut-off blade faded out
kurgan/web/static/sword-vertical.png the web UI's backdrop: the whole sword, full size, turned 90°
clockwise (pommel up); the page's bottom edge cuts the blade off
kurgan/web/static/favicon.ico the browser tab icon, from the hilt
Cleaning: the photo was cut out of a white background, leaving a pale one-pixel fringe and
stair-stepped edges. The outline is pulled in by a pixel, edge pixels take the colour of the
sword next to them instead of white, and the edge is smoothed to about a pixel wide.
Small icons (32 px and under) have their metal brightened a little: at 16 px on a dark taskbar
the mid-grey crossguard otherwise reads as black. The black grip still disappears there; an
outline was tried and made the 16 px icon a blur.
"""
from __future__ import annotations
import os
import sys
import numpy as np
from PIL import Image, ImageFilter
HERE = os.path.dirname(os.path.abspath(__file__))
ROOT = os.path.dirname(os.path.dirname(HERE))
STATIC = os.path.join(ROOT, "kurgan", "web", "static")
SOURCE = os.path.join(ROOT, "The-Kurgan-Sword.png")
ICON_SIZES = (16, 20, 24, 32, 40, 48, 64, 256) # tray: 16 at 100% scaling up to 32 at 200%; the rest for Windows
FAVICON_SIZES = (16, 32, 48)
LOGO_HEIGHT = 96 # shown 40 px high in the header: sharp up to about 240% scaling
SMALL_LIFT = 1.35 # gamma applied to icons of 32 px and under
BLADE_FADE = 0.18 # the last 18% of the header logo's width fades out (the photo cuts the blade off)
def _bleed(rgb: np.ndarray, known: np.ndarray, steps: int) -> np.ndarray:
"""Give pixels outside `known` the average colour of their known neighbours, ring by ring."""
rgb, known = rgb.copy(), known.copy()
for _ in range(steps):
acc = np.zeros_like(rgb)
count = np.zeros(known.shape, np.float32)
for dy in (-1, 0, 1):
for dx in (-1, 0, 1):
if dy or dx:
k = np.roll(known, (dy, dx), (0, 1))
acc += np.roll(rgb, (dy, dx), (0, 1)) * k[..., None]
count += k
new = ~known & (count > 0)
rgb[new] = acc[new] / count[new][:, None]
known |= new
return rgb
def clean(path: str) -> Image.Image:
"""The sword without its white fringe, with smooth edges, trimmed to its outline."""
src = np.asarray(Image.open(path).convert("RGBA")).astype(np.float32)
solid = Image.fromarray(((src[..., 3] > 128) * 255).astype(np.uint8))
core_img = solid.filter(ImageFilter.MinFilter(3)) # one pixel in: drops the fringe
core = np.asarray(core_img) > 0
rgb = _bleed(src[..., :3], core, 8) # edges take the sword's colour, not white
soft = np.asarray(core_img.filter(ImageFilter.GaussianBlur(1.0))).astype(np.float32) / 255
alpha = np.clip((soft - 0.5) * 2.0 + 0.5, 0, 1) # smooth, about a pixel wide
img = Image.fromarray(np.dstack([rgb, alpha * 255]).round().clip(0, 255).astype(np.uint8), "RGBA")
return img.crop(img.getchannel("A").point(lambda v: 255 if v > 8 else 0).getbbox())
def hilt(sword: Image.Image) -> Image.Image:
"""A square around the crossguard (the columns where the sword is tallest), as large as fits."""
a = np.asarray(sword.getchannel("A")) > 128
guard = np.nonzero(a.sum(0) > 0.6 * a.shape[0])[0]
rows = np.nonzero(a[:, guard].any(1))[0]
cx, cy = (guard.min() + guard.max()) / 2, (rows.min() + rows.max()) / 2
side = round((rows.max() - rows.min() + 1) * 1.03)
left, top = round(cx - side / 2), round(cy - side / 2)
square = Image.new("RGBA", (side, side), (0, 0, 0, 0))
piece = sword.crop((max(left, 0), max(top, 0), min(left + side, sword.width), min(top + side, sword.height)))
square.alpha_composite(piece, (max(-left, 0), max(-top, 0)))
return square
def icon_image(square: Image.Image, size: int) -> Image.Image:
small = square.resize((size, size), Image.LANCZOS)
if size > 32:
return small
small = small.filter(ImageFilter.UnsharpMask(0.6, 80, 0))
r, g, b, a = small.split()
lift = [round(255 * (v / 255) ** (1 / SMALL_LIFT)) for v in range(256)]
return Image.merge("RGBA", (r.point(lift), g.point(lift), b.point(lift), a))
def save_ico(square: Image.Image, path: str, sizes: tuple[int, ...]) -> None:
images = [icon_image(square, s) for s in sizes]
images[-1].save(path, format="ICO", sizes=[(s, s) for s in sizes], append_images=images[:-1])
def header_logo(sword: Image.Image) -> Image.Image:
width = round(sword.width * LOGO_HEIGHT / sword.height)
logo = sword.resize((width, LOGO_HEIGHT), Image.LANCZOS)
x = np.linspace(0, 1, width)
t = np.clip((x - (1 - BLADE_FADE)) / BLADE_FADE, 0, 1)
fade = 1 - t * t * (3 - 2 * t) # smoothstep down to nothing at the tip
alpha = np.asarray(logo.getchannel("A")).astype(np.float32) * fade[None, :]
logo.putalpha(Image.fromarray(alpha.round().astype(np.uint8)))
return logo
def main(source: str = SOURCE) -> None:
sword = clean(source)
sword.save(os.path.join(HERE, "sword.png"), optimize=True)
square = hilt(sword)
square.resize((512, 512), Image.LANCZOS).save(os.path.join(HERE, "hilt.png"), optimize=True)
save_ico(square, os.path.join(HERE, "kurgan.ico"), ICON_SIZES)
header_logo(sword).save(os.path.join(STATIC, "logo.png"), optimize=True)
sword.transpose(Image.Transpose.ROTATE_270).save(os.path.join(STATIC, "sword-vertical.png"), optimize=True)
save_ico(square, os.path.join(STATIC, "favicon.ico"), FAVICON_SIZES)
print(f"sword {sword.size}, hilt {square.size} -> 512, icons {ICON_SIZES}, logo height {LOGO_HEIGHT}")
if __name__ == "__main__":
main(*sys.argv[1:2])
Binary file not shown.

After

Width:  |  Height:  |  Size: 222 KiB

+1 -1
View File
@@ -1,4 +1,4 @@
"""Colours and thresholds shared by the LCD, the case/RAM lighting and the tray icon.""" """Colours and thresholds shared by the LCD and the case/RAM lighting."""
from __future__ import annotations from __future__ import annotations
+4 -38
View File
@@ -18,11 +18,14 @@ from __future__ import annotations
import ctypes import ctypes
import ctypes.wintypes as wt import ctypes.wintypes as wt
import logging import logging
import os
import subprocess import subprocess
import threading import threading
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
# The sword's hilt, 16-256 px (made by kurgan/assets/make_assets.py from The-Kurgan-Sword.png).
ICON_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets", "kurgan.ico")
TASK_NAME = "The Kurgan" TASK_NAME = "The Kurgan"
LEGACY_TASK_NAME = "TT LCD Dashboard" # until setup.ps1 re-registers the task LEGACY_TASK_NAME = "TT LCD Dashboard" # until setup.ps1 re-registers the task
@@ -84,37 +87,6 @@ def set_autostart(on: bool) -> None:
_powershell(_SET.replace("%TASK%", name).replace("%ON%", "$true" if on else "$false")) _powershell(_SET.replace("%TASK%", name).replace("%ON%", "$true" if on else "$false"))
# ----------------------------------------------------------------------------- icon image
def make_icon(path: str, layers: list[tuple[int, int, int]]) -> str:
"""Draw a small version of the dashboard's power tank and save it as a .ico file.
layers: colours from the bottom up (other, CPU, GPU).
"""
from PIL import Image, ImageDraw
s = 256
img = Image.new("RGBA", (s, s), (0, 0, 0, 0))
d = ImageDraw.Draw(img)
chrome, dark = (206, 206, 212, 255), (20, 20, 24, 255)
x0, x1 = 52, 204 # glass
d.rectangle([x0, 30, x1, 226], fill=dark)
y = 226
for h, c in zip((50, 42, 56), layers): # bottom up
d.rectangle([x0, y - h, x1, y], fill=c + (255,))
y -= h
d.rectangle([x0, y - 3, x1, y + 3], fill=dark)
hl = Image.new("RGBA", (s, s), (0, 0, 0, 0))
ImageDraw.Draw(hl).rectangle([x0 + 22, 36, x0 + 40, 222], fill=(255, 255, 255, 70))
img.alpha_composite(hl)
d = ImageDraw.Draw(img)
for y0, y1 in ((4, 40), (216, 252)): # end caps
d.rounded_rectangle([28, y0, 228, y1], radius=12, fill=chrome)
d.rectangle([28, (y0 + y1) // 2 - 2, 228, (y0 + y1) // 2 + 2], fill=(120, 120, 128, 255))
img.save(path, sizes=[(16, 16), (20, 20), (24, 24), (32, 32), (40, 40), (48, 48), (64, 64)])
return path
# ----------------------------------------------------------------------------- Win32 # ----------------------------------------------------------------------------- Win32
_u32 = ctypes.WinDLL("user32", use_last_error=True) _u32 = ctypes.WinDLL("user32", use_last_error=True)
@@ -418,16 +390,10 @@ class TrayIcon:
if __name__ == "__main__": if __name__ == "__main__":
# Quick check: show the icon for 20 s with a test tooltip. # Quick check: show the icon for 20 s with a test tooltip.
import os
import tempfile
import time
logging.basicConfig(level=logging.INFO, format="%(levelname)s %(message)s") logging.basicConfig(level=logging.INFO, format="%(levelname)s %(message)s")
print("Start with Windows:", autostart_enabled()) print("Start with Windows:", autostart_enabled())
path = make_icon(os.path.join(tempfile.gettempdir(), "kurgan_tray_test.ico"),
[(217, 89, 38), (57, 135, 229), (25, 158, 112)])
done = threading.Event() done = threading.Event()
tray = TrayIcon("The Kurgan (test)", path, on_exit=done.set, status_lines=lambda: ["Test run"]) tray = TrayIcon("The Kurgan (test)", ICON_PATH, on_exit=done.set, status_lines=lambda: ["Test run"])
tray.start() tray.start()
for i in range(20): for i in range(20):
tray.set_tooltip(f"The Kurgan (test)\n{i} s") tray.set_tooltip(f"The Kurgan (test)\n{i} s")
Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

-12
View File
@@ -1,12 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
<symbol id="tank" viewBox="0 0 32 32">
<rect x="6.5" y="4" width="19" height="24" rx="1" fill="#141418"/>
<rect x="6.5" y="21" width="19" height="7" fill="#d95926"/>
<rect x="6.5" y="14.5" width="19" height="6" fill="#3987e5"/>
<rect x="6.5" y="8" width="19" height="6" fill="#199e70"/>
<rect x="9" y="5" width="2.2" height="22" fill="#fff" opacity=".25"/>
<rect x="3.5" y="1" width="25" height="4.5" rx="1.5" fill="#cecdd4"/>
<rect x="3.5" y="26.5" width="25" height="4.5" rx="1.5" fill="#cecdd4"/>
</symbol>
<use href="#tank"/>
</svg>

Before

Width:  |  Height:  |  Size: 632 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

+21 -2
View File
@@ -73,9 +73,10 @@ button, select, input { font: inherit; color: inherit; }
background: color-mix(in srgb, var(--page) 92%, transparent); background: color-mix(in srgb, var(--page) 92%, transparent);
backdrop-filter: blur(6px); backdrop-filter: blur(6px);
border-bottom: 1px solid var(--border); border-bottom: 1px solid var(--border);
anchor-name: --masthead;
} }
.brand { display: flex; align-items: center; gap: 10px; } .brand { display: flex; align-items: center; gap: 10px; }
.brand svg { width: 22px; height: 22px; } .brand img { display: block; width: auto; height: 40px; }
.brand h1 { .brand h1 {
margin: 0; font-size: 17px; font-weight: 700; letter-spacing: 0.22em; color: var(--brand); margin: 0; font-size: 17px; font-weight: 700; letter-spacing: 0.22em; color: var(--brand);
} }
@@ -97,6 +98,20 @@ button, select, input { font: inherit; color: inherit; }
} }
.banner .note { margin: 0; font-size: 14px; } .banner .note { margin: 0; font-size: 14px; }
/* ---------------------------------------------------------------- the sword behind everything
Full size, pommel up, from just below the header to the bottom of the window, lined up with
the right edge of the tiles. Fixed: the page scrolls over it. The top follows the header's
height (it wraps on narrow windows); browsers without anchor positioning assume one row. */
body::after {
content: ""; position: fixed; z-index: -1; pointer-events: none;
top: 71px; bottom: 0; left: 0;
right: calc(max(0px, (100% - 1480px) / 2) + 24px); /* main's max-width and padding */
background: url("/static/sword-vertical.png") right top / auto 100% no-repeat;
}
@supports (top: anchor(--masthead bottom)) {
body::after { top: anchor(--masthead bottom); }
}
/* ---------------------------------------------------------------- layout */ /* ---------------------------------------------------------------- layout */
main { padding: 8px 24px 40px; max-width: 1480px; margin: 0 auto; } main { padding: 8px 24px 40px; max-width: 1480px; margin: 0 auto; }
section { margin-top: 28px; } section { margin-top: 28px; }
@@ -107,7 +122,10 @@ section > h2 {
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; margin-top: 16px; } .grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; margin-top: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin-top: 16px; } .grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin-top: 16px; }
.card { .card {
background: var(--surface); border: 1px solid var(--border); border-radius: 10px; /* The sword shows through. 90% keeps the grey text at 4.5:1 or better over the brightest
metal (dark theme) and the black grip (light theme); 80% dropped it to 3.4:1. */
background: color-mix(in srgb, var(--surface) 90%, transparent);
border: 1px solid var(--border); border-radius: 10px;
padding: 16px 18px; margin: 0; min-width: 0; padding: 16px 18px; margin: 0; min-width: 0;
} }
.card h3 { margin: 0 0 2px; font-size: 15px; font-weight: 600; } .card h3 { margin: 0 0 2px; font-size: 15px; font-weight: 600; }
@@ -264,6 +282,7 @@ footer { color: var(--text-2); font-size: 12.5px; padding: 0 24px 28px; max-widt
@media (max-width: 720px) { @media (max-width: 720px) {
.masthead { padding: 10px 14px; gap: 12px; } .masthead { padding: 10px 14px; gap: 12px; }
main { padding: 8px 14px 32px; } main { padding: 8px 14px 32px; }
body::after { right: 14px; }
.hero-value { font-size: 36px; } .hero-value { font-size: 36px; }
.grid2 { grid-template-columns: 1fr; } .grid2 { grid-template-columns: 1fr; }
} }
Binary file not shown.

After

Width:  |  Height:  |  Size: 228 KiB