img icon indicating copy to clipboard operation
img copied to clipboard

Please use the same character used by Rich and Textual for the pixels

Open Emasoft opened this issue 2 years ago • 1 comments

Can you use the same character used by Rich for the pixels?

IMG_0627

class ColorBox:
    def __rich_console__(
        self, console: Console, options: ConsoleOptions
    ) -> RenderResult:
        for y in range(0, 5):
            for x in range(options.max_width):
                h = x / options.max_width
                l = 0.1 + ((y / 5) * 0.7)
                r1, g1, b1 = colorsys.hls_to_rgb(h, l, 1.0)
                r2, g2, b2 = colorsys.hls_to_rgb(h, l + 0.7 / 10, 1.0)
                bgcolor = Color.from_rgb(r1 * 255, g1 * 255, b1 * 255)
                color = Color.from_rgb(r2 * 255, g2 * 255, b2 * 255)
                yield Segment("▄", Style(color=color, bgcolor=bgcolor))
            yield Segment.line()

    def __rich_measure__(
        self, console: "Console", options: ConsoleOptions
    ) -> Measurement:
        return Measurement(1, options.max_width)

Emasoft avatar Feb 19 '23 15:02 Emasoft

Message that will be displayed on users first issue

github-actions[bot] avatar Feb 19 '23 15:02 github-actions[bot]