def video(rw, cyl=False, **aniparams):
R = rw.params.R
Htop = rw.params.Htop
Hbot = rw.params.Hbot
#fig = plt.figure()
#fig.set_size_inches(6, 6)
#ax = plt.axes([0,0,1,1], autoscale_on=False, xlim=(-R, R), ylim=(-H, H))
xlim = (-R, R) if not cyl else (0., R)
ax = plt.axes(xlim=xlim, ylim=(-Hbot, Htop))
#streamlines(rx=R, ry=Htop, Nx=100, Ny=100, maxvalue=None, F=rw.F)
coll = rw.ellipse_collection(ax)
patches = rw.polygon_patches(cyl)
def init():
return ()
def animate(t):
if t == 0:
ax.add_collection(coll)
for p in patches:
ax.add_patch(p)
rw.move_ellipses(coll, cyl=cyl)
return tuple([coll] + patches)
aniparams = dict(dict(interval=10, blit=True, save_count=5000), **aniparams)
ani = animation.FuncAnimation(ax.figure, animate, frames=rw.walk(),
init_func=init, **aniparams)
return ani
评论列表
文章目录