A thin chip seam is halfway between the chip's label and its fill
The thin chevron between two chips of one colour took the previous chip's label colour. It now takes the OKLab midpoint of that label and the chip's fill (oklab.midpoint), so the line is softer than the text. The 16-colour console keeps the label, because it has no slot between a bright hue and its dim twin. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0d09a364cd
commit
f296413a5e
5 files changed
+92
-34
No files matched your search
@@ -470,9 +470,11 @@ as a grouped list does. Filling a page in is editing its `.md`; no Python follow
|
||||
can't tell apart: under `pathline.SEAM_BLUR` apart in OKLab (`ui/oklab.py`, THE
|
||||
perceptual colour distance — never a hue gap, never sRGB, both of which mis-size the
|
||||
greens against the cyans). There the seam is the **thin** chevron (`POWERLINE_THIN`)
|
||||
in the previous chip's label colour, drawn on the next, so the ribbon runs on unbroken
|
||||
and the join is a line the chip draws
|
||||
on itself, never a wedge of page cut out of the route and never a third colour. An
|
||||
halfway between the previous chip's label and fill (OKLab, `oklab.midpoint`; JP,
|
||||
2026-10-29 — it was the label itself), drawn on the next, so the ribbon runs on
|
||||
unbroken and the join is a line the chip draws on itself out of its own pair, never a
|
||||
wedge of page cut out of the route. The PicoCalc keeps the label: it has no slot
|
||||
between a bright hue and its dim twin (`pathline._slot_seam`). An
|
||||
elision breaks the ribbon rather than joining it — bare `⋯`
|
||||
on the page between a closing point and the next chip's notch, no fill, no padding.
|
||||
- The ribbon's **outer ends**: the chevron means *the route continues*, so an end that is
|
||||
|
||||
@@ -121,6 +121,18 @@ def distance(first: str, second: str) -> float:
|
||||
return math.dist(from_hex(first), from_hex(second))
|
||||
|
||||
|
||||
def midpoint(first: str, second: str) -> str:
|
||||
"""The ``#rrggbb`` colour halfway between two ``#rrggbb`` colours, as the eye sees them.
|
||||
|
||||
The function finds the average of the two colours in OKLab. Thus the result is halfway
|
||||
in lightness and halfway in chroma to the eye. The average of two colours in the sRGB
|
||||
gamut can be a little outside it, because the transform is not linear. :func:`fitted`
|
||||
then lowers its chroma.
|
||||
"""
|
||||
(l1, a1, b1), (l2, a2, b2) = from_hex(first), from_hex(second)
|
||||
return to_hex(fitted(((l1 + l2) / 2, (a1 + a2) / 2, (b1 + b2) / 2)))
|
||||
|
||||
|
||||
def shaded(colour: str, by: float, *, floor: float | None = None) -> str:
|
||||
"""``colour`` moved ``by`` in lightness, away from the end of the scale that is nearer.
|
||||
|
||||
|
||||
+45
-21
@@ -25,9 +25,10 @@ surface that the survey found can in the end use it.
|
||||
keyless greys). Sometimes they have two fills that are too close to tell apart (less
|
||||
than :data:`SEAM_BLUR` apart in OKLab, the perceptual distance that
|
||||
:mod:`~meshterm.ui.oklab` measures). Then the interlock cannot draw the seam, and the
|
||||
seam is the *thin* chevron instead. It has the colour of the label of the previous chip,
|
||||
and it is drawn on the next chip. Thus the ribbon continues without a break, and the
|
||||
join is a line that the chip draws on itself (:meth:`PathLine._seam`).
|
||||
seam is the *thin* chevron instead. Its colour is halfway between the label and the fill
|
||||
of the previous chip (on the 16-colour console, the label itself), and it is drawn on
|
||||
the next chip. Thus the ribbon continues without a break, and the join is a line that
|
||||
the chip draws on itself (:meth:`PathLine._seam`).
|
||||
|
||||
Hops that are elided from the middle break the ribbon and do not join it. The mark is
|
||||
bare on the page, between a closing point and the notch of the next chip
|
||||
@@ -126,8 +127,8 @@ POWERLINE_SEP = "\ue0b0"
|
||||
#: The thin right-pointing chevron (U+E0B1). It is the outline sibling of the solid point,
|
||||
#: in the same core set. It is powerline's own mark for a join *inside* one colour. It
|
||||
#: draws the seam between two chips whose fills the eye cannot tell apart
|
||||
#: (:meth:`PathLine._seam`). It is the previous fill, shaded, and drawn on the next chip,
|
||||
#: where a solid point disappears.
|
||||
#: (:meth:`PathLine._seam`). It is drawn on the next chip, where a solid point disappears,
|
||||
#: in a colour halfway between the label and the fill of the previous chip.
|
||||
POWERLINE_THIN = "\ue0b1"
|
||||
|
||||
#: The rounded caps (U+E0B6 opening, U+E0B4 closing) that finish the two outer ends of a
|
||||
@@ -1179,16 +1180,17 @@ class PathLine:
|
||||
equality, and it is not a gap of hue.
|
||||
|
||||
There the seam is the **thin** chevron, :data:`POWERLINE_THIN`. It is drawn on the
|
||||
fill ahead, in the colour of the label of the previous chip. It is powerline's
|
||||
own mark for a join inside one colour, and the chip to which it belongs draws a line
|
||||
on itself. Thus the ribbon continues without a break, and nothing on it is a colour
|
||||
that is not a colour of a chip. Before, the solid point that was drawn bare cut a
|
||||
wedge of page out of the route here. (A run of near hues read as dashes, and on a
|
||||
light terminal the wedge was a hole.) Then the thin chevron was the previous fill,
|
||||
one step darker in lightness (JP, 2026-09-16). When the label became the hue of the
|
||||
node on a darker fill of itself (2026-10-06), the label colour became the line. It is
|
||||
the light half of the same pair, so it is visible on each fill, and it is still the
|
||||
own colour of the chip. In both cases the seam is one cell.
|
||||
fill ahead. It is powerline's own mark for a join inside one colour, and the chip to
|
||||
which it belongs draws a line on itself. Thus the ribbon continues without a break,
|
||||
and the line comes from the two colours of the chip behind it. Before, the solid
|
||||
point that was drawn bare cut a wedge of page out of the route here. (A run of near
|
||||
hues read as dashes, and on a light terminal the wedge was a hole.) Then the thin
|
||||
chevron was the previous fill, one step darker in lightness (JP, 2026-09-16). When
|
||||
the label became the hue of the node on a darker fill of itself (2026-10-06), the
|
||||
label colour became the line. Now the line is halfway between the label and the
|
||||
fill of the previous chip (JP, 2026-10-29), so it is softer than the label and
|
||||
still visible on the fill. On the 16-colour console, it is still the label
|
||||
(:func:`_slot_seam`). In all cases the seam is one cell.
|
||||
|
||||
Args:
|
||||
before: The colours of the previous chip. The point is drawn in its fill.
|
||||
@@ -1198,7 +1200,7 @@ class PathLine:
|
||||
The single styled cell of the seam.
|
||||
"""
|
||||
if _fills_blur(before.fill, after.fill):
|
||||
return Text(POWERLINE_THIN, style=f"{_FLAT}{before.ink} on {after.fill}")
|
||||
return Text(POWERLINE_THIN, style=f"{_FLAT}{_seam_line(before)} on {after.fill}")
|
||||
return Text(POWERLINE_SEP, style=f"{_FLAT}{before.fill} on {after.fill}")
|
||||
|
||||
@staticmethod
|
||||
@@ -1335,9 +1337,30 @@ def _slot_colours(hop: PathHop) -> _ChipColours:
|
||||
return _ChipColours(DIM_TWIN[ink], ink, ink)
|
||||
|
||||
|
||||
#: The colours of a chip, and the two prefixes of the chip styles. MeshTerm binds them when
|
||||
#: the platform switches (:func:`_bind_chips`).
|
||||
def _spectrum_seam(colours: _ChipColours) -> str:
|
||||
"""The line of a thin seam on a truecolor terminal: halfway between label and fill.
|
||||
|
||||
The halfway point is in OKLab (:func:`~meshterm.ui.oklab.midpoint`), so the line is
|
||||
halfway to the eye. Refer to :meth:`PathLine._seam`.
|
||||
"""
|
||||
return oklab.midpoint(colours.ink, colours.fill)
|
||||
|
||||
|
||||
def _slot_seam(colours: _ChipColours) -> str:
|
||||
"""The line of a thin seam on the 16-colour console: the label.
|
||||
|
||||
The console has no colour between a bright slot and its dim twin. The nearest slot to
|
||||
the halfway point is the label for most hues, but not for all of them. For yellow on
|
||||
brown, it is bright red. For white on light grey (a keyless chip), it is the light grey
|
||||
of the fill, on which the line disappears. The label is correct for each chip.
|
||||
"""
|
||||
return colours.ink
|
||||
|
||||
|
||||
#: The colours of a chip, the line of a thin seam, and the two prefixes of the chip styles.
|
||||
#: MeshTerm binds them when the platform switches (:func:`_bind_chips`).
|
||||
_colours_of: Callable[[PathHop], _ChipColours] = _spectrum_colours
|
||||
_seam_line: Callable[[_ChipColours], str] = _spectrum_seam
|
||||
#: The weight of a chip label: ``bold`` on a truecolor terminal.
|
||||
_WEIGHT = "bold "
|
||||
#: The prefix of each other chip style: empty on a truecolor terminal.
|
||||
@@ -1353,11 +1376,12 @@ def _bind_chips(platform: Platform) -> None:
|
||||
to its bright twin. For this reason each chip style there says ``not bold``, and a label
|
||||
gets no weight. Its bright slot is its emphasis.
|
||||
"""
|
||||
global _colours_of, _WEIGHT, _FLAT
|
||||
global _colours_of, _seam_line, _WEIGHT, _FLAT
|
||||
if platform.truecolor:
|
||||
_colours_of, _WEIGHT, _FLAT = _spectrum_colours, "bold ", ""
|
||||
_colours_of, _seam_line, _WEIGHT, _FLAT = _spectrum_colours, _spectrum_seam, "bold ", ""
|
||||
else:
|
||||
_colours_of, _WEIGHT, _FLAT = _slot_colours, "not bold ", "not bold "
|
||||
_colours_of, _seam_line = _slot_colours, _slot_seam
|
||||
_WEIGHT, _FLAT = "not bold ", "not bold "
|
||||
|
||||
|
||||
def _shorten(value: str, hash_bytes: int | None) -> str:
|
||||
|
||||
@@ -80,6 +80,21 @@ def test_fitted_lowers_chroma_alone_and_keeps_near_hues_apart() -> None:
|
||||
assert abs(after[1]) < abs(before[1]) # less chroma
|
||||
|
||||
|
||||
def test_midpoint_is_halfway_to_the_eye() -> None:
|
||||
"""The midpoint is equally far from the two colours, and half as far as they are apart.
|
||||
|
||||
The midpoint of black and white has ``L`` 0.5. The midpoint of a colour with itself is
|
||||
the same colour.
|
||||
"""
|
||||
assert oklab.from_hex(oklab.midpoint("#000000", "#ffffff"))[0] == pytest.approx(0.5, abs=0.01)
|
||||
assert oklab.midpoint("#f25555", "#f25555") == "#f25555"
|
||||
label, fill = "#55f255", _fill("4c")
|
||||
middle = oklab.midpoint(label, fill)
|
||||
half = oklab.distance(label, fill) / 2
|
||||
assert oklab.distance(middle, label) == pytest.approx(half, rel=0.05)
|
||||
assert oklab.distance(middle, fill) == pytest.approx(half, rel=0.05)
|
||||
|
||||
|
||||
def test_from_hex_rejects_anything_but_six_digits() -> None:
|
||||
"""Six hex digits are accepted, and the ``#`` and the case are optional.
|
||||
|
||||
|
||||
+15
-10
@@ -301,8 +301,9 @@ def test_picocalc_seams_on_one_colour_and_the_composer_slot(picocalc: None) -> N
|
||||
"""Two chips of one colour join on a thin chevron in the hue. The slot is a break.
|
||||
|
||||
The thin chevron is the bright twin of the fill: the colour of the label on the chip.
|
||||
The slot of the composer has no white background on the console. Thus it is a white
|
||||
``+`` on the page, and the chips on each side close on a point and open on a notch.
|
||||
The console has no colour halfway between the two. The slot of the composer has no
|
||||
white background on the console. Thus it is a white ``+`` on the page, and the chips
|
||||
on each side close on a point and open on a notch.
|
||||
"""
|
||||
same = PathLine([PathHop("Mill", key="1a"), PathHop("Tower", key="20")]).text()
|
||||
seam = same.plain.index(POWERLINE_THIN)
|
||||
@@ -858,14 +859,14 @@ def _seams(*hops: PathHop) -> list[tuple[str, str]]:
|
||||
|
||||
|
||||
def test_a_seam_between_two_of_one_colour_is_the_thin_chevron_in_its_label() -> None:
|
||||
"""Where two chips have the same fill, the seam is the thin chevron in the label colour.
|
||||
"""Where two chips have the same fill, the seam is the thin chevron, softer than the label.
|
||||
|
||||
The interlock cannot draw a solid point in its own background. Thus MeshTerm draws the
|
||||
join *on* the shared fill instead (powerline's own mark for a join inside one
|
||||
colour), and the ribbon continues without a break. Its colour is the label of the
|
||||
previous chip. It is the light half of the chip's own pair, so it is visible on the
|
||||
fill, and nothing on the line has a colour that is not a colour of a chip. The faded
|
||||
slate draws it in its muted text.
|
||||
colour), and the ribbon continues without a break. Its colour is halfway between the
|
||||
label and the fill of the previous chip (JP, 2026-10-29). Thus it comes from the
|
||||
chip's own pair, and it is softer than the label. The faded slate draws it halfway
|
||||
between its muted text and its fill.
|
||||
|
||||
This is not a rare accident. A mirrored return leg is a run of hops that are identically
|
||||
faded, by construction, and a stretch of keyless hops has one grey. In both cases the
|
||||
@@ -874,7 +875,10 @@ def test_a_seam_between_two_of_one_colour_is_the_thin_chevron_in_its_label() ->
|
||||
"""
|
||||
hue = _style_hex(node_style("aa"))
|
||||
glyph, style = _seams(PathHop("A", key="aa"), PathHop("B", key="aa"))[0]
|
||||
assert (glyph, style) == (POWERLINE_THIN, f"{hue} on {_fill('aa')}")
|
||||
line = oklab.midpoint(hue, _fill("aa"))
|
||||
assert (glyph, style) == (POWERLINE_THIN, f"{line} on {_fill('aa')}")
|
||||
to_label, to_fill = oklab.distance(line, hue), oklab.distance(line, _fill("aa"))
|
||||
assert to_label == pytest.approx(to_fill, rel=0.05) and to_fill > SEAM_BLUR
|
||||
|
||||
assert _seams(PathHop("A", key="aa"), PathHop("B", key="77"))[0] == (
|
||||
POWERLINE_SEP,
|
||||
@@ -882,7 +886,7 @@ def test_a_seam_between_two_of_one_colour_is_the_thin_chevron_in_its_label() ->
|
||||
) # a blend, one cell
|
||||
|
||||
glyph, style = _seams(PathHop("A", dim=True), PathHop("B", dim=True))[0]
|
||||
assert (glyph, style) == (POWERLINE_THIN, f"{_DIM_FG} on {_DIM_BG}")
|
||||
assert (glyph, style) == (POWERLINE_THIN, f"{oklab.midpoint(_DIM_FG, _DIM_BG)} on {_DIM_BG}")
|
||||
|
||||
|
||||
def test_a_seam_blurs_by_perceived_distance_not_by_hue_gap() -> None:
|
||||
@@ -900,7 +904,8 @@ def test_a_seam_blurs_by_perceived_distance_not_by_hue_gap() -> None:
|
||||
assert green[0] == POWERLINE_THIN and red[0] == POWERLINE_SEP
|
||||
assert oklab.distance(_fill("4c"), _fill("5c")) < SEAM_BLUR
|
||||
assert oklab.distance(_fill("00"), _fill("10")) > SEAM_BLUR
|
||||
assert green[1] == f"{_style_hex(node_style('4c'))} on {_fill('5c')}"
|
||||
line = oklab.midpoint(_style_hex(node_style("4c")), _fill("4c"))
|
||||
assert green[1] == f"{line} on {_fill('5c')}"
|
||||
|
||||
wrapped = _seams(PathHop("A", key="fc"), PathHop("B", key="02"))[0]
|
||||
assert wrapped[0] == POWERLINE_THIN # neighbours across the seam of the wheel, also
|
||||
|
||||
Reference in new issue
Block a user