I'm trying to create a GIF with a text overlay where the overlay will change at a one-second interval. Because of the large number of individual GIFs necessary, I ended up wrapping the image_annotate function (from magick package) in a function to return the result more rapidly. I feel like there might be a way to use Sys.sleep() to delay the function return to every second, but I haven't been able to get it working. TIA if anyone has suggestions I could try.
library(tidyverse)
library(magick)
falls_gif <- image_read('https://media.giphy.com/media/jpxjacGJcdies/giphy.gif')
annotation <- function(x,y){
images = x:y %>% map(~image_annotate(falls_gif[seq(1,15,4)],
paste0("Acre-Feet: ", 2*.x), size=20, color="white"))
return(images)
}
annotation(x=0, y=250)