DrawTextCentered

Draw text horizontally centered at a given X position.

Syntax

Susano.DrawTextCentered(x, y, text, size_px, r, g, b[, a][, fontId]) -> void

Parameters

x, y (number): Center X position and top Y position in pixels.

text (string): The text to render.

size_px (number): Font size in pixels. Pass 0 for the font's default.

r, g, b (number): Color. Accepts 0..1 floats or 0..255 integers (auto-detected).

a (number, optional): Alpha. Default: 1.0.

fontId (number, optional): Font handle from LoadFont/LoadFontFromBuffer.

Return(s)

None

Behavior

Measures the text width, then draws it offset so it is horizontally centered on the X coordinate. Useful for titles, labels, and UI headers.

Example(s)

Susano.BeginFrame()
Susano.DrawTextCentered(960, 50, "Centered Title", 24, 255, 255, 255)
Susano.SubmitFrame()