convertFromDevicePixels: Utilities for working with grobs and viewports in device...

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Utilities for working with grobs and viewports in device coordinates.

Usage

1
2
3
4
5
6
7
8
9
convertFromDevicePixels(x.px, y.px, unitTo = "native", valueOnly = FALSE)
convertToDevicePixels(x, y)

inViewport(x.px, y.px, viewport)
grobBBDevicePixels(grob, viewport, pad = 2)

grobBoundingBoxes(draw = TRUE,
    gp.box = gpar(col = "yellow", lwd = 5, alpha = 0.2),
    gp.text = gpar(cex = 0.75, alpha = 0.5))

Arguments

x.px, y.px

locations in device coordinates (i.e. pixels, with origin at top-left corner of device). May be vectors.

unitTo

the unit to convert to.

valueOnly

to return values as numeric (native) rather than units.

x, y

locations in the current viewport (numeric native or units). May be vectors.

viewport

a viewport name or vpPath.

grob

a grob.

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.

Details

Not yet...

Value

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.

grobBoundingBoxes returns a data.frame giving information about all grobs in the current scene.

Author(s)

Felix Andrews [email protected]

See Also

grid.convert, grobX, grid.ls, grid.show.layout

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
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(grobBoundingBoxes(draw = TRUE))

11010tianyi/playwith documentation built on May 5, 2019, 10:37 a.m.