Description Usage Arguments Value Author(s) See Also Examples
This function and its methods allow us to query whether the bounding box or area of one SVG element is inside that of another.
1 | isInside(obj, host)
|
obj |
the object whose area might be inside the bounding box of |
host |
the element whose area might enclose that of |
A logical value with TRUE
indicating obj
is "inside" host
, in a physical sense on the SVG display.
Duncan Temple Lang
getBoundingBox
isAnnotationGroup
getGeneralPath
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.