Animations are created in 3 steps:
- Initialize an
- Save each frame of the animation with
- Convert the frames to an animated gif with
gif(anim, filename, fps=15)
The convenience macros
@animate simplify this code immensely. See the home page for examples of the short version, or the gr example for the long version.
There are two macros for varying levels of convenience in creating animations:
@gif. The main difference is that
@animate will return an
Animation object for later processing, and
@gif will create an animated gif file (and display it when returned to an IJulia cell).
@gif for simple, one-off animations that you want to view immediately. Use
@animate for anything more complex. Constructing
Animation objects can be done when you need full control of the life-cycle of the animation (usually unnecessary though).
using Plots @userplot CirclePlot @recipe function f(cp::CirclePlot) x, y, i = cp.args n = length(x) inds = circshift(1:n, 1 - i) linewidth --> range(0, 10, length = n) seriesalpha --> range(0, 1, length = n) aspect_ratio --> 1 label --> false x[inds], y[inds] end n = 150 t = range(0, 2π, length = n) x = sin.(t) y = cos.(t) anim = @animate for i ∈ 1:n circleplot(x, y, i) end gif(anim, "anim_fps15.gif", fps = 15)