gui

Methods

rgb_to_hsv

Returns the hsv representation of the provided values

function gui.rgb_to_hsv(red: float, green: float, blue: float): float, float, float
-- example usage
local h, s, v = gui.rgb_to_hsv(1.0, 1.0, 1.0)

hsv_to_rgb

Returns the rgb representation of the provided values

function gui.hsv_to_rgb(hue: float, saturation: float, value: float): float, float, float
-- example usage
local r, g, b = gui.hsv_to_rgb(1.0, 1.0, 1.0)

get_window_size

Returns the width and height of the game window's client area

function gui.get_window_size(): float, float
-- example usage
local w, h = gui.get_window_size()

get_text_size

Returns the width and height of the provided text

function gui.get_text_size(text: string, scale: float, wrap: float? --[[-1.0]]): float, float
-- example usage
local w, h = gui.get_text_size("Example", 1.0)

draw_line

Draws a line using the provided parameters

function gui.draw_line(x1: float, y1: float, x2: float, y2: float, red: float, green: float, blue: float, alpha: float, thickness: float): void
-- example usage
-- draw two lines in the center of the window

local scale = 200.0

local window_w, window_h = gui.get_window_size()

gui.draw_line((window_w / 2.0) - (scale / 2.0), (window_h / 2.0) - (scale / 2.0), (window_w / 2.0) + (scale / 2.0), (window_h / 2.0) + (scale / 2.0), 0.0, 1.0, 0.0, 1.0, 2.0)

gui.draw_line((window_w / 2.0) - (scale / 2.0), (window_h / 2.0) + (scale / 2.0), (window_w / 2.0) + (scale / 2.0), (window_h / 2.0) - (scale / 2.0), 0.0, 1.0, 0.0, 1.0, 2.0)

draw_text

Draws text using the provided parameters

function gui.draw_text(text: string, x: float, y: float, red: float, green: float, blue: float, alpha: float, scale: float, wrap: float? --[[-1.0]]): void
-- example usage
-- draw text in the center of the window

local text_w, text_h = gui.get_text_size("Example", 1.0)

local window_w, window_h = gui.get_window_size()

gui.draw_text("Example", (window_w / 2.0) - (text_w / 2.0), (window_h / 2.0) - (text_h / 2.0), 0.0, 1.0, 0.0, 1.0, 1.0)

draw_rect

Draws a rect using the provided parameters

function gui.draw_rect(x: float, y: float, width: float, height: float, red: float, green: float, blue: float, alpha: float, rounding: float, thickness: float): void
-- example usage
-- draw a rect in the center of the window

local scale = 200.0

local window_w, window_h = gui.get_window_size()

gui.draw_rect((window_w / 2.0) - (scale / 2.0), (window_h / 2.0) - (scale / 2.0), scale, scale, 0.0, 1.0, 0.0, 1.0, 0.0, 2.0)

draw_rect_filled

Draws a filled rect using the provided parameters

function gui.draw_rect_filled(x: float, y: float, width: float, height: float, red: float, green: float, blue: float, alpha: float, rounding: float): void
-- example usage
-- draw a filled rect in the center of the window

local scale = 200.0

local window_w, window_h = gui.get_window_size()

gui.draw_rect_filled((window_w / 2.0) - (scale / 2.0), (window_h / 2.0) - (scale / 2.0), scale, scale, 0.0, 1.0, 0.0, 1.0, 0.0)

draw_circle

Draws a circle using the provided parameters

function gui.draw_circle(x: float, y: float, red: float, green: float, blue: float, alpha: float, radius: float, thickness: float): void
-- example usage
-- draw a circle in the center of the window

local radius = 100.0

local window_w, window_h = gui.get_window_size()

gui.draw_circle((window_w / 2.0), (window_h / 2.0), 0.0, 1.0, 0.0, 1.0, radius, 2.0)

draw_circle_filled

Draws a filled circle using the provided parameters

function gui.draw_circle_filled(x: float, y: float, red: float, green: float, blue: float, alpha: float, radius: float): void
-- example usage
-- draw a filled circle in the center of the window

local radius = 100.0

local window_w, window_h = gui.get_window_size()

gui.draw_circle_filled((window_w / 2.0), (window_h / 2.0), 0.0, 1.0, 0.0, 1.0, radius)

draw_triangle

Draws a triangle using the provided parameters

function gui.draw_triangle(x1: float, y1: float, x2: float, y2: float, x3: float, y3: float, red: float, green: float, blue: float, alpha: float, thickness: float): void
-- example usage
-- draw a triangle in the center of the window

local scale = 200.0

local window_w, window_h = gui.get_window_size()

gui.draw_triangle((window_w / 2.0) - (scale / 2.0), (window_h / 2.0) + (scale / 2.0), (window_w / 2.0), (window_h / 2.0) - (scale / 2.0), (window_w / 2.0) + (scale / 2.0), (window_h / 2.0) + (scale / 2.0), 0.0, 1.0, 0.0, 1.0, 2.0)

draw_triangle_filled

Draws a filled triangle using the provided parameters

function gui.draw_triangle_filled(x1: float, y1: float, x2: float, y2: float, x3: float, y3: float, red: float, green: float, blue: float, alpha: float): void
-- example usage
-- draw a filled triangle in the center of the window

local scale = 200.0

local window_w, window_h = gui.get_window_size()

gui.draw_triangle_filled((window_w / 2.0) - (scale / 2.0), (window_h / 2.0) + (scale / 2.0), (window_w / 2.0), (window_h / 2.0) - (scale / 2.0), (window_w / 2.0) + (scale / 2.0), (window_h / 2.0) + (scale / 2.0), 0.0, 1.0, 0.0, 1.0)

draw_polygon

Draws a polygon using the provided parameters

function gui.draw_polygon(x: float, y: float, red: float, green: float, blue: float, alpha: float, radius: float, segments: int, thickness: float): void
-- example usage
-- draw a polygon in the center of the window

local radius = 100.0

local window_w, window_h = gui.get_window_size()

gui.draw_polygon((window_w / 2.0), (window_h / 2.0), 0.0, 1.0, 0.0, 1.0, radius, 8, 2.0)

draw_polygon_filled

Draws a filled polygon using the provided parameters

function gui.draw_polygon_filled(x: float, y: float, red: float, green: float, blue: float, alpha: float, radius: float, segments: int): void
-- example usage
-- draw a filled polygon in the center of the window

local radius = 100.0

local window_w, window_h = gui.get_window_size()

gui.draw_polygon_filled((window_w / 2.0), (window_h / 2.0), 0.0, 1.0, 0.0, 1.0, radius, 8)