R2SWF (version 0.9-2)

svg2swf: Convert a sequence of SVG files to SWF file

Description

Given the file names of a sequence of SVG files, this function could convert them into a Flash file (.swf).

Usage

svg2swf(input, output = "movie.swf", bgColor = "white", interval = 1)

Arguments

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

Value

The name of the generated SWF file if successful.

Details

This function uses the XML package in R and a subset of librsvg (http://librsvg.sourceforge.net/) to parse the SVG file, and uses the Ming library (http://www.libming.org/) to implement the conversion. Currently this function supports SVG files created by svg() in the grDevices package, and CairoSVG() in the Cairo package.

Examples

Run this code
# 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)
}
# }
# NOT RUN {
# }

Run the code above in your browser using DataCamp Workspace