Timeline¶
The Timeline object is the main object of an animation. It renders frames, video files and loads and saves projects.
- class diplotocus.Timeline(name='Unnamed', fig=None, quiet=False, dpi=200, transparent=False, axis_color='k', noaxis=False, easing=<diplotocus.easings.easeLinear object>, xlim=None, ylim=None, figsize=None)[source]
Create and manage an animation timeline.
- Parameters:
name (str) – the name used for the rendered images folder.
fig (Figure | None) – an existing Figure to plot on. If None, a new Figure will be created.
quiet (bool) – if True, any message will not be printed, and no progress bar will be shown.
dpi (int) – The DPI of the rendered images (higher = better resolution/slower render).
transparent (bool) – if True, the background color of the Figure and axes will be transparent. Can be used to render a transparent video (only compatible with a .mov video file).
axis_color (str) – if True, changes the color of the axes, ticks and labels to the specified color.
noaxis (bool) – if True, hides the axis lines, ticks and labels.
easing (easing) – a global easing to be used if no other easing is specified on an animation.
xlim (tuple | None) – if fig is None, sets the X limits of the created axis.
ylim (tuple | None) – if fig is None, sets the Y limits of the created axis.
Once created, a Timeline is used to render animations of plot objects via Timeline().animate(plot_objects):
- Timeline.animate(plot_objects, easing=None, debug=False)[source]
Render one or more plot objects into the timeline.
To include frames without any changes, you can call Timeline().wait(duration):
- Timeline.wait(duration)[source]
Pause the animation for a number of frames.
- Parameters:
duration (int) – the number of frames to pause the animation for.
To render your animation to a video file, you can call Timeline().save_video(path=None,speed=1,ffmpeg_path='ffmpeg',multialpha=False,prerendered=False,clean=True):
- Timeline.save_video(path=None, speed=1, ffmpeg_path='ffmpeg', multialpha=False, prerendered=False, clean=True)[source]
Render the current timeline to a video file.
- Parameters:
path (str | None) – the path to save the video file to.
speed (float) – by default, animations are rendered at 30fps (frames per second). You can change this by setting the speed. For 60fps videos, choose speed=2.
ffmpeg_path (str) – if ffmpeg is not recognised as is, you can set the path to the ffmpeg executable through this parameter.
multialpha (bool) – when rendering to a transparent .mov video, if you have semi-transparent frames, can be used to get better results.
prerendered (bool) – if save_video() was already called and clean was set to False, image files and the text list file associated still exist. If you want to rerender the video, without having to rerender all the frames, you can set prerendered to true, which will only run the ffmpeg command.
clean (bool) – if True, image files and the text list file associated are deleted after the video has been rendered.