🎨render

Functions:

screen_size

render.screen_size(): vector

camera_position

render.camera_position(): vector

Returns the camera position vector.

camera_angles

render.camera_angles([angles: vector]): vector

Returns or sets the camera angles.

world_to_screen

render.world_to_screen(position: vector): vector

📌 Note that there is a cleaner alternative, the :to_screen vector function.

Returns the screen position vector, or nil if the world position is not visible on your screen. This can only be called from the render callback.

get_offscreen

render.get_offscreen(position: vector, radius: number[, accurate: boolean]): vector, number, boolean

Returns the position, rotation, and is_out_of_fov arguments or nil on failure.

position: Screen coordinates (Returns ellipse-based position if the world position is out of FOV) rotation: Yaw axis that can be used to rotate drawing stuff is_out_of_fov: Returns true if the world position is out of FOV.

get_pixel

render.get_pixel(position: vector)

Getting the color of the pixel is a heavy process. Do not do it inside callbacks that are called a lot of times per second.

Returns the color of the specified pixel on the screen.

load_font

📌 Render any text via the draw:text function.

render.load_font(name: string, size: number[, flags: string]): FontObject

Returns the FontObject struct or nil on failure.

load_image

📌 Render any image via the :texture function.

render.load_image(contents: string, size: vector): ImgObject

Returns the ImgObject struct or nil on failure. Supports JPG, PNG, BMP, SVG, and GIF formats.

load_image_rgba

📌 Render any image via the :texture function.

render.load_image_rgba(contents: string, size: vector): ImgObject

Returns the ImgObject struct or nil on failure.

load_image_from_file

📌 Render any image via the :texture function.

render.load_image_from_file(path: string, size: vector): ImgObject

ℹī¸ Loading images from game resources is supported.

Example: render.load_image_from_file 'materials/panorama/images/icons/ui/warning.svg'

Returns the ImgObject struct or nil on failure. Supports JPG, PNG, BMP, SVG, and GIF formats.

measure_text

render.measure_text(font: FontObject[, flags: string], text: string): vector

Returns the measured size of the text.

highlight_hitbox

render.highlight_hitbox(entity: entity, hitbox: number, color: color)

Highlights the specified hitbox / hitboxes.

get_scale

render.get_scale(type: number): number

Returns the DPI scale value.

Structs

🔗 ImgObject

width

img.width : number

height

img.height : number

resolution

img.resolution : number

🔗 FontObject

width

font.width : number

height

font.height : number

spacing

font.spacing : number

:set_size

font:set_size(size: number)

Sets the new font size.

Draw functions

blur

render.blur(position_a: vector, position_b: vector, strength: number, alpha: number[, rounding: number])

line

render.line(position_a: vector, position_b: vector, color: color)

poly

render.poly(color: color, positions: vector[, ...])

poly_blur

render.poly_blur(opacity: number, strength: number, positions: vector[, ...])

poly_line

render.poly_line(color: color, positions: vector[, ...])

rect

render.rect(position_a: vector, position_b: vector, color: color[, rounding: number, no_clamp: boolean])

rect_outline

render.rect_outline(position_a: vector, position_b: vector, color: color[, thickness: number, rounding: number, no_clamp: boolean])

gradient

render.gradient(position_a: vector, position_b: vector, top_left: color, top_right: color, bottom_left: color, bottom_right: color[, rounding: number])

circle

render.circle(position: vector, color: color, radius: number, start_deg: number, pct: number)

circle_outline

render.circle_outline(position: vector, color: color, radius: number, start_deg: number, pct: number[, thickness: number])

circle_gradient

render.circle_gradient(position: vector, color_outer: color, color_inner: color, radius: number, start_deg: number, pct: number)

circle_3d

render.circle_3d(position: vector, color: color, radius: number, start_deg: number, pct: number[, outline: boolean])

circle_3d_outline

render.circle_3d_outline(position: vector, color: color, radius: number, start_deg: number, pct: number[, thickness: number])

circle_3d_gradient

render.circle_3d_gradient(position: vector, color_outer: color, color_inner: color, radius: number, start_deg: number, pct: number)

text

📌 Render any text via the :load_font function.

render.text(font: FontObject, position: vector, color: color, flags: string, text:any[, ...])

Draws the specified text.

texture

📌 Create the texture via the :load_image function.

render.texture(texture: ImgObject, position: vector[, size: vector, color: color, mode: string, rounding: number])

push_rotation

render.push_rotation(degrees: number)

Applies the rotation for all subsequent elements.

pop_rotation

render.pop_rotation()

Discards an early set rotation.

push_clip_rect

render.push_clip_rect(pos_a: vector, pos_b: vector[, intersect: boolean])

Applies the clip region to the given rectangle for all subsequent elements.

pop_clip_rect

render.pop_clip_rect()

Discards an early set rectangle clipping region.

shadow

render.shadow(pos_a: vector, pos_b: vector, clr: color[, thickness: number, offset: number, rounding: number])

Draws a shadow rectangle.

Last updated