fix(frame): start the corner fade at the brightest palette stop
A ladder is a hue walk, not a brightness walk, so painting the hot end backwards put the dim colour at the corner. Sort the ramp by stock brightness and follow the pane height for the bottom-left glow.
This commit is contained in:
1 parent
81116282cb
commit
ec2ca72efb
4 files changed
+117
-39
No files matched your search
@@ -75,6 +75,32 @@ PALETTES: dict[str, tuple[str, ...]] = {
|
||||
"mono": ("bright_black", "white", "bright_white"),
|
||||
}
|
||||
|
||||
#: The stock names from dark to bright. These are xterm's default values in
|
||||
#: Rec. 601 luma order — the closest thing to a stock answer. A theme may
|
||||
#: disagree about the exact numbers, but the ordering is what the frame fades
|
||||
#: need: a ladder is a *hue* walk, so where it ends says nothing about which
|
||||
#: end is brighter.
|
||||
BRIGHTNESS: tuple[str, ...] = (
|
||||
"black",
|
||||
"blue",
|
||||
"red",
|
||||
"bright_red",
|
||||
"magenta",
|
||||
"bright_magenta",
|
||||
"bright_blue",
|
||||
"green",
|
||||
"bright_black",
|
||||
"cyan",
|
||||
"bright_green",
|
||||
"bright_cyan",
|
||||
"yellow",
|
||||
"white",
|
||||
"bright_yellow",
|
||||
"bright_white",
|
||||
)
|
||||
|
||||
_RANK = {name: rank for rank, name in enumerate(BRIGHTNESS)}
|
||||
|
||||
#: Cycle order for the palette key.
|
||||
PALETTE_ORDER: tuple[str, ...] = tuple(PALETTES)
|
||||
|
||||
@@ -86,3 +112,8 @@ def palette_stops(name: str | None) -> tuple[str, ...]:
|
||||
"""The ladder for ``name``, falling back to the default palette."""
|
||||
key = (name or "").strip().lower()
|
||||
return PALETTES.get(key, PALETTES[DEFAULT_PALETTE])
|
||||
|
||||
|
||||
def brightness(colour: str) -> int:
|
||||
"""How bright a stock name is: 0 (black) to 15 (bright white)."""
|
||||
return _RANK.get(colour.strip().lower(), 0)
|
||||
Reference in new issue
Block a user