svg2swf | R Documentation |
Given the file names of a sequence of SVG files, this function could convert them into a Flash file (.swf).
svg2swf(input, output = "movie.swf", bgColor = "white", interval = 1)
input |
the file names of the SVG files to be converted |
output |
the name of the output SWF file |
bgColor |
background color of the output SWF file |
interval |
the time interval (in seconds) between animation frames |
This function uses the XML package in R and a subset of librsvg
(https://wiki.gnome.org/action/show/Projects/LibRsvg)
to parse the SVG file, and
uses the Ming library (https://github.com/libming/libming) to
implement the conversion. Currently this function supports SVG files
created by svg()
in the grDevices
package, and CairoSVG()
in the
Cairo package.
The name of the generated SWF file if successful.
Yixuan Qiu <https://statr.me>
## Not run: if(capabilities("cairo")) { olddir = setwd(tempdir()) svg("Rplot%03d.svg", onefile = FALSE) set.seed(123) x = rnorm(5) y = rnorm(5) for(i in 1:100) { plot(x <- x + 0.1 * rnorm(5), y <- y + 0.1 * rnorm(5), xlim = c(-3, 3), ylim = c(-3, 3), col = "steelblue", pch = 16, cex = 2, xlab = "x", ylab = "y") } dev.off() output = svg2swf(sprintf("Rplot%03d.svg", 1:100), interval = 0.1) swf2html(output) setwd(olddir) } ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.