コード例 #1
0
 def test_howto_example_drawing_line(self):
     """tests the third canvas example from howto"""
     test_image = get_image("canvas_3.png")
     o = get_mock_output()
     c = Canvas(o, name=c_name)
     c.line((10, 4, "-8", "-4"))
     assert(imgs_are_equal(c.get_image(), test_image))
コード例 #2
0
def get_yes_icon(width=40, height=40):
    o = MockOutput(width, height)
    c = Canvas(o)
    cx, cy = c.get_center()
    c.circle((cx, cy, min(width / 2, height / 2) - 1), fill="white")
    c.line((cx - 15, cy, cx, cy + 15), fill="black", width=5)
    c.line((cx - 1, cy + 15, cx + 10, cy - 12), fill="black", width=4)
    return c.get_image()
コード例 #3
0
 def refresh(self):
     c = Canvas(self.o)
     charwidth = 20
     charheight = 32
     font = c.load_font("Fixedsys62.ttf", charheight)
     pin_width = len(self.pin) * charwidth
     x_offset = (self.o.width - pin_width) / 2
     y_offset = 15
     c.line((x_offset, y_offset + charheight, str(-x_offset),
             y_offset + charheight))
     c.line((x_offset, y_offset + charheight, x_offset,
             y_offset + charheight - 5))
     for x in range(len(self.pin)):
         i = x + 1
         if x in range(len(self.value)):
             c.text("*", (x_offset + charwidth * x, y_offset), font=font)
         c.line((x_offset + charwidth * i, y_offset + charheight,
                 x_offset + charwidth * i, y_offset + charheight - 5))
     self.o.display_image(c.get_image())
コード例 #4
0
ファイル: main.py プロジェクト: shivergard/spacekat
 def test_screen(self):
     # Testing the screen - drawing a "crosshair" to test screen edges and lines
     c = Canvas(self.o)
     c.line((0, 0, 10, 0))
     c.line(("-1", 0, "-10", 0))
     c.line((0, "-1", 10, "-1"))
     c.line(("-1", "-1", "-10", "-1"))
     c.line((0, 0, 0, 10))
     c.line((0, "-1", 0, "-10"))
     c.line(("-1", 10, "-1", 0))
     c.line(("-1", "-1", "-1", "-10"))
     c.line((0, 0, "-1", "-1"))
     c.line((0, "-1", "-1", 0))
     eh = ExitHelper(self.i, ["KEY_ENTER", "KEY_LEFT"]).start()
     c.display()
     sleep(1)
     for x in range(30):
         if eh.do_run():
             if x % 10 == 0:
                 c.invert()
                 c.display()
             sleep(0.1)
         else:
             break
     # Filling the screen (still using the same ExitHelper)
     c = Canvas(self.o)
     for x in range(60):
         if eh.do_run():
             if x % 20 == 0:
                 c.invert()
                 c.display()
             sleep(0.1)
         else:
             break