本文整理汇总了Python中caca.canvas.Canvas.import_from_memory方法的典型用法代码示例。如果您正苦于以下问题:Python Canvas.import_from_memory方法的具体用法?Python Canvas.import_from_memory怎么用?Python Canvas.import_from_memory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类caca.canvas.Canvas
的用法示例。
在下文中一共展示了Canvas.import_from_memory方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from caca.canvas import Canvas [as 别名]
# 或者: from caca.canvas.Canvas import import_from_memory [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'))
示例2: main
# 需要导入模块: from caca.canvas import Canvas [as 别名]
# 或者: from caca.canvas.Canvas import import_from_memory [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)