Wordmark: half the narrow mark's red row was a bank too bright

The 53-column mark's fourth row is the only row in either wordmark whose
colour lands on the dim bank (185;28;28 -> slot 1), and on the console it
came out part red, part light red: the M's right leg, E, S, H and the R's
right leg promoted, the M's left leg, T, E and the R's left leg not.

The split follows the bevels. The mark alternates letter blocks with slate
bevel spans, the bevel is slot 8 -- spelled 90, which on the VT sets the
intensity bit -- and the quantizer handed back a bare 31 for the blocks
after it. Bare, it keeps the bit and renders 91. Every leg that happened to
follow a bevel went light red; every leg that followed one of the row's few
resets stayed red. The .ansi art is one colour throughout; the promotion is
entirely on the way out.

So the fold's quantizer now states its intent the way the theme's dim-slot
styles already must: a dim slot leaves as 22;3N, never a bare 3N. Adjacent
art spans reset nothing between them, so this is the only place that can
know. It fixes the same latent promotion in a map raster, where two
neighbouring cells are exactly this pattern.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jean-Pierre MartineauandClaude Opus 5 committed 2026-08-09 05:04:39 -04:00
1 parent 6e0c9ec50b
commit 0a6182b0e5
3 files changed
+47 -6

No files matched your search

+5 -1
View File
@@ -187,7 +187,11 @@ branch on the platform per frame, and never `from meshterm.platforms import PLAT
(the promotion is the point, only `title.muted`), never silent. Rich merges a row's
base style into every span, so a silent one changes colour inside a selected row. Same
trap outside the theme: `MapCanvas` drops emphasis entirely where bold is brightness,
since its colours arrive quantized and it can't know which bank they landed in.
since its colours arrive quantized and it can't know which bank they landed in, and the
fold's quantizer (`theme._nearest_slot_sgr`) states intent for it — a dim slot leaves as
`22;3N`, never a bare `3N`, because `9N` is *how* the console spells bright and adjacent
art spans (the wordmark's bevels, a raster's neighbouring cells) reset nothing between
them, so a bare one inherits the intensity bit and lands a bank too high mid-row.
- On picocalc, the node hue and the heat gradient **quantize** — same rule, coarser
resolution: `node_style` snaps the key's hue to its sixth of the wheel
(`theme._NODE_SLOT_HEXES`, the six chromatic bright slots) and heat to the `heat.*`
+14 -3
View File
@@ -664,6 +664,15 @@ def _nearest_slot_sgr(background: bool, r: int, g: int, b: int) -> str:
Foregrounds may land on any slot (30–37 / 90–97); backgrounds only on 0–7 (the VT has
no bright backgrounds), so a bright colour used as a fill picks its dim-bank cousin.
A **dim-bank foreground states its intent** (``22;3N``, normal intensity) rather than
emitting a bare ``3N``. Bold is brightness on the VT, and ``9N`` *is* how the console
spells bright — so a bare ``31`` immediately after a ``90`` inherits the intensity bit
and silently renders as ``91``. Quantized art is a run of adjacent colour spans with
no style boundaries to reset between them (the wordmark's every-other-span slate
bevel; a map raster's neighbouring cells), so the promotion lands mid-row and colours
half a row wrong: the narrow wordmark's fourth row — its only dim-slot row — came out
part red, part light red, split at each span that happened to follow the bevel.
"""
key = (background, r, g, b)
cached = _SLOT_CACHE.get(key)
@@ -678,10 +687,12 @@ def _nearest_slot_sgr(background: bool, r: int, g: int, b: int) -> str:
),
)
if background:
code = 40 + slot
sgr = f"\x1b[{40 + slot}m"
elif slot < 8:
sgr = f"\x1b[22;{30 + slot}m"
else:
code = 30 + slot if slot < 8 else 90 + slot - 8
cached = _SLOT_CACHE[key] = f"\x1b[{code}m"
sgr = f"\x1b[{90 + slot - 8}m"
cached = _SLOT_CACHE[key] = sgr
return cached
+28 -2
View File
@@ -200,7 +200,8 @@ def test_fold_quantizes_embedded_truecolor_to_the_slots() -> None:
set_platform(PICOCALC)
folded = fold_text("\x1b[38;2;148;163;184m○\x1b[0m")
assert "38;2;" not in folded
assert "\x1b[37m" in folded # #94a3b8 → nearest stock slot is 7 (#aaaaaa)
# #94a3b8 → nearest stock slot is 7 (#aaaaaa); a dim-bank slot states its intensity.
assert "\x1b[22;37m" in folded
background = fold_text("\x1b[48;2;94;234;212mX\x1b[0m")
assert "48;2;" not in background
assert re.search(r"\x1b\[4[0-7]m", background), background # bg clamps to the dim bank
@@ -312,7 +313,9 @@ def test_canvas_drops_emphasis_where_bold_means_brightness() -> None:
canvas.marker(0, 0, "x", (148, 163, 184)) # markers always draw emboldened
rendered = "".join(canvas.to_ansi_lines())
assert ("\x1b[1m" in rendered) is expect_bold, (platform.name, repr(rendered))
assert "\x1b[37m" in rendered # and the colour it was given survives intact
# And the colour it was given survives intact — a dim-bank slot with its intensity
# stated, so the span can't inherit brightness from the raster cell before it.
assert "\x1b[22;37m" in rendered
# -- the font build script stays mirrored ---------------------------------------------
@@ -372,6 +375,29 @@ def test_specimen_renders_clean_on_picocalc() -> None:
assert ord(ch) in FONT_CODEPOINTS, f"line {i} char {ch!r} outside the font"
def test_narrow_wordmark_keeps_its_dim_row_off_the_bright_bank() -> None:
"""Every span of the wordmark's dim-slot row states its intensity.
The mark alternates letter blocks with slate bevels, so a row painted on the dim bank
is a run of ``3N`` spans each following a ``90``. Bare, they inherit the console's
intensity bit and half the row renders a bank too bright — the narrow mark's fourth
row came out part red (slot 1), part light red (slot 9), split at every span that
followed a bevel.
"""
from meshterm.ui.logo import load_logo
from meshterm.ui.tui.frame import _banner_lines
set_platform(PICOCALC)
rows = _banner_lines(load_logo(53), 53)
assert rows, "the 53-column mark should fit a 53-column console"
for i, row in enumerate(rows):
for sgr in re.findall(r"\x1b\[([0-9;]*)m", row):
assert not re.fullmatch(r"3[0-7]", sgr), f"bare dim-bank SGR on row {i}: {row!r}"
# The fourth row is the mark's only dim-slot row, and it is one colour throughout.
reds = set(re.findall(r"\x1b\[([0-9;]+)m(?=█)", rows[3]))
assert reds == {"22;31"}, reds
# -- relocated marks stay importable from their old homes -----------------------------