# NOT RUN {
#make some images
# }
# NOT RUN {
dir.create(paste0(tempdir(),"/images")) #make a directory to store images
a <- 2
b <- 3
theta <- seq(0,10*pi,0.01)
r <- a + b*theta
df <- data.frame(x=r*cos(theta), y=r*sin(theta)) # Cartesian coords
every.i <- 30
for(i in seq(1,length(theta),30)) {
jpeg(paste0(tempdir(),"/images/image_",sprintf("%03d",which(i==seq(1,length(theta),30))),".jpg"))
with(df[1:i,],plot(x,y,xlim=range(df$x),ylim=range(df$y),col="red"))
dev.off()
}
images.to.video(image.dir=paste0(tempdir(),"/images"),
vid.name="spiral.mp4",out.dir=tempdir(),
frame.rate=5,qual=100,silent=TRUE,overwrite=TRUE)
file.exists(paste0(tempdir(),"/spiral.mp4"))
#clean up
unlink(paste0(tempdir(),"/spiral.mp4"))
unlink(paste0(tempdir(),"/images"),recursive=TRUE)
# }
Run the code above in your browser using DataLab