Hero image

Bounding Box

What the code does

Demonstrates how to poll the dimensions of the bounding box for a piece of text. The bounding box is a rectangle which (broadly speaking) is the smallest to enclose a given bit of text (it is in reality a little different from this). However, it is essential to understand this concept if you which to position pieces of text centred upon a given position on the screen. You will see this concept used in many other demos to position text. The code draws a piece of text once in standard mode (bottom left corner of the text bounding box being aligned with the requested text position) and a second time with the text positioned such that the bounding box of the text is centred on the requested text position.

Visualisation

The code

Instagram image Instagram image Instagram image Instagram image Instagram image Instagram image