The R package ‘easySVG’ can generate SVG elements easily.
This package is an easy SVG elements generator. It can easily generate svg elements such as rect, line, circle, ellipse, polygon polyline, text and make group. Also, it can output svg elements into a svg file.
# Install the cutting edge development version from GitHub:
# install.packages("devtools")
::install_github("ytdai/easySVG") devtools
R CMD INSTALL pkg
library(easySVG)
.1 <- line.svg(x1 = 50, y1 = 20, x2 = 150, y2 = 20)
linemessage(line.1)
.2 <- line.svg(x1 = 50, y1 = 40, x2 = 150, y2 = 40, stroke = "red", stroke.width = 3)
linemessage(line.2)
.1 <- rect.svg(x = 50, y = 60, width = 100, height = 10, fill = "blue")
rectmessage(rect.1)
.2 <- rect.svg(x = 50, y = 80, width = 100, height = 5, fill = "yellow", stroke = "none")
rectmessage(rect.2)
.1 <- circle.svg(cx = 80, cy = 100, r = 10, fill = "blue")
circlemessage(circle.1)
.2 <- circle.svg(cx = 120, cy = 100, r = 5, fill = "red", stroke = "none")
circlemessage(circle.2)
.1 <- ellipse.svg(cx = 100, cy = 120, rx = 20, ry = 5, fill = "blue")
ellipsemessage(ellipse.1)
<- matrix(c( 50, 100, 120, 140, 135, 145), nrow = 3, ncol = 2)
points
.1 <- polygon.svg(points = points, fill = "green", stroke = "none")
polygonmessage(polygon.1)
<- matrix(c( 50, 100, 120, 160, 155, 165), nrow = 3, ncol = 2)
points
.1 <- polyline.svg(points = points)
polylinemessage(polyline.1)
<- c("line.1", "line.2", "rect.1 - rect.2",
text "circle.1", "circle.2", "ellipse.1",
"polygon.1", "polyline.1")
<- lapply(1:length(text),
text.elements function(x) get.text.svg(x = 10, y = 20*x, text.content = text[x], font.size = 6))
<- unlist(text.elements)
text.elements
<- list(line.1, line.2, rect.1, rect.2,
content .1, circle.2, ellipse.1,
circle.1, polyline.1, text.elements)
polygonpack.svg(width = 200, height = 200, pack.content = content, output.svg.name = "eleSVG.svg")