Skip to main content

renderer

Core functionality to render or draw elements into the screen.

renderer.color

Array of bytes that represents a color used by the rendering functions.

[1]

(field) [1]: number

Red


[2]

(field) [2]: number

Green


[3]

(field) [3]: number

Blue


[4]

(field) [4]: number

Alpha


renderer.conic_bezier

Represent a conic / quadratic bezier curve with a single control point, in the form of { start_x, start_y, cp1_x, cp1_y, end_x, end_y }.

renderer.cubic_bezier

Represent a cubic bezier curve with two control points, in the form of { start_x, start_y, cp1_x, cp1_y, cp2_x, cp2_y, end_x, end_y }.

renderer.font

get_metadata

function renderer.font.get_metadata(font_or_path: string|renderer.font)
-> renderer.font.metadata|renderer.font.metadata[]|nil
2. errmsg: string?

Get a font file metadata. In case of a font group it will return an array of metadata results for each font on the group.


group

function renderer.font.group(fonts: renderer.font[])
-> renderer.font

Combines an array of fonts into a single one for broader charset support, the order of the list determines the fonts precedence when retrieving a symbol from it.


load

function renderer.font.load(path: string, size: number, options?: renderer.fontoptions)
-> renderer.font

Create a new font object.


copy

(method) renderer.font:copy(size?: number, options?: renderer.fontoptions)
-> renderer.font

Clones a font object into a new one.

@param size — Optional new size for cloned font.


get_height

(method) renderer.font:get_height()
-> number

Get the height in pixels that occupies a single character when rendered with this font.


get_path

(method) renderer.font:get_path()
-> string|table<integer, string>

Get the current path of the font as a string if a single font or as an array of strings if a group font.


get_size

(method) renderer.font:get_size()
-> number

Get the current size of the font.


get_width

(method) renderer.font:get_width(text: string, tab_data?: renderer.tab_data)
-> number

Get the width in pixels of the given text when rendered with this font.


set_size

(method) renderer.font:set_size(size: number)

Set a new size for the font.


set_tab_size

(method) renderer.font:set_tab_size(chars: integer)

Set the amount of characters that represent a tab.

@param chars — Also known as tab width.


renderer.font.metadata

Representation of a font metadata.

family

(field) family: string?

fullname

(field) fullname: string?

id

(field) id: string?

monospace

(field) monospace: boolean

Some monospace fonts do not set it to true, do not rely on it too much.


psname

(field) psname: string?

sampletext

(field) sampletext: string?

subfamily

(field) subfamily: string?

tfamily

(field) tfamily: string?

tsubfamily

(field) tsubfamily: string?

version

(field) version: string?

wwsfamily

(field) wwsfamily: string?

wwssubfamily

(field) wwssubfamily: string?

renderer.fontoptions

Represent options that affect a font's rendering.

antialiasing

(field) antialiasing: "grayscale"|"none"|"subpixel"

bold

(field) bold: boolean

hinting

(field) hinting: "full"|"none"|"slight"

italic

(field) italic: boolean

smoothing

(field) smoothing: boolean

strikethrough

(field) strikethrough: boolean

underline

(field) underline: boolean

renderer.normal_point

Represent a point in a poly line, in the form of { x, y }.

renderer.poly_object

Represent all types accepted by the renderer.draw_poly function.

renderer.tab_data

tab_offset

(field) tab_offset: number?

Offset to a previous tab stop


begin_frame

function renderer.begin_frame(window: renwindow)

Tell the rendering system that we want to build a new frame to render.


begin_frame_lua

function

draw_canvas

function renderer.draw_canvas(canvas: canvas, x: integer, y: integer)

Draw a Canvas.


draw_poly

function renderer.draw_poly(poly: integer[][], color: renderer.color)
-> x: number
2. y: number
3. w: number
4. h: number

Draws a filled polygon, consisting of curves and points. The polygon is filled using the non-zero winding rule in clockwise direction.

The function returns the control box of the polygon, which is greater than or equal to the dimensions of the rendered polygon. It is not guaranteed to the exact dimension of the rendered polygon.

@param poly — the lines or curves to draw, up to 65535 points.

@return x — the X coordinate of top left corner of the control box.

@return y — the Y coordinate of the top left corner of the control box.

@return w — the width of the control box.

@return h — the height of the control box.


draw_rect

function renderer.draw_rect(x: number, y: number, width: number, height: number, color: renderer.color)

Draw a rectangle.


draw_rect_lua

function

draw_text

function renderer.draw_text(font: renderer.font, text: string, x: number, y: number, color: renderer.color, tab_data?: renderer.tab_data)
-> x: number

Draw text and return the x coordinate where the text finished drawing.


draw_text_lua

function

end_frame

function renderer.end_frame()

Tell the rendering system that we finished building the frame.


end_frame_lua

function

get_size

function renderer.get_size()
-> width: number
2. height: number

Get the size of the screen area been rendered.


set_clip_rect

function renderer.set_clip_rect(x: number, y: number, width: number, height: number)

Set the region of the screen where draw operations will take effect.


set_clip_rect_lua

function

show_debug

function renderer.show_debug(enable: boolean)

Toggles drawing debugging rectangles on the currently rendered sections of the window to help troubleshoot the renderer.


to_canvas

function renderer.to_canvas(x: integer, y: integer, w: integer, h: integer)
-> canvas: canvas

Copy a portion of the window to a new Canvas.