Learn R Programming

stopmotion (version 0.1.0)

preview: Preview an animation

Description

Converts a stack of frames into an animated GIF for display, with each frame's index and label overlaid as text. In an interactive session the animation opens in the system viewer; in a knitr/Quarto document it is embedded as an inline animated GIF. Wraps magick::image_animate.

Usage

preview(images, fps = 10, loop = 0, frames = NULL, label = TRUE)

Value

a magick-image object containing the animated sequence.

Arguments

images

an object of class magick-image to modify

fps

playback speed in frames per second. Must be a positive integer divisor of 100, because GIF delay is stored in hundredths of a second (delay = 100 / fps). Valid values: 1, 2, 4, 5, 10, 20, 25, 50, 100. Defaults to 10.

loop

a non-negative integer giving the number of times the animation loops. 0 (the default) means loop forever.

frames

integer vector of frame indices to duplicate. Defaults to NULL, which duplicates all frames.

label

logical. Whether to overlay the frame index and label on each frame. Defaults to TRUE.

Examples

Run this code
# \donttest{
  dino_dir <- system.file("extdata", package = "stopmotion")
  images <- read(dir = dino_dir)
  preview(images)
  preview(images, fps = 5)
  preview(images, label = FALSE)
# }

Run the code above in your browser using DataLab