Skip to contents

Renders successive generation states and writes them to an animated GIF. The optional magick package is required only when this function is called.

Usage

animate_maze(maze, output_file = "maze-animation.gif", fps = 10,
  every = 1L, width = 800L, height = 800L, wall_width = 3,
  progress = interactive())

Arguments

maze

A maze object returned by generate_maze().

output_file

Destination path for the GIF.

fps

Frames per second.

every

Render every nth generation step. Increase this for large mazes.

width, height

Frame dimensions in pixels.

wall_width

Width of wall lines.

progress

Show a progress bar in interactive sessions.

Value

The normalized output path, invisibly.

Examples

if (requireNamespace("magick", quietly = TRUE)) {
  maze <- generate_maze(5, 5, seed = 42)
  animate_maze(maze, tempfile(fileext = ".gif"), every = 2)
}
#> Animation saved to '/tmp/RtmpFI2xvQ/file19bf77c0e2a3.gif'.