#海龟碰到线条就停止了(也是为了bloodfill漫水填充而编的测试程序) import turtle cv = turtle.getcanvas() turtle.shape('circle') turtle.shapesize(0.2) turtle.circle(100) turtle.penup() turtle.sety(50) running = True while running: turtle.fd(1) all_items = cv.find_all() for item in all_items: zt = cv.itemconfig(item)['state'][-1] if zt=='hidden':continue selfitem = turtle.getturtle().turtle._item x1,y1,x2,y2 = cv.bbox(selfitem) ss = cv.find_overlapping(x1,y1,x2,y2) ss = set(ss) ss.remove(selfitem) if ss:running = False x,y = 100,100 cv.create_rectangle(x,y,x,y,outline="red") x,y = 200,100 cv.create_line(x,y,x+1,y+1,width=1,fill="red")
李兴球
李兴球的博客是Python创意编程原创博客
要发表评论,您必须先登录。
发表评论