Exemplo n.º 1
0
def test_color_to_256():
    # test B/W output
    # prefer usage of 16 and 231 for black and white since 0 and 15 are
    # user-defined
    assert termpixels.color.color_to_256(Color(0, 0, 0)) == 16
    assert termpixels.color.color_to_256(Color(255, 255, 255)) == 231

    # test grayscale output
    assert termpixels.color.color_to_256(Color.rgb(0.2, 0.2, 0.2)) == 236
    assert termpixels.color.color_to_256(Color.rgb(0.5, 0.5, 0.5)) == 244
    assert termpixels.color.color_to_256(Color.rgb(0.8, 0.8, 0.8)) == 251

    # test a couple RGB colors
    assert termpixels.color.color_to_256(Color(255, 0, 0)) == 196
    assert termpixels.color.color_to_256(Color(0, 255, 0)) == 46
    assert termpixels.color.color_to_256(Color(0, 0, 255)) == 21
    assert termpixels.color.color_to_256(Color(127, 127, 255)) == 105
Exemplo n.º 2
0
    def __init__(self):
        super().__init__()
        # set up buffers
        self._stdout = windll.kernel32.GetStdHandle(STD_OUTPUT_HANDLE)
        self._back_buffer = None
        self._char_data = None
        self._out_buffer = self._stdout
        windll.kernel32.SetConsoleMode(self._out_buffer, ENABLE_PROCESSED_OUTPUT)

        self.size_dirty = True
        self._size = None
        self.update_size()

        self._fg = Color.rgb(1,1,1)
        self._bg = Color.rgb(0,0,0)
        self.color_mode = "16-color"
        self._cursor_pos = None
        self._show_cursor = None
        self._attr = WORD(0)

        self._termname = "Windows Console"
Exemplo n.º 3
0
def test_color_rgb():
    assert Color.rgb(0.1, 0.2, 0.3) == Color((0.1, 0.2, 0.3))