A curious quirk of the way Indigo works is that it seems unusual to need to find the boundary / bounding box of a rendered element. Usually you are telling something how big it needs to be rather than asking it how big or small it actually is.
Nonetheless, Indigo does have a facility for discovering the dimensions of a scene node called the 'Boundary Locator' which can be found on the
The boundary locator has a few methods on it, but the two main ones are
findBounds finds the bounds of any scene node you give it.
val graphic = Graphic(32, 32, Material.Bitmap(AssetName("my graphic"))) context.boundaryLocator.findBounds(graphic)
<div id="mdoc-html-run1" data-mdoc-js></div>
measureText is used specifically to find the real size of the text in a
TextBox. This is costly as it requires rendering the text with all it's font properties in the background.
val tb = TextBox("hello, world!") context.boundaryLocator.measureText(tb)
<div id="mdoc-html-run2" data-mdoc-js></div>
The fast, the slow, and the unavailable
Measuring the bounds of something is assumed to mean more than just reading it's size property, and takes into account scaling and rotation. This means that measuring the real size of scene entities ranges from being fairly easy to we-won't-even-try hard.
Below is a guide. 'Unavailable' means we cannot sensible work this out for you:
Group|-|X|-|Calculated from the calculated bounds of all child nodes. Can be very expensive!
TextBox|X|-|-|Note that this is the given bounds. Use
measureText to find the real bounds.