Render API

Constants

RR_TOP_LEFT
RR_TOP_RIGHT
RR_BOTTOM_LEFT
RR_BOTTOM_RIGHT

Rectangle corner rounding flags (bitmask), used with rounding_flags in rect functions.

TE_NONE
TE_OUTLINE
TE_SHADOW
TE_GLOW

Text effects used by draw_text.


Viewport

w, h = get_view()
scale = get_view_scale()
fps = get_fps()
  • get_view() — returns the current viewport width and height in pixels.

  • get_view_scale() — returns a reference scale factor (useful for DPI-aware sizes).

  • get_fps()


Shapes

Rectangle (outline)

Draws a rounded rectangle outline.


Rectangle (filled)

Draws a filled rounded rectangle.


Line

Draws a line from (x1, y1) to (x2, y2).


Arc

Draws an arc or pie-slice centered at (cx, cy).


Circle

Draws a circle centered at (cx, cy).

  • If filled == true, draws a filled circle.

  • Otherwise draws an outlined circle.


Triangle

Draws a triangle using the three points (ax, ay), (bx, by), (cx, cy).


Polygon

  • xy_pairs — Lua table of floats: { x1, y1, x2, y2, x3, y3, ... }.

  • count_pairs — optional; if nil or 0, uses the whole table.

Draws a polyline or filled polygon.


Four-Corner Gradient

Draws a rectangle with independent colors per corner:

  • top-left: (tlr, tlg, tlb, tla)

  • top-right: (trr, trg, trb, tra)

  • bottom-left: (blr, blg, blb, bla)

  • bottom-right: (brr, brg, brb, bra)


Bitmaps

Create bitmap

  • data — Lua table of uint8 values (byte buffer).

  • Returns a handle bmp that can be passed to draw_bitmap.

  • Returns 0 on failure.


Draw bitmap

Draws a bitmap tinted with color (r, g, b, a).

  • bmp — handle returned by create_bitmap.

  • rounded — if true, draws with rounded corners.


Fonts & Text

Built-in fonts

Returns a handle to a default font at a given size.


Create font from file

  • path — filesystem path or font name.

  • size — font size in pixels.

  • anti_aliasedtrue for smooth text, false for pixel-style rendering (boolean).

  • load_colortrue to enable color glyphs (emoji / color fonts), false for standard monochrome glyphs (boolean).

  • Returns a font handle or 0 on failure.

The function searches for fonts inside the API directory (e.g. verdana_custom.ttf, fonts/verdana_custom.ttf) and may fall back to system font locations. If a font name matches a system font, that one may be loaded instead— use unique names to prevent conflicts.


Create font from memory

  • label — name/tag for the font (string).

  • size — font size in pixels.

  • buf — Lua table of uint8 values (font binary data).

  • anti_aliasedtrue for smooth text, false for pixel-style rendering (boolean).

  • load_colortrue to enable color glyphs (emoji / color fonts), false for standard monochrome glyphs (boolean).

  • Returns a font handle or 0 on failure.


Draw text

  • text — string to draw.

  • (r, g, b, a) — text color.

  • font — font handle.

  • effect — one of TE_NONE, TE_OUTLINE, TE_SHADOW, TE_GLOW.

  • (er, eg, eb, ea) — effect color (e.g. shadow/outline color).

  • effect_amount — intensity scalar.


Text metrics

  • get_text_size — returns width/height of the rendered text.

  • get_char_advance — returns advance width for a single character (wchar32).


Clipping

  • clip_push — pushes a rectangular clip region.

  • clip_pop — restores the previous clip region.

All drawing while a clip is active is restricted to the specified rectangle.


Example

This draws a centered rounded panel and a title text using the Lua Render API.

Last updated