跳转至

gui


rgb_to_hsv

float, float, float gui.rgb_to_hsv(float red, float green, float blue)

Returns the hsv representation of the provided values
Example Usage
local h, s, v = gui.rgb_to_hsv(1.0, 1.0, 1.0)

hsv_to_rgb

float, float, float gui.hsv_to_rgb(float hue, float saturation, float value)

Returns the rgb representation of the provided values
Example Usage
local r, g, b = gui.hsv_to_rgb(1.0, 1.0, 1.0)

get_window_size

float, float gui.get_window_size()

Returns the width and height of the game window's client area
Example Usage
local w, h = gui.get_window_size()

get_text_size

float, float gui.get_text_size(string text, float scale, float? wrap)

Returns the width and height of the provided text
Example Usage
local w, h = gui.get_text_size("Example", 1.0)

draw_line

void gui.draw_line(float x1, float y1, float x2, float y2, float red, float green, float blue, float alpha, float thickness)

Draws a line using the provided parameters
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)

Note

Coordinates must be within the game window's client area


draw_text

void gui.draw_text(string text, float x, float y, float red, float green, float blue, float alpha, float scale, float? wrap)

Draws text using the provided parameters
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)

Note

Coordinates must be within the game window's client area


draw_rect

void gui.draw_rect(float x, float y, float width, float height, float red, float green, float blue, float alpha, float rounding, float thickness)

Draws a rect using the provided parameters
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)

Note

Coordinates must be within the game window's client area


draw_rect_filled

void gui.draw_rect_filled(float x, float y, float width, float height, float red, float green, float blue, float alpha, float rounding)

Draws a filled rect using the provided parameters
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)

Note

Coordinates must be within the game window's client area


draw_circle

void gui.draw_circle(float x, float y, float red, float green, float blue, float alpha, float radius, float thickness)

Draws a circle using the provided parameters
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)

Note

Coordinates must be within the game window's client area


draw_circle_filled

void gui.draw_circle_filled(float x, float y, float red, float green, float blue, float alpha, float radius)

Draws a filled circle using the provided parameters
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)

Note

Coordinates must be within the game window's client area


draw_triangle

void gui.draw_triangle(float x1, float y1, float x2, float y2, float x3, float y3, float red, float green, float blue, float alpha, float thickness)

Draws a triangle using the provided parameters
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)

Note

Coordinates must be within the game window's client area


draw_triangle_filled

void gui.draw_triangle_filled(float x1, float y1, float x2, float y2, float x3, float y3, float red, float green, float blue, float alpha)

Draws a filled triangle using the provided parameters
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)

Note

Coordinates must be within the game window's client area


draw_polygon

void gui.draw_polygon(float x, float y, float red, float green, float blue, float alpha, float radius, int segments, float thickness)

Draws a polygon using the provided parameters
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)

Note

Coordinates must be within the game window's client area


draw_polygon_filled

void gui.draw_polygon_filled(float x, float y, float red, float green, float blue, float alpha, float radius, int segments)

Draws a filled polygon using the provided parameters
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)

Note

Coordinates must be within the game window's client area