Learn R Programming

animation (version 2.0-0)

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, img.name = "Rplot", swf.name = "animation.swf", 
    swftools, ...)

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)).
img.name
file name of the sequence of images (`pure' name; without any format or extension)
swf.name
file name of 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
...
other arguments passed to ani.options, e.g. ani.height and ani.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, saveLatex, saveHTML, system, png, jpeg, pdf

Examples

Run this code
## from png to swf
saveSWF({
    par(mar = c(3, 3, 1, 1.5), mgp = c(1.5, 0.5, 0))
    knn.ani(test = matrix(rnorm(16), ncol = 2), cl.pch = c(16, 
        2))
}, swf.name = "kNN.swf", interval = 1.5, nmax = ifelse(interactive(), 
    40, 2))

## from pdf (vector plot) to swf
saveSWF({
    brownian.motion(pch = 21, cex = 5, col = "red", bg = "yellow")
}, swf.name = "brownian.swf", interval = 0.2, nmax = 30, ani.dev = "pdf", 
    ani.type = "pdf", ani.height = 6, ani.width = 6)

Run the code above in your browser using DataLab