Drawing and colours
Shapes, text and images on the overlay, colours, and the old render aliases.
draw.line(x1, y1, x2, y2, col [, thickness])Line between two screen points.
| Name | Type | Default | Description |
|---|---|---|---|
x1 | number | ||
y1 | number | ||
x2 | number | ||
y2 | number | ||
col | color | ||
thicknessoptional | number | 1 |
draw.line(10, 10, 200, 10, color(255, 255, 255), 2)draw.rect(x, y, w, h, col [, thickness [, rounding]])Rectangle outline.
| Name | Type | Default | Description |
|---|---|---|---|
x | number | ||
y | number | ||
w | number | ||
h | number | ||
col | color | ||
thicknessoptional | number | 1 | |
roundingoptional | number | 0 |
draw.rect(100, 100, 50, 80, color(255, 0, 0))draw.rect_filled(x, y, w, h, col [, rounding])Filled rectangle.
| Name | Type | Default | Description |
|---|---|---|---|
x | number | ||
y | number | ||
w | number | ||
h | number | ||
col | color | ||
roundingoptional | number | 0 |
draw.rect_filled(20, 20, 120, 24, color(17, 17, 17, 240), 4)draw.gradient(x, y, w, h, tl, tr, br, bl)Four-corner gradient rectangle (no rounding).
| Name | Type | Description |
|---|---|---|
x | number | |
y | number | |
w | number | |
h | number | |
tl | color | |
tr | color | |
br | color | |
bl | color |
draw.gradient(0, 0, 200, 40, color(255,0,0), color(0,255,0), color(0,0,255), color(255,255,255))draw.gradient_h(x, y, w, h, left, right)Horizontal gradient rectangle.
| Name | Type | Description |
|---|---|---|
x | number | |
y | number | |
w | number | |
h | number | |
left | color | |
right | color |
draw.gradient_h(20, 20, 200, 2, ui.accent(), color(0, 0, 0, 0))draw.gradient_v(x, y, w, h, top, bottom)Vertical gradient rectangle.
| Name | Type | Description |
|---|---|---|
x | number | |
y | number | |
w | number | |
h | number | |
top | color | |
bottom | color |
draw.gradient_v(20, 20, 200, 60, color(30, 30, 30), color(10, 10, 10))draw.circle(x, y, r, col [, thickness [, segments]])Circle outline (segments 0 = automatic).
| Name | Type | Default | Description |
|---|---|---|---|
x | number | ||
y | number | ||
r | number | ||
col | color | ||
thicknessoptional | number | 1 | |
segmentsoptional | integer | 0 |
draw.circle(960, 540, 100, color(255, 255, 255, 120))draw.circle_filled(x, y, r, col [, segments])Filled circle.
| Name | Type | Default | Description |
|---|---|---|---|
x | number | ||
y | number | ||
r | number | ||
col | color | ||
segmentsoptional | integer | 0 |
draw.circle_filled(960, 540, 3, color(143, 108, 240))draw.arc(x, y, r, start_deg, sweep_deg, col [, thickness])Arc; 0 degrees = +x, clockwise on screen, sweep may be negative.
| Name | Type | Default | Description |
|---|---|---|---|
x | number | ||
y | number | ||
r | number | ||
start_deg | number | ||
sweep_deg | number | ||
col | color | ||
thicknessoptional | number | 1 |
draw.arc(960, 540, 30, -90, 270, color(255, 255, 255), 2)draw.triangle(x1, y1, x2, y2, x3, y3, col [, filled])Triangle, outlined or filled.
| Name | Type | Default | Description |
|---|---|---|---|
x1 | number | ||
y1 | number | ||
x2 | number | ||
y2 | number | ||
x3 | number | ||
y3 | number | ||
col | color | ||
filledoptional | boolean | false |
draw.triangle(0, 0, 20, 0, 10, 15, color(255, 255, 0), true)draw.polygon(points, col [, filled [, thickness]])Closed polygon; points = flat {x1, y1, x2, y2, ...} or a list of vec2 (at most 512 points). Filled polygons must be convex.
| Name | Type | Default | Description |
|---|---|---|---|
points | table | ||
col | color | ||
filledoptional | boolean | false | |
thicknessoptional | number | 1 |
draw.polygon({10, 10, 60, 10, 35, 50}, color(0, 200, 255), true)draw.polyline(points, col [, closed [, thickness]])Open (or closed) line strip.
| Name | Type | Default | Description |
|---|---|---|---|
points | table | ||
col | color | ||
closedoptional | boolean | false | |
thicknessoptional | number | 1 |
draw.polyline({0, 0, 50, 20, 100, 0}, color(255, 255, 255))draw.text(x, y, text, col [, opts])Text (at most 1024 bytes). opts = {font=, size=, align="left"|"center"|"right", outline=true, shadow=true}.
| Name | Type | Description |
|---|---|---|
x | number | |
y | number | |
text | string | |
col | color | |
optsoptional | table |
draw.text(20, 20, "hello", color(255, 255, 255), {font = "bold", outline = true})draw.text_size(text [, font [, size]]) -> number, numberWidth and height of text in pixels.
| Name | Type | Description |
|---|---|---|
text | string | |
fontoptional | font | |
sizeoptional | number |
number, number
local w, h = draw.text_size("hello", "bold")draw.font(name) -> fontA built-in face: text, bold, small, esp, label, pixel, icons (Boxicons).
| Name | Type | Description |
|---|---|---|
name | string |
font
local f = draw.font("pixel")draw.load_font(file, size) -> font | nil, stringLoads a TTF/OTF from scripts/fonts/ (at most 8 per runtime).
| Name | Type | Description |
|---|---|---|
file | string | |
size | number |
font | nil, string
local f = draw.load_font("Inter.ttf", 14)draw.load_image(file) -> image | nil, stringLoads a PNG/JPEG from the scripts folder (path relative to it; at most 64 per runtime).
| Name | Type | Description |
|---|---|---|
file | string |
image | nil, string
local logo = draw.load_image("images/logo.png")draw.image(img, x, y, w, h [, tint [, rotation_deg]])Draws a loaded image, optionally tinted and rotated about its centre.
| Name | Type | Default | Description |
|---|---|---|---|
img | image | ||
x | number | ||
y | number | ||
w | number | ||
h | number | ||
tintoptional | color | ||
rotation_degoptional | number | 0 |
draw.image(logo, 20, 20, 64, 64)draw.clip_push(x, y, w, h)Clips the following draws to a rectangle (balanced automatically at the end of paint).
| Name | Type | Description |
|---|---|---|
x | number | |
y | number | |
w | number | |
h | number |
draw.clip_push(0, 0, 100, 20)draw.clip_pop()Ends the last clip_push.
draw.clip_pop()draw.chip(spec) -> number, numberThe house HUD chip: spec = {x=, y=, label=, value=, accent=, meter=0..1, icon=image, label_color=, value_color=}. Returns its width and height.
| Name | Type | Description |
|---|---|---|
spec | table |
number, number
draw.chip({x = 20, y = 300, label = "KILLS", value = tostring(n)})draw.panel(x, y, w, h [, title]) -> numberThe house panel look (frame, accent line, title row). Returns the y of the first content row.
| Name | Type | Description |
|---|---|---|
x | number | |
y | number | |
w | number | |
h | number | |
titleoptional | string |
number
local y = draw.panel(20, 20, 180, 60, "Stats")draw.world_line(a, b, col [, thickness])Line between two world points, projected with the drawn camera.
| Name | Type | Default | Description |
|---|---|---|---|
a | vec3 | ||
b | vec3 | ||
col | color | ||
thicknessoptional | number | 1 |
Needs Allow game scripting in Scripts > Security (on by default).
draw.world_line(p.origin, p.eye_pos, color(255, 0, 0))draw.world_circle(center, radius, col [, thickness])Circle on the ground plane around a world point.
| Name | Type | Default | Description |
|---|---|---|---|
center | vec3 | ||
radius | number | ||
col | color | ||
thicknessoptional | number | 1 |
Needs Allow game scripting in Scripts > Security (on by default).
draw.world_circle(p.origin, 20, color(255, 255, 255))draw.world_text(pos, text, col [, opts])Text at a world point (centred by default).
| Name | Type | Description |
|---|---|---|
pos | vec3 | |
text | string | |
col | color | |
optsoptional | table |
Needs Allow game scripting in Scripts > Security (on by default).
draw.world_text(p.eye_pos, p.name, color(255, 255, 255))draw.screen_size() -> number, numberOverlay size in pixels.
number, number
local w, h = draw.screen_size()color.hex(hex) -> colorParses "#rrggbb[aa]".
| Name | Type | Description |
|---|---|---|
hex | string |
color
local c = color.hex("#8f6cf0")color.hsv(h, s, v [, a]) -> colorFrom hue/saturation/value in 0..1.
| Name | Type | Default | Description |
|---|---|---|---|
h | number | ||
s | number | ||
v | number | ||
aoptional | integer | 255 |
color
local rainbow = color.hsv(time.now() % 1, 1, 1)color.lerp(a, b, t) -> colorBlends two colours.
| Name | Type | Description |
|---|---|---|
a | color | |
b | color | |
t | number |
color
local c = color.lerp(color(255,0,0), color(0,255,0), 0.5)color.alpha(c, a) -> colorThe colour with another alpha.
| Name | Type | Description |
|---|---|---|
c | color | |
a | integer |
color
local faded = color.alpha(c, 100)color.unpack(c) -> integer, integer, integer, integerr, g, b, a of a colour.
| Name | Type | Description |
|---|---|---|
c | color |
integer, integer, integer, integer
local r, g, b, a = color.unpack(c)render.draw_line(p0, p1, col [, thickness])Alias for draw.line.
| Name | Type | Description |
|---|---|---|
p0 | vec2 | |
p1 | vec2 | |
col | color | |
thicknessoptional | number |
render.draw_rect(pos, size, col [, thickness [, rounding]])draw.rect.
| Name | Type | Description |
|---|---|---|
pos | vec2 | |
size | vec2 | |
col | color | |
thicknessoptional | number | |
roundingoptional | number |
render.draw_rect_filled(pos, size, col [, rounding])draw.rect_filled.
| Name | Type | Description |
|---|---|---|
pos | vec2 | |
size | vec2 | |
col | color | |
roundingoptional | number |
render.draw_circle(center, r, col [, thickness [, filled]])draw.circle / circle_filled.
| Name | Type | Description |
|---|---|---|
center | vec2 | |
r | number | |
col | color | |
thicknessoptional | number | |
filledoptional | boolean |
render.draw_polygon(points, n, col [, thickness [, filled]])draw.polygon.
| Name | Type | Description |
|---|---|---|
points | vec2[] | |
n | integer | |
col | color | |
thicknessoptional | number | |
filledoptional | boolean |
render.draw_triangle(a, b, c, col [, thickness [, filled]])draw.triangle.
| Name | Type | Description |
|---|---|---|
a | vec2 | |
b | vec2 | |
c | vec2 | |
col | color | |
thicknessoptional | number | |
filledoptional | boolean |
render.draw_arc(center, r, start_deg, sweep_deg, col [, thickness])draw.arc.
| Name | Type | Description |
|---|---|---|
center | vec2 | |
r | number | |
start_deg | number | |
sweep_deg | number | |
col | color | |
thicknessoptional | number |
render.draw_four_corner_gradient(pos, size, tl, tr, br, bl)draw.gradient.
| Name | Type | Description |
|---|---|---|
pos | vec2 | |
size | vec2 | |
tl | color | |
tr | color | |
br | color | |
bl | color |
render.draw_text(text, pos, col [, font [, outline [, shadow_color [, shadow_px [, size]]]]])draw.text.
| Name | Type | Description |
|---|---|---|
text | string | |
pos | vec2 | |
col | color | |
fontoptional | font | |
outlineoptional | boolean | |
shadow_coloroptional | color | |
shadow_pxoptional | number | |
sizeoptional | number |
render.get_text_size(font, text) -> vec2draw.text_size.
| Name | Type | Description |
|---|---|---|
font | font | |
text | string |
vec2
render.create_font(file, size) -> fontdraw.load_font.
| Name | Type | Description |
|---|---|---|
file | string | |
size | number |
font
render.create_bitmap(file) -> imagedraw.load_image.
| Name | Type | Description |
|---|---|---|
file | string |
image
render.draw_bitmap(bmp, pos, size [, tint])draw.image.
| Name | Type | Description |
|---|---|---|
bmp | image | |
pos | vec2 | |
size | vec2 | |
tintoptional | color |
render.clip_push(pos, size)draw.clip_push.
| Name | Type | Description |
|---|---|---|
pos | vec2 | |
size | vec2 |
render.clip_pop()draw.clip_pop.
render.get_view_width() -> numberOverlay width.
number
render.get_view_height() -> numberOverlay height.
number
render.get_fps() -> numbertime.fps().
number
render.get_frame_index() -> integertime.frame().
integer