TextBufferBounds.centerX

Finds the relative center point on the X axis, optionally taking into account the width of another object (e.g. text).

struct TextBufferBounds
pure
size_t
centerX
(
const size_t width = 0
)

Parameters

width size_t

The optional width to take into account.

Return Value

Type: size_t

The relative center X position, optionally offset by width.

Examples

auto bounds = TextBufferBounds(0, 0, 10, 0);
assert(bounds.centerX == 5);
assert(bounds.centerX(2) == 4);
assert(bounds.centerX(5) == 2);

bounds.left = 20000;
assert(bounds.centerX == 5); // centerX provides a relative point, not absolute.

Meta