本文整理匯總了Python中caca.canvas.Canvas.fill_box方法的典型用法代碼示例。如果您正苦於以下問題:Python Canvas.fill_box方法的具體用法?Python Canvas.fill_box怎麽用?Python Canvas.fill_box使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類caca.canvas.Canvas
的用法示例。
在下文中一共展示了Canvas.fill_box方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_fill_box
# 需要導入模塊: from caca.canvas import Canvas [as 別名]
# 或者: from caca.canvas.Canvas import fill_box [as 別名]
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)
示例2: main
# 需要導入模塊: from caca.canvas import Canvas [as 別名]
# 或者: from caca.canvas.Canvas import fill_box [as 別名]
def main():
""" Main function. """
try:
cv = Canvas(0, 0)
except CanvasError as err:
sys.stderr.write("%s\n" % err)
sys.exit(2)
for idx in range(1, 200):
cv.create_frame(idx)
sys.stderr.write("canvas created, size is %dx%d\n" \
% (cv.get_width(), cv.get_height()))
cv.set_size(150, 80)
sys.stderr.write("canvas expanded, size is %dx%d\n" \
% (cv.get_width(), cv.get_height()))
for idx in range(0, 16):
cv.set_frame(idx)
cv.set_color_ansi(caca.COLOR_WHITE, idx)
cv.fill_box(0, 0, 40, 15, ':')
cv.set_color_ansi(caca.COLOR_WHITE, caca.COLOR_BLUE)
cv.put_str((idx * 5) // 2, idx, "カカ")
cv.set_color_ansi(caca.COLOR_DEFAULT, caca.COLOR_TRANSPARENT)
cv.set_size(41, 16)
sys.stderr.write("canvas shrinked, size is %dx%d\n" \
% (cv.get_width(), cv.get_height()))
try:
dp = Display(cv)
except DisplayError as err:
sys.stderr.write("%s\n" % err)
sys.exit(2)
dp.set_time(50000)
sys.stderr.write("display attached, size is %dx%d\n" \
% (cv.get_width(), cv.get_height()))
n = 0
while not dp.get_event(caca.EVENT_KEY_PRESS, Event(), 0):
cv.set_frame(n % 16)
dp.refresh()
n += 1