本文整理汇总了Python中ball.Ball.get_bbox方法的典型用法代码示例。如果您正苦于以下问题:Python Ball.get_bbox方法的具体用法?Python Ball.get_bbox怎么用?Python Ball.get_bbox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ball.Ball
的用法示例。
在下文中一共展示了Ball.get_bbox方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Tk
# 需要导入模块: from ball import Ball [as 别名]
# 或者: from ball.Ball import get_bbox [as 别名]
from tkinter import *
from ball import Ball
master = Tk()
canvas = Canvas(master, width = 400, height = 400)
canvas.pack()
canvas. create_rectangle(0, 0, 400, 400, fill ='#ffffff')
ball = Ball((150, 250), (2, -2), 25)
while True:
ball.move()
bbox = ball.get_bbox()
canvas. create_rectangle(0, 0, 400, 400, fill ='#ffffff')
canvas.create_oval(bbox, fill='#000000')
# (same as previous line) canvas.create_oval(bbox[0], bbox[1], bbox[3], bbox[4], fill='#000000')
canvas.after(1000 // 60)
canvas.update()
mainloop()
示例2: test_get_bbox
# 需要导入模块: from ball import Ball [as 别名]
# 或者: from ball.Ball import get_bbox [as 别名]
def test_get_bbox(self):
ball = Ball((40,50), (10,10), 10)
bbox = ball.get_bbox()
self.assertEqual(bbox, (30,40,50,60))
示例3: Tk
# 需要导入模块: from ball import Ball [as 别名]
# 或者: from ball.Ball import get_bbox [as 别名]
from tkinter import *
from ball import Ball
master = Tk()
c = Canvas(master, width = 400, height = 400)
c.pack()
ball = Ball((40, 50), (2, 2), 10)
while True:
ball.move()
c.create_oval(ball.get_bbox(), fill='#ffcc00')
c.after(16)
c.update()
c.delete('all')
mainloop()