Skip to content

render

Functions

screen_size

render.screen_size(): vec2_t


setup_font

render.setup_font(filename: string, size: number, flags?: number): font_t

Name Type Description
filename string Path to the font
size number Font size
flags number Optional. Font flags

Warning

If you specify a font that does not exist, return value will be nil.

Example
1
2
3
4
local font = render.setup_font("C:/Windows/Fonts/verdana.ttf", 32, 0)
register_callback("paint", function()
    render.text("hello from nixware lua api!", font, vec2_t.new(100, 100), color_t.new(1, 1, 1, 1))
end)

calc_text_size

render.calc_text_size(text: string, font: font_t, size?: number): vec2_t

Name Type Description
text string Text size of which will be calculated
font font_t Font object
size number Optional. Font size

Warning

If you specify a font that does not exist, return value will be nil.


world_to_screen

render.world_to_screen(pos: vec3_t): vec3_t

Name Type Description
pos vec3_t World position

Warning

If world position is not on the screen, return value will be nil.

Example
1
2
3
4
5
6
register_callback("paint", function()
    local w2s = render.world_to_screen(vec3_t.new(0, 0, 0))
    if w2s then
        render.circle_fade(w2s, 20, color_t.new(1, 0.25, 0.25, 0.5), color_t.new(0, 0, 0, 1))
    end
end)

Draw functions

text

render.text(text: string, font: font_t, pos: vec2_t, color?: color_t, size?: number)

Name Type Description
text string Text to render
font font_t Font object, or 0 = default font, or 1 = pixel font
pos vec2_t Position of where text will be rendered
color color_t Optional. Text color
size number Optional. Text size

line

render.line(from: vec2_t, to: vec2_t, color: color_t, thickness?: number)

Name Type Description
from vec2_t Start position of the line
to vec2_t End position of the line
color color_t Color of the line
thickness number Optional. Thickness of the line

rect

render.rect(from: vec2_t, to: vec2_t, color: color_t, rounding?: number, thickness?: number)

Name Type Description
from vec2_t Start position of the rectangle
to vec2_t End position of the rectangle
color color_t Color of the rectangle
rounding number Optional. Rounding of the rectangle
thickness number Optional. Thickness of the rectangle

rect_filled

render.rect_filled(from: vec2_t, to: vec2_t, color: color_t, rounding?: number)

Name Type Description
from vec2_t Start position of a rectangle
to vec2_t End position of the rectangle
color color_t Color of the rectangle
rounding number Optional. Rounding of the rectangle

rect_filled_fade

render.rect_filled_fade(from: vec2_t, to: vec2_t, col_upr_left: color_t, col_upr_right: color_t, col_bot_right: color_t, col_bot_left: color_t)

Name Type Description
from vec2_t Start position of a rectangle
to vec2_t Font object
col_upr_left color_t Color of the top left corner
col_upr_right color_t Color of the top right corner
col_bot_right color_t Color of the bottom right corner
col_bot_left color_t Color of the bottom left corner

circle

render.circle(pos: vec2_t, radius: number, segments: number, color: color_t, thickness?: number)

Name Type Description
pos vec2_t Position of the circle
radius number Radius of the circle
segments number Count of the circle segments
color color_t Color of the circle
thickness number Optional. Thickness of the circle

circle_filled

render.circle_filled(pos: vec2_t, radius: number, segments: number, color: color_t)

Name Type Description
pos vec2_t Position of the circle
radius number Radius of the circle
segments number Count of the circle segments
color color_t Color of the circle

circle_fade

render.circle_fade(pos: vec2_t, radius: number, color_in: color_t, color_out: color_t)

Name Type Description
pos vec2_t Position of the circle
radius number Radius of the circle
color_in color_t Color of the center of the circle
color_out color_t Color of the edge of the circle

filled_polygon

render.filled_polygon(points: vec2_t[], color: color_t)

Name Type Description
points vec2_t[] Array of screen positions
color color_t Color of the polygon

poly_line

render.poly_line(points: vec2_t[], color: color_t)

Name Type Description
points vec2_t[] Array of screen positions
color color_t Color of the polyline

push_clip_rect

render.push_clip_rect(from: vec2_t, to: vec2_t, intersect_with_current_clip_rect?: boolean)

Name Type Description
from vec2_t Start position of the clip rect
to vec2_t End position of the clip rect
intersect_with_current_clip_rect boolean Optional. Allow intersections with other clips

pop_clip_rect

render.pop_clip_rect()


World draw functions

circle_3d

render.circle_3d(pos: vec3_t, radius: number, color: color_t, thickness?: number, normal?: vec3_t)

Name Type Description
pos vec3_t Position of the circle
radius number Radius of the circle
color color_t Color of the circle
thickness number Optional. Thickness of the circle
normal vec3_t Optional. Rotation of the circle

circle_filled_3d

render.circle_filled_3d(pos: vec3_t, radius: number, color: color_t, normal?: vec3_t)

Name Type Description
pos vec3_t Position of the circle
radius number Radius of the circle
color color_t Color of the circle
normal vec3_t Optional. Rotation of the circle

circle_fade_3d

render.circle_fade_3d(pos: vec3_t, radius: number, color_in: color_t, color_out: color_t, normal?: vec3_t)

Name Type Description
pos vec3_t Position of the circle
radius number Radius of the circle
color_in color_t Color of the center of the circle
color_out color_t Color of the edge of the circle
normal vec3_t Optional. Rotation of the circle