The R Project SVN R

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
25278 murrell 1
\name{convertNative}
2
\alias{convertNative}
3
\title{ Convert a Unit Object to Native units }
4
\description{
5
  \bold{This function is deprecated in grid version 0.8 and will be
6
    made defunct in grid version 0.9}
7
 
8
  You should use the \code{grid.convert()} function or one of its
9
  close allies instead.
10
 
11
  This function returns a numeric vector containing the specified
12
  x or y locations or dimensions, converted to "user" or "data"
13
  units, relative to the current viewport.
14
}
15
\usage{
16
convertNative(unit, dimension="x", type="location")
17
}
18
\arguments{
19
  \item{unit}{ A unit object. }
20
  \item{dimension}{ Either "x" or "y". }
21
  \item{type}{ Either "location" or "dimension". }
22
}
23
\value{
24
  A numeric vector.
25
}
26
\author{ Paul Murrell }
27
\section{WARNING }{ If you draw objects based on output from these conversion
28
    functions, then resize your device, the objects will be drawn 
29
    incorrectly -- the base R display list will not recalculate these
30
    conversions.  This means that you can only rely on the results of 
31
    these calculations if the size of your device is fixed.} 
32
\seealso{ \code{\link{grid.convert}}, \code{\link{unit}} }
33
 
34
\examples{
35
grid.newpage()
26693 murrell 36
pushViewport(viewport(width=unit(.5, "npc"),
25278 murrell 37
                       height=unit(.5, "npc")))
38
grid.rect()
39
w <- convertNative(unit(1, "inches"))
40
h <- convertNative(unit(1, "inches"), "y")
41
# This rectangle starts off life as 1in square, but if you
42
# resize the device it will no longer be 1in square
43
grid.rect(width=unit(w, "native"), height=unit(h, "native"),
44
          gp=gpar(col="red"))
26693 murrell 45
popViewport(1)
25278 murrell 46
 
47
# How to use grid.convert(), etc instead
48
convertNative(unit(1, "inches")) ==
49
  grid.convertX(unit(1, "inches"), "native", valueOnly=TRUE)
50
convertNative(unit(1, "inches"), "y", "dimension") ==
51
  grid.convertHeight(unit(1, "inches"), "native", valueOnly=TRUE)
52
}
25323 hornik 53
\keyword{ dplot }