anim_frame() writes a single frame of a vellum_animation to a PNG, SVG
or PDF file: the poster for an animation, its thumbnail, or the moment to
put in print. The frame is drawn exactly as it appears in the animation –
the same frozen scales and colours, the same tween, the same frame
variables in the title – so a poster matches the animation it stands for,
which a separately built static plot (its scales trained on one state)
need not.
Arguments
- filename
Output path;
.png,.svgor.pdf.- animation
A
vellum_animation(fromanimate()).- frame
The frame to save: a whole number from 1 to the number of frames. The default is the frame a reader who asks for reduced motion sees: the last frame when the animation ends on its final state (a reveal,
transition_time(), a non-loopingtransition_states()), else the first.- scale
Resolution multiplier (default 1), as in
render_plot():2doubles the pixels of a PNG at the same layout.
Details
Frames are numbered as in the files anim_save() writes, pauses and rewind
included (see animate()).
Examples
if (FALSE) { # \dontrun{
d <- data.frame(t = rep(1:3, each = 4), g = rep(letters[1:4], 3),
v = c(1, 3, 2, 4, 4, 1, 3, 2, 2, 4, 1, 3))
a <- vplot(d) |>
mark_bar(x = g, y = v, fill = g) |>
transition_states(t, wrap = FALSE) |>
animate()
anim_frame("poster.png", a) # the final state
anim_frame("middle.svg", a, frame = 25)
} # }
