isInside: Determine if one SVG object is physically located within...

Description Usage Arguments Value Author(s) See Also Examples

Description

This function and its methods allow us to query whether the bounding box or area of one SVG element is inside that of another.

Usage

1
isInside(obj, host)

Arguments

obj

the object whose area might be inside the bounding box of host

host

the element whose area might enclose that of obj

Value

A logical value with TRUE indicating obj is "inside" host, in a physical sense on the SVG display.

Author(s)

Duncan Temple Lang

See Also

getBoundingBox isAnnotationGroup getGeneralPath

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
doc = svgPlot({
           plot(1:10, pch = 21, fg = c("red"), bg = "lightgrey")

           points(1:10, pch = '+')

           abline(v = c(3, 7), col = 'blue', lty = 3)
           abline(h = c(3, 7, 9), col = 'lightgray', lty = 2)           
        })
g = xmlRoot(doc)[["g"]][[2]]
rr = getPlotRegionNodes(doc)

xmlSApply(rr[[2]], isInside, rr[[1]])

  # Compute the bounding box for the potential host/container
  # just once and pass it to each call to avoid it being computed each time.
 bb = getBoundingBox(rr[[1]])
 xmlSApply(rr[[2]], isInside, bb)

## Not run: 
    # no method for this yet.
  # Check if the first + is inside the first circle.
 isInside(rr[[2]][[1]], rr[[1]][[1]])

## End(Not run)

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