R2SWF (version 0.9-9)

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)

Value

The name of the generated SWF file if successful.

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

Author

Yixuan Qiu <https://statr.me>

Details

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.

Examples

Run this code
if (FALSE) {
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)
}
}

Run the code above in your browser using DataLab