pydistsim.gui.drawing.create_animation

create_animation(sim: Simulation, figsize=None, dpi: int = 100, milliseconds_per_frame: int = 300, frame_limit: int = 2000, reset_on_start: bool = True, **kwargs) FuncAnimation[source]

Create an animation of the simulation.

Example for visualizing in Jupyter Notebook:

anim = create_animation(sim)

video = anim.to_html5_video()

from IPython.display import HTML
HTML(video)

Example for saving as a video file:

from matplotlib.animation import FFMpegFileWriter

moviewriter = FFMpegFileWriter()
anim = draw.create_animation(sim)

anim.save("flood.mp4", writer=moviewriter)
Parameters:
  • sim – Simulation object

  • figsize – figure size

  • dpi – dots per inch

  • milliseconds_per_frame – milliseconds per frame

  • frame_limit – limit of frames, default is 2000

  • reset_on_start – control if the simulation will restart on animation start

  • kwargs – additional keyword arguments to pass to the draw_current_state() function

Returns:

animation object