convertScreenUnits {imageUtilities} | R Documentation |
Attempt to convert between npc, inches, and pixels on the screen.
convertScreenUnits(value, from, to, type = c("width", "height"))
value |
value to convert |
from |
unit to convert from. See Details. |
to |
unit to convert to. See Details. |
type |
either 'width' or 'height'. Only of use for 'npc' conversions – whether you want to return a fraction of the height or of the width. |
The available units are:
Inches
Normalised Parent Coordinates: the entire monitor has dimensions (1,1).
pixels
** The conversions are rough only and not exact! Also, 'npc' conversions may screw up with dual monitor! **
The conversion between pixels and inches uses
imageUtilities.option('ppi')
(pixels per inch),
which is default 96.
The conversion between pixels or inches and screen size
uses the function getScreenResolution
,
which doesn't always work. If the code is unable to
return the screen resolution, a default value of
imageUtilities.option('default.screen.resolution')
is used (currently 1280 x 1024).
the converted unit
Other units: getPPI
,
getScreenResolution
, unitType
# convert 7 screen inches to screen pixels (approx). convertScreenUnits(7,from='inches',to='pixels') # find out what half the screen width is in inches convertScreenUnits(.5,from='npc',to='inches',type='width') # find out what fraction of the screen height 2 inches is. convertScreenUnits(2,from='inches',to='npc',type='height')