Learn R Programming

animation (version 1.1-4)

saveSWF: Convert Images to Flash Animations...

Description

Convert Images to Flash Animations This function opens a graphical device first to generate a sequence of images based on expr, then makes use of the commands in `SWF Tools' (png2swf, jpeg2swf, pdf2swf) to convert these images to a single Flash animation.

Usage

saveSWF(expr, interval=1, swfname="movie.swf", dev=c("png", "jpeg",
    "pdf"), filename="Rplot", fmt="%03d", outdir=tempdir(), swftools,
    para=par(no.readonly = TRUE), ...)

Arguments

expr
an expression to generate animations; use either the animation functions (e.g. brownian.motion()) in this package or a custom expression (e.g. for(i in 1:10) plot(runif(10), ylim = 0:1)).
interval
duration between animation frames (unit in seconds)
swfname
file name of the Flash file
dev
character: the graphics device to be used. Three choices are available: png, jpeg and pdf
filename
file name of the sequence of images (`pure' name; without any format or extension)
fmt
a C-style string formatting command, such as `%3d'
outdir
the directory for the animation frames and the Flash file
swftools
the path of `SWF Tools', e.g. C:/swftools. This argument is to make sure that png2swf, jpeg2swf and pdf2swf can be executed correctly. If it is NULL, it should be guaranteed that these co
para
a list: the graphics parameters to be set before plotting; passed to par
...
other arguments passed to the graphical device, such as height and width, ...

Value

  • An integer indicating failure (-1) or success (0) of the converting (refer to system).

References

http://animation.yihui.name/animation:start#create_flash_animations

See Also

saveMovie, system, png, jpeg, pdf

Examples

Run this code
oopt = ani.options(nmax = 50)
# from png
saveSWF(knn.ani(test = matrix(rnorm(16), ncol = 2),
cl.pch = c(16, 2)), 1.5, dev = "png", para = list(mar = c(3,
3, 1, 1.5), mgp = c(1.5, 0.5, 0)), swfname = "kNN.swf")

# from pdf (vector plot!)
ani.options(nmax = 50)
saveSWF(brownian.motion(pch = 21, cex = 5, col = "red", bg = "yellow"),
0.2, "brownian.swf", "pdf", fmt = "")

ani.options(oopt)

Run the code above in your browser using DataLab