MCPcopy
hub / github.com/Textualize/rich / ColorBox

Class ColorBox

rich/__main__.py:18–36  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16
17
18class ColorBox:
19 def __rich_console__(
20 self, console: Console, options: ConsoleOptions
21 ) -> RenderResult:
22 for y in range(0, 5):
23 for x in range(options.max_width):
24 h = x / options.max_width
25 l = 0.1 + ((y / 5) * 0.7)
26 r1, g1, b1 = colorsys.hls_to_rgb(h, l, 1.0)
27 r2, g2, b2 = colorsys.hls_to_rgb(h, l + 0.7 / 10, 1.0)
28 bgcolor = Color.from_rgb(r1 * 255, g1 * 255, b1 * 255)
29 color = Color.from_rgb(r2 * 255, g2 * 255, b2 * 255)
30 yield Segment("▄", Style(color=color, bgcolor=bgcolor))
31 yield Segment.line()
32
33 def __rich_measure__(
34 self, console: "Console", options: ConsoleOptions
35 ) -> Measurement:
36 return Measurement(1, options.max_width)
37
38
39def make_test_card() -> Table:

Callers 1

make_test_cardFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected