feat(palette): sixteen ANSI colour ladders, cycled with c
This commit is contained in:
1 parent
253b462df1
commit
43ddd8666b
14 files changed
+622
-111
No files matched your search
@@ -10,7 +10,7 @@ from rich.text import Text
|
||||
from textual.widget import Widget
|
||||
|
||||
from .common import (
|
||||
SPECTRUM_STOPS,
|
||||
active_stops,
|
||||
clock_time,
|
||||
date_label,
|
||||
gradient,
|
||||
@@ -22,7 +22,13 @@ if TYPE_CHECKING:
|
||||
from ..app import BeefyPlayerApp
|
||||
|
||||
|
||||
def _hero_line(markup: str, index: int, width: int, gradient_fill: bool) -> Text:
|
||||
def _hero_line(
|
||||
markup: str,
|
||||
index: int,
|
||||
width: int,
|
||||
gradient_fill: bool,
|
||||
stops: tuple[str, ...],
|
||||
) -> Text:
|
||||
"""One row of the hero: spectrum-painted glyphs, or the art's own colours."""
|
||||
if not gradient_fill:
|
||||
line = Text.from_markup(markup)
|
||||
@@ -32,7 +38,7 @@ def _hero_line(markup: str, index: int, width: int, gradient_fill: bool) -> Text
|
||||
line = Text(no_wrap=True)
|
||||
for column, char in enumerate(markup):
|
||||
position = (column / max(1, width - 1) + index * 0.055) % 1.0
|
||||
line.append(char, style=f"bold {gradient(SPECTRUM_STOPS, position)}")
|
||||
line.append(char, style=f"bold {gradient(stops, position)}")
|
||||
return line
|
||||
|
||||
|
||||
@@ -45,6 +51,7 @@ class HeaderBar(Widget):
|
||||
hero = tuple(getattr(provider, "hero", ()) or ())
|
||||
hero_lines = tuple(getattr(provider, "hero_lines", ()) or ())
|
||||
gradient_fill = bool(getattr(provider, "hero_gradient", False))
|
||||
stops = active_stops(app)
|
||||
|
||||
width = max(24, self.size.width)
|
||||
height = max(1, self.size.height)
|
||||
@@ -73,7 +80,7 @@ class HeaderBar(Widget):
|
||||
|
||||
lines: list[Text] = []
|
||||
for index, row in enumerate(hero):
|
||||
line = _hero_line(row, index, hero_width, gradient_fill)
|
||||
line = _hero_line(row, index, hero_width, gradient_fill, stops)
|
||||
# Art rows are right-trimmed, so a row ending in a blank cell is a
|
||||
# column short; pad it back or the caption and clock drift left.
|
||||
short = hero_width - cell_len(line.plain)
|
||||
|
||||
Reference in new issue
Block a user