EVOLUTION-MANAGER
Edit File: deviceLoc.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Convert Viewport Location to Device Location</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for deviceLoc {grid}"><tr><td>deviceLoc {grid}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2> Convert Viewport Location to Device Location </h2> <h3>Description</h3> <p>These functions take a pair of unit objects and convert them to a pair of device locations (or dimensions) in inches. </p> <h3>Usage</h3> <pre> deviceLoc(x, y, valueOnly = FALSE) deviceDim(w, h, valueOnly = FALSE) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x, y, w, h</code></td> <td> <p> A unit object. </p> </td></tr> <tr valign="top"><td><code>valueOnly</code></td> <td> <p> A logical indicating. If <code>TRUE</code> then the function does not return a unit object, but rather only the converted numeric values. </p> </td></tr> </table> <h3>Details</h3> <p>These functions differ from the functions like <code>convertX()</code> because they convert from the coordinate systems within a viewport to inches on the device (i.e., from one viewport to another) and because they only deal with pairs of values (locations or dimensions). </p> <p>The functions like <code>convertX()</code> convert between different units within the same viewport and convert along a single dimension. </p> <h3>Value</h3> <p>A list with two components, both of which are unit object in inches (unless <code>valueOnly</code> is <code>TRUE</code> in which case both components are numeric). </p> <h3>Warning</h3> <p>The conversion is only valid for the current device size. If the device is resized then at least some conversions will become invalid. </p> <p>Furthermore, the returned value only makes sense with respect to the entire device (i.e., within the context of the root viewport). </p> <h3>Author(s)</h3> <p> Paul Murrell </p> <h3>See Also</h3> <p><code><a href="unit.html">unit</a></code> </p> <h3>Examples</h3> <pre> ## A tautology grid.newpage() pushViewport(viewport()) deviceLoc(unit(1, "inches"), unit(1, "inches")) ## Something less obvious grid.newpage() pushViewport(viewport(width=.5, height=.5)) grid.rect() x <- unit(1, "in") y <- unit(1, "in") grid.circle(x, y, r=unit(2, "mm")) loc <- deviceLoc(x, y) loc upViewport() grid.circle(loc$x, loc$y, r=unit(1, "mm"), gp=gpar(fill="black")) ## Something even less obvious grid.newpage() pushViewport(viewport(width=.5, height=.5, angle=30)) grid.rect() x <- unit(.2, "npc") y <- unit(2, "in") grid.circle(x, y, r=unit(2, "mm")) loc <- deviceLoc(x, y) loc upViewport() grid.circle(loc$x, loc$y, r=unit(1, "mm"), gp=gpar(fill="black")) </pre> <hr /><div style="text-align: center;">[Package <em>grid</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>