The Core.Web.Measure
namespace provides tools for measuring the on-screen rendered size of DOM elements and for conversion of non-pixel units to pixels.
To measure the size of a DOM element, a Core.Web.Measure.Bounds
object can be instantiated. The measured element is specified as a constructor argument. The instantiated Bounds
object provides left
, top
, width
and height
integer properties describing the position and size of the element. If the element is not part of the rendered DOM when it is being measured, it will be temporarily added to an off-screen portion of the DOM for measurement, and then returned to its previous state.
The Core.Web.Measure.extentToPixels()
method converts an arbitrary CSS dimension to pixels. It supports source units of inches (in
), centimeters (cm
), millimeters (mm
), points (pt
), picas (pc
) exes, (ex
) and ems (em
).
When Core.Web is initialized, it will draw a rectangle of known size offscreen and measure its size to determine the real pixel conversion factors.