saveSWF {animation} | R Documentation |
This function opens a graphical device first to generate a sequence of images
based on expr
, then makes use of the commands in SWFTools
(png2swf
, jpeg2swf
, pdf2swf
) to convert these
images to a single Flash animation.
saveSWF(expr, swf.name = "animation.swf", img.name = "Rplot", swftools = NULL, ...)
expr |
an expression to generate animations; use either the animation
functions (e.g. |
img.name |
the base file name of the sequence of images (without any format or extension) |
swf.name |
file name of the Flash file |
swftools |
the path of SWFTools, e.g. ‘C:/swftools’. This argument
is to make sure that |
... |
other arguments passed to |
An integer indicating failure (-1) or success (0) of the converting
(refer to system
).
Please download and install the SWFTools before using this function: http://www.swftools.org
We can also set the path to SWF Tools by ani.options(swftools =
'path/to/swftools')
.
ani.options('ani.type')
can only be one of png
, pdf
and jpeg
.
Also note that PDF graphics can be compressed using qpdf or Pdftk (if
either one is installed and ani.options('qpdf')
or
ani.options('pdftk')
has been set); see qpdf
or
pdftk
.
Yihui Xie
Other utilities: gm.convert
,
im.convert
; saveGIF
,
saveMovie
; saveHTML
;
saveLatex
; saveVideo
## 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; can set the option 'pdftk' to compress ## PDF 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)