diff options
| author | blasty <blasty@local> | 2026-08-06 17:02:18 +0200 |
|---|---|---|
| committer | blasty <blasty@local> | 2026-08-06 17:02:18 +0200 |
| commit | 45ba9cf2f448b8c0e9548fce08ced7cea3d9cf69 (patch) | |
| tree | 15d01087b92e5408e190491ca0395b55f5e4dbce /idatui/app.py | |
| parent | help: reach the cheatsheet with H as well as F1 (diff) | |
| download | ida-tui-45ba9cf2f448b8c0e9548fce08ced7cea3d9cf69.tar.gz ida-tui-45ba9cf2f448b8c0e9548fce08ced7cea3d9cf69.tar.xz ida-tui-45ba9cf2f448b8c0e9548fce08ced7cea3d9cf69.zip | |
splash: blasty's transparent logo, and stop guessing the cell aspect
The artwork is now a proper transparent PNG with soft edges (24% of its pixels
carry partial alpha) instead of opaque art on black with a stray full-width
scan line along the bottom. Cropped to its content and resized 1024 -> 768px,
which halves the file and costs nothing visible; logo-trans.png keeps the
master for future re-renders.
Two things the new art exposed, both wrong before it:
fit() assumed cells were 1:2. This terminal reports 9x22, i.e. 1:2.44. The old
logo was 474x516 -- close enough to the assumption that nobody noticed -- but a
square image at the hardcoded 60x33 would have been visibly stretched. The
graphics query now asks for the cell size too (CSI 16 t rides along in the same
round trip, before the DA1 that already synchronises it) and fit() uses the
answer.
The footprint was a constant. logo_cells() derives it from the artwork and the
measured cell size, so the art can be replaced without anyone remembering to
edit a number.
logo.ans was stale: the block-art fallback for terminals that can't draw an
image was still the OLD artwork, scan line included. tools/make_logo_ans.py
regenerates it from logo.png so the two cannot drift again. It understands
alpha -- a transparent cell emits no colour and lets the terminal background
through, and a cell with only one opaque half uses the matching half block so
the pixel lands on the correct side.
Diffstat (limited to 'idatui/app.py')
| -rw-r--r-- | idatui/app.py | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/idatui/app.py b/idatui/app.py index b3367c4..fc19fa5 100644 --- a/idatui/app.py +++ b/idatui/app.py @@ -3757,9 +3757,25 @@ class ConfirmScreen(ModalScreen): _REPO_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) _LOGO_PATH = os.path.join(_REPO_ROOT, "logo.ans") #: The same artwork as a real image, for terminals that can draw one. logo.ans -#: is 60x33 cells of half-blocks, i.e. 60x66 pixels; this is 474x516. +#: is half-blocks (two pixels per cell); this is a transparent PNG at 768px. LOGO_PNG = os.path.join(_REPO_ROOT, "logo.png") -_LOGO_CELLS = (60, 33) # what logo.ans occupies, so either path lays out the same +_LOGO_BOX = (60, 33) # the most room the splash will give the art +_logo_cells: tuple[int, int] | None = None + + +def logo_cells() -> tuple[int, int]: + """Cell footprint for the image, derived from the artwork and the terminal's + real cell size rather than hardcoded. + + Cells are nowhere near square (9x22 px here, 1:2.44), so a fixed box picked + for one aspect ratio stretches any other. Recomputing means the art can be + replaced without anyone remembering to edit a constant. + """ + global _logo_cells + if _logo_cells is None: + px = kittygfx.png_size(LOGO_PNG) + _logo_cells = kittygfx.fit(px, *_LOGO_BOX) if px else _LOGO_BOX + return _logo_cells _logo_cache: object = False # False == not yet loaded (None == absent/unreadable) @@ -3805,9 +3821,10 @@ class LoadingScreen(ModalScreen): # The image is anchored to screen cells rather than composited by # Textual (no unicode-placeholder support here), so the widget is # only reserved blank space -- see _place_logo. - cols, rows = _LOGO_CELLS + cols, rows = logo_cells() kittygfx.log(f"compose: supported={kittygfx.supported()} " - f"app.size={self.app.size} fits={self._fits(rows)}") + f"app.size={self.app.size} cells={cols}x{rows} " + f"fits={self._fits(rows)}") if kittygfx.supported() and self._fits(rows): self._image = True blank = Static("\n" * (rows - 1), id="loading-image") @@ -3859,7 +3876,7 @@ class LoadingScreen(ModalScreen): kittygfx.log(f"place_logo: region={region}") if not region.width or not region.height: return - cols, rows = _LOGO_CELLS + cols, rows = logo_cells() col = region.x + max((region.width - cols) // 2, 0) # centre it kittygfx.place(region.y, col, min(cols, region.width), rows) |
