def panimate(ax, dt, pcoll, patches, boundaries, **kwargs):
particles = pcoll.P
coll = ellipse_collection(ax, particles)
def init():
return ()
#ax.clear()
#ax.add_patch(rect)
#return (rect, )
def animate(i):
if i == 0:
for patch in patches:
ax.add_patch(patch)
ax.add_collection(coll)
else:
move(particles, dt, boundaries)
xy = np.array([p.x[::2].flatten() for p in particles])
coll.set_offsets(xy)
return tuple(patches + [coll])
kwargs = dict(dict(frames=1800, interval=10, blit=True), **kwargs)
ani = animation.FuncAnimation(ax.figure, animate, init_func=init, **kwargs)
return ani
评论列表
文章目录