convertFromDevicePixels {playwith} | R Documentation |
Utilities for working with grobs and viewports in device coordinates.
convertFromDevicePixels(x.px, y.px, unitTo = "native", valueOnly = FALSE) convertToDevicePixels(x, y) inViewport(x.px, y.px, viewport) grobBBDevicePixels(grob, viewport, pad = 2) showGrobsBB(draw = TRUE, gp.box = gpar(col = "yellow", lwd = 5, alpha = 0.2), gp.text = gpar(cex = 0.75, alpha = 0.5))
x.px, y.px |
locations in device coordinates (i.e. pixels, with origin at top-left corner of device). May be vectors. |
unitTo |
the |
valueOnly |
to return values as numeric (native) rather than
|
x, y |
locations in the current viewport (numeric native or
|
viewport |
a viewport name or |
grob |
a |
pad |
number of pixels to expand bounding boxes. |
draw |
whether to draw bounding boxes and grob names. |
gp.box |
graphical parameters for bounding boxes. |
gp.text |
graphical parameters for grob name text. |
Not yet...
convertFromDevicePixels
returns a list with x, y
(units or
numeric) locations in the current viewport.
convertToDevicePixels
returns a list with x, y
(numeric)
locations in pixels from the top-left corner of the device.
inViewport
returns a logical: whether the given pixel location is
inside the given viewport.
grobBBDevicePixels
returns a list with x, y
(numeric)
locations in pixels giving the bounding box of the given grob. The grob
must exist in the given viewport.
showGrobsBB
returns a data.frame
giving information about all
grobs in the current scene.
Felix Andrews felix@nfrac.org
grid.convert
,
grobX
,
grid.ls
,
grid.show.layout
print(xyplot(1:10 ~ 1:10 | c("a", "b"))) vpname <- trellis.vpname("panel", 1, 1) downViewport(vpname) convertToDevicePixels(x = 5:10, y = 5:10) convertToDevicePixels(unit(0, "npc"), unit(0, "npc")) convertFromDevicePixels(x = 100, y = 100) inViewport(x = 100, y = 100, vpname) inViewport(x = c(0, 100), y = c(0, 100), vpname) myGrob <- grid.circle(r = 0.3, name = "myCircle") grobBBDevicePixels(myGrob, vpname) str(showGrobsBB(draw = TRUE))