as.mask {grid} | R Documentation |
Define either an alpha mask or a luminance mask, based on a grob.
as.mask(x, type=c("alpha", "luminance"))
x |
A grob. |
type |
The type of mask. |
A mask may be specified for a viewport either directly as a grob or using this function. In the former case, the result is an alpha mask. This function allows the user to define a luminance mask instead.
Not all graphics devices support masks and those that do
may only support one type of mask: for example
xfig
and pictex
do not support masks and
Cairo-based devices only support alpha masks.
A "GridMask"
object.
Paul Murrell
## NOTE: on devices without support for masks normal line segments
## will be drawn
grid.newpage()
## Alpha mask
grid.segments(y0=1, y1=0, gp=gpar(col=2, lwd=100))
pushViewport(viewport(mask=circleGrob(gp=gpar(fill=rgb(0,0,0,.5)))))
grid.segments(gp=gpar(col=3, lwd=100))
grid.newpage()
## Luminance mask
grid.segments(y0=1, y1=0, gp=gpar(col=2, lwd=100))
pushViewport(viewport(mask=as.mask(circleGrob(gp=gpar(fill="grey50")),
"luminance")))
grid.segments(gp=gpar(col=3, lwd=100))