svg2swf: Convert a sequence of SVG files to SWF file

Description Usage Arguments Details Value Author(s) Examples

View source: R/svg2swf.R

Description

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

Usage

1
2
  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

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.

Value

The name of the generated SWF file if successful.

Author(s)

Yixuan Qiu <yixuan.qiu@cos.name>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## 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)

yixuan/R2SWF-archive documentation built on May 4, 2019, 5:28 p.m.