当前位置: 首页>>代码示例>>Python>>正文


Python canvas.Canvas类代码示例

本文整理汇总了Python中caca.canvas.Canvas的典型用法代码示例。如果您正苦于以下问题:Python Canvas类的具体用法?Python Canvas怎么用?Python Canvas使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Canvas类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_draw_thin_triangle

 def test_draw_thin_triangle(self):
     """ module canvas: Canvas.draw_thin_triangle()
     """
     cv = Canvas(10, 10)
     self.assertEqual(0, cv.draw_thin_triangle(0, 0, 2, 2, 4, 0))
     self.assertRaises(CanvasError, cv.draw_thin_triangle,
                       0, 0, 2, 2, 4, '#')
开发者ID:Kirkman,项目名称:libcaca,代码行数:7,代码来源:canvas.py

示例2: test_fill_ellipse

 def test_fill_ellipse(self):
     """ module canvas: Canvas.fill_ellipse()
     """
     cv = Canvas(10, 10)
     self.assertEqual(0, cv.fill_ellipse(5, 5, 3, 3, '#'))
     self.assertRaises(CanvasError, cv.fill_ellipse, 0, 0, 3, '#', '#')
     self.assertRaises(CanvasError, cv.fill_ellipse, 0, 0, 3, 3, 0)
开发者ID:Kirkman,项目名称:libcaca,代码行数:7,代码来源:canvas.py

示例3: test_fill_box

 def test_fill_box(self):
     """ module canvas: Canvas.fill_box()
     """
     cv = Canvas(10, 10)
     self.assertEqual(0, cv.fill_box(0, 0, 2, 2, '#'))
     self.assertRaises(CanvasError, cv.fill_box, 0, 0, 2, '#', '#')
     self.assertRaises(CanvasError, cv.fill_box, 0, 0, 2, 2, 0)
开发者ID:Kirkman,项目名称:libcaca,代码行数:7,代码来源:canvas.py

示例4: test_remove_dirty_rect

 def test_remove_dirty_rect(self):
     """ module canvas: Canvas.remove_dirty_rect()
     """
     cv = Canvas(10, 10)
     cv.add_dirty_rect(4, 4, 2, 2)
     self.assertEqual(0, cv.remove_dirty_rect(4, 4, 2, 2))
     self.assertRaises(CanvasError, cv.remove_dirty_rect, 11, 11, 20, 20)
开发者ID:Kirkman,项目名称:libcaca,代码行数:7,代码来源:canvas.py

示例5: test_draw_circle

 def test_draw_circle(self):
     """ module canvas: Canvas.draw_circle()
     """
     cv = Canvas(10, 10)
     self.assertEqual(0, cv.draw_circle(5, 5, 3, '#'))
     self.assertRaises(CanvasError, cv.draw_circle, 0, 0, '#', '#')
     self.assertRaises(CanvasError, cv.draw_circle, 0, 0, 3, 0)
开发者ID:Kirkman,项目名称:libcaca,代码行数:7,代码来源:canvas.py

示例6: test_draw_thin_line

 def test_draw_thin_line(self):
     """ module canvas: Canvas.draw_thin_line()
     """
     cv = Canvas(10, 1)
     cv.draw_thin_line(0, 0, 10, 1)
     self.assertEqual("-" * 10, cv.export_to_memory("utf8").strip('\n'))
     self.assertRaises(CanvasError, cv.draw_thin_line, 0, "a", 10, 1)
开发者ID:Kirkman,项目名称:libcaca,代码行数:7,代码来源:canvas.py

示例7: test_enable_dirty_rect

 def test_enable_dirty_rect(self):
     """ module canvas: Canvas.enable_dirty_rect()
     """
     cv = Canvas()
     self.assertRaises(CanvasError, cv.enable_dirty_rect)
     cv.disable_dirty_rect()
     self.assertEqual(0, cv.enable_dirty_rect())
开发者ID:Kirkman,项目名称:libcaca,代码行数:7,代码来源:canvas.py

示例8: main

def main():
    """ Main function. """


    if len(sys.argv) < 3:
        sys.stderr.write("Usage: %s <figfont file> <word>\n" \
                            % os.path.basename(sys.argv[0]))
        sys.exit(2)

    try:
        cv = Canvas(0, 0)
    except CanvasError as err:
        sys.stderr.write("%s\n" % err)
        sys.exit(2)

    if cv.set_figfont(sys.argv[1]):
        sys.stderr.write("Could not open font...\n")
        sys.exit(2)

    if sys.version_info[0:2] >= (3,0):
        word = sys.argv[2]
    else:
        word = codecs.decode(sys.argv[2], "utf8")
    for c in word:
        cv.put_figchar(c)

    sys.stderr.write(cv.export_to_memory("utf8"))
开发者ID:Kirkman,项目名称:libcaca,代码行数:27,代码来源:figfont.py

示例9: test_draw_thin_polyline

 def test_draw_thin_polyline(self):
     """ module canvas: Canvas.draw_thin_polyline()
     """
     cv = Canvas(10, 10)
     self.assertEqual(0, cv.draw_thin_polyline([(0, 0), (2, 2),
                                                (5, 2), (0, 0)]))
     self.assertRaises(CanvasError, cv.draw_thin_polyline, [])
     self.assertRaises(CanvasError, cv.draw_thin_polyline, [0, 1, 2, 4])
开发者ID:Kirkman,项目名称:libcaca,代码行数:8,代码来源:canvas.py

示例10: test_set_handle

 def test_set_handle(self):
     """ module canvas: Canvas.set_handle()
     """
     cv = Canvas(10, 5)
     self.assertEqual(0, cv.set_handle(3, 3))
     self.assertEqual((3, 3), (cv.get_handle_x(), cv.get_handle_y()))
     self.assertRaises(CanvasError, cv.set_handle, "a", 1)
     self.assertRaises(CanvasError, cv.set_handle, 1, "a")
开发者ID:Kirkman,项目名称:libcaca,代码行数:8,代码来源:canvas.py

示例11: test_gotoxy

 def test_gotoxy(self):
     """ module canvas: Canvas.gotoxy()
     """
     cv = Canvas(10, 10)
     cv.gotoxy(5, 5)
     self.assertEqual((5, 5), (cv.wherex(), cv.wherey()))
     self.assertRaises(CanvasError, cv.gotoxy, "a", 9)
     self.assertRaises(CanvasError, cv.gotoxy, 9, "a")
开发者ID:Kirkman,项目名称:libcaca,代码行数:8,代码来源:canvas.py

示例12: test_set_size

    def test_set_size(self):
        """ module canvas: Canvas.set_size()
        """
        cv = Canvas(0, 0)
        cv.set_size(1234, 1001)

        self.assertEqual((1234, 1001), (cv.get_width(), cv.get_height()))
        self.assertRaises(CanvasError, cv.set_size, "a", 12)
        self.assertRaises(CanvasError, cv.set_size, 12, "a")
开发者ID:Kirkman,项目名称:libcaca,代码行数:9,代码来源:canvas.py

示例13: test_fill_triangle

 def test_fill_triangle(self):
     """ module canvas: Canvas.fill_triangle()
     """
     cv = Canvas(10, 10)
     self.assertEqual(0, cv.fill_triangle(0, 0, 2, 2, 4, 0, '#'))
     self.assertRaises(CanvasError, cv.fill_triangle,
                       0, 0, 2, 2, 4, '#', '#')
     self.assertRaises(CanvasError, cv.fill_triangle,
                       0, 0, 2, 2, 4, 0, 0)
开发者ID:Kirkman,项目名称:libcaca,代码行数:9,代码来源:canvas.py

示例14: test_put_char

 def test_put_char(self):
     """ module canvas: Canvas.put_char()
     """
     cv = Canvas(10, 1)
     self.assertEqual(1, cv.put_char(0, 0, "z"))
     self.assertEqual(1, cv.put_char(1, 0, "é"))
     self.assertEqual("z", cv.get_char(0, 0))
     self.assertEqual("é", cv.get_char(1, 0))
     self.assertRaises(CanvasError, cv.put_char, "a", 1, 2)
     self.assertRaises(CanvasError, cv.put_char, "a", 1, "b")
开发者ID:Kirkman,项目名称:libcaca,代码行数:10,代码来源:canvas.py

示例15: test_printf

 def test_printf(self):
     """ module canvas: Canvas.printf()
     """
     word1, word2 = "test", "string"
     cv = Canvas(10, 1)
     self.assertEqual(10, cv.printf(0, 0, "%s%s", word1, word2))
     liststring = []
     for i in range(0, 10):
         liststring.append(cv.get_char(i, 0))
     self.assertEqual("teststring", "".join(liststring))
     self.assertRaises(CanvasError, cv.printf, 0, 0, 111)
     self.assertRaises(CanvasError, cv.printf, 0, "z", "abc %s", "def")
开发者ID:Kirkman,项目名称:libcaca,代码行数:12,代码来源:canvas.py


注:本文中的caca.canvas.Canvas类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。