getShape: Compute the shape of an SVG node

Description Usage Arguments Value Author(s) See Also Examples

Description

This function analyzes a given SVG node and attempts to determine the shape of the element. It then returns an object of the corresponding shape class (e.g. Circle, Line, VerticalLine, ...) containing the relevant information about that shape for this element, e.g. the x, y coordinates and the radius for a circle.

Usage

1
getShape(node, d = xmlGetAttr(node, "d"))

Arguments

node

the SVG node

d

the path of the node that draws the shape.

Value

An object of one of the classes derived from the class Shape. These are Circle, Polygon, Polyline, Line, RectangularBoundingBox, VerticalLine and HorizontalLine.

Author(s)

Duncan Temple Lang

See Also

guessSVGShape. This is probably the more appropriate function to use.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
dd = list(a = c(rnorm(100), rnorm(10, 3)), b = rnorm(400))

doc1 = svgPlot(boxplot(dd$a))

pts = getPlotPoints(doc1)
shapes = sapply(pts, SVGAnnotation:::getShape)
sapply(shapes, class)


doc2 = svgPlot(boxplot(dd))

pts2 = getPlotPoints(doc2)
shapes = sapply(pts2, SVGAnnotation:::getShape)
sapply(shapes, class)

duncantl/SVGAnnotation documentation built on May 15, 2019, 5:57 p.m.