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


Python Canvas.blit方法代码示例

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


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

示例1: main

# 需要导入模块: from caca.canvas import Canvas [as 别名]
# 或者: from caca.canvas.Canvas import blit [as 别名]
def main():
    """ Main function. """

    try:
        pig = Canvas(0, 0)
        pig.import_from_memory(STRING, "text")
        cv = Canvas(pig.get_width() * 2, pig.get_height() * 2)
    except CanvasError as err:
        sys.stderr.write("%s\n" % err)
        sys.exit(2)

    cv.blit(0, 0, pig, NullCanvas())
    pig.flip()
    cv.blit(pig.get_width(), 0, pig, NullCanvas())
    pig.flip()
    pig.flop()
    cv.blit(0, pig.get_height(), pig, NullCanvas())
    pig.flop()
    pig.rotate_180()
    cv.blit(pig.get_width(), pig.get_height(), pig, NullCanvas())

    for j in range(0, cv.get_height()):
        for i in range(0, cv.get_width(), 2):
            cv.set_color_ansi(caca.COLOR_LIGHTBLUE + (i + j) % 6,
                              caca.COLOR_DEFAULT)

            a = cv.get_attr(-1, -1)
            cv.put_attr(i, j, a)
            cv.put_attr(i+1, j, a)

    print("%s" % cv.export_to_memory('utf8'))
    cv.rotate_left()
    print("%s" % cv.export_to_memory('utf8'))
开发者ID:Kirkman,项目名称:libcaca,代码行数:35,代码来源:text.py

示例2: test_blit

# 需要导入模块: from caca.canvas import Canvas [as 别名]
# 或者: from caca.canvas.Canvas import blit [as 别名]
 def test_blit(self):
     """ module canvas: Canvas.blit()
     """
     cv1 = Canvas(10, 1)
     cv2 = Canvas(10, 1)
     cv2.put_str(0, 0, "teststring")
     self.assertEqual(0, cv1.blit(0, 0, cv2))
     self.assertEqual("teststring", cv1.export_to_memory("utf8").strip('\n'))
     self.assertRaises(CanvasError, cv1.blit, 0, 0, "abc")
     self.assertRaises(CanvasError, cv1.blit, "a", 0, cv2)
开发者ID:Kirkman,项目名称:libcaca,代码行数:12,代码来源:canvas.py

示例3: test_blit_mask

# 需要导入模块: from caca.canvas import Canvas [as 别名]
# 或者: from caca.canvas.Canvas import blit [as 别名]
 def test_blit_mask(self):
     """ module canvas: Canvas.blit() (with mask)
     """
     cv1 = Canvas(10, 1)
     cv2 = Canvas(10, 1)
     mask = Canvas(10, 1)
     badm = Canvas()
     cv2.put_str(0, 0, "teststring")
     mask.put_str(0, 0, "####")
     self.assertEqual(0, cv1.blit(0, 0, cv2, mask))
     self.assertEqual("test      ", cv1.export_to_memory("utf8").strip("\n"))
     self.assertRaises(CanvasError, cv1.blit, 0, 0, cv2, badm)
开发者ID:Kirkman,项目名称:libcaca,代码行数:14,代码来源:canvas.py

示例4: main

# 需要导入模块: from caca.canvas import Canvas [as 别名]
# 或者: from caca.canvas.Canvas import blit [as 别名]
def main():
    """ Main function. """
    try:
        cv = Canvas(0, 0)
        dp = Display(cv)
    except (CanvasError, DisplayError) as err:
        sys.stderr.write("%s\n" % err)
        sys.exit(2)

    sprite = Canvas(0, 0)
    sprite.set_color_ansi(caca.COLOR_LIGHTRED, caca.COLOR_BLACK)
    sprite.import_from_memory(THE_PIG, "text")
    sprite.set_handle(sprite.get_width()//2, sprite.get_height()//2)

    cv.set_color_ansi(caca.COLOR_WHITE, caca.COLOR_BLUE)
    cv.put_str(0, 0, "Centered sprite")
    cv.blit(cv.get_width()//2, cv.get_height()//2, sprite, NullCanvas())

    dp.refresh()
    dp.get_event(caca.EVENT_KEY_PRESS, Event(), -1)

    sys.exit(0)
开发者ID:graingert,项目名称:libcaca,代码行数:24,代码来源:blit.py


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