GUI

Functions

push_clip

Pushes a clip rect.

---@param pos vec2
---@param scale vec2
function gui.push_clip(pos, scale): nil

pop_clip

Pops a clip rect.

function gui.pop_clip(): nil

line

Draws a 2D line.

---@param from vec2
---@param to vec2
---@param thickness number
---@param color color
function gui.line(from, to, thickness, color): nil

circle

Draws a circle.

---@param pos vec2
---@param radius number
---@param color color
function gui.circle(pos, radius, color): nil

image

Draws an image.

---@param texture texture
---@param pos vec2
---@param scale vec2
---@param color color
function gui.image(texture, pos, scale, color): nil

image_rounded

Draws a rounded image.

---@param texture texture
---@param pos vec2
---@param scale vec2
---@param color color
---@param rounding number
---@param flags gui.rounding|integer
function gui.image_rounded(texture, pos, scale, color, rounding?, flags?): nil

image_rotated

Draws a rotated image.

---@param texture texture
---@param pos vec2
---@param scale vec2
---@param color color
---@param degrees number
function gui.image_rotated(texture, pos, scale, color, degrees): nil

rebuild

Rebuild the font atlas.

function gui.rebuild(): nil

load_image

Loads an image.

---@param path string
function gui.load_image(path): texture

load_font

Loads a font.

---@param path string
---@param scale number
function gui.load_font(path, scale): font

text

Creates an instance of text.

---@param str string
function gui.text(str): text

rect

Creates an instance of rect.

---@param pos vec2
---@param scale vec2
function gui.rect(pos, scale): rect

text_size

Gets the width and height of some text.

---@param text string
---@param scale number
---@param options? { wrap: number, font: font }
function gui.text_size(text, scale, options?): vec2

Types

text

function text:draw(): text
function text:get_size(): vec2

---@param pos vec2
function text:position(pos): text

---@param color color
function text:color(color): text

---@param wrap number
function text:wrap(wrap): text

---@param scale number
function text:scale(scale): text

---@param justify gui.justify
function text:justify(justify): text

---@param font font
function text:font(font): text

rect

function rect:draw(): rect
function rect:filled(): rect

---@param color color
function rect:color(color): rect

---@param thickness number
---@param color color
function rect:outline(thickness, color): rect

---@param rounding number
---@param flags? gui.rounding|integer
function rect:rounding(rounding, flags?): rect

---@param upr_left color
---@param upr_right color
---@param bot_right color
---@param bot_left color
function rect:multicolors(upr_left, upr_right, bot_right, bot_left): rect

color

TypeName
integerr
integerg
integerb
numberrf
numbergf
numberbf

texture

TypeName
vec2scale
stringname
stringpath

font

TypeName
numberscale
stringpath

Constants

justify

gui.justify.left
gui.justify.center
gui.justify.right

rounding

gui.rounding.top_left
gui.rounding.top_right
gui.rounding.bottom_left
gui.rounding.bottom_right

Example

util.create_thread(function()
  gui.rect(vec2(100.0, 100.0), vec2(100.0, 100.0))
    :filled()
    :color(color(255, 255, 255, 100))
    :draw()

  gui.text('test')
    :position(vec2(100.0, 100.0))
    :color(color(255, 255, 255, 100))
    :draw()
end)