Exemplo n.º 1
0
 def test_howto_example_invert_region(self):
     """tests the sixth canvas example from howto"""
     test_image = get_image("canvas_6.png")
     o = get_mock_output()
     c = Canvas(o, name=c_name)
     c.text("Hello world", (5, 5))
     c.invert_rect((35, 5, 80, 17))
     assert(imgs_are_equal(c.get_image(), test_image))
Exemplo n.º 2
0
 def test_invert_region_rgb(self):
     """tests that rgb canvas inversion doesn't fail with RGB displays and returns a valid RGB image"""
     test_image = get_image("canvas_6.png")
     o = get_mock_output(mode="RGB")
     c = Canvas(o, name=c_name)
     c.text("Hello world", (5, 5))
     c.invert_rect((35, 5, 80, 17))
     assert (c.get_image().mode == o.device_mode)
     assert (imgs_are_equal(c.get_image(), test_image.convert("RGB")))
Exemplo n.º 3
0
def show(lines):
    if len(lines) < 4:
        max = len(lines)
    else:
        max = 4
    index = values.get_index()
    if index == 1:
        index = 2  # row 3
    c = Canvas(o)
    for n in range(max):
        y = n * char_height
        c.text(lines[n], (0, y), font=font1)
        if n == index and blink.isSet():  # row 0 or 3 && blink
            c.invert_rect(
                (127 - 8, y + char_height - 4, 127, y + char_height - 1))
    c.display()