render#
Info
the render.* functions can only be called from within a few select callbacks, make sure you check if the callback youre in right now supports it
create_font#
Creates a font object
Warning
Only call this OUTSIDE of callbacks to prevent infinite font creation and crashing
font_t create_font(<string> font_name, <int> font_size, <int> font_weight, [optional] <e_font_flags> font_flags...)
| Fields | Description |
|---|---|
font_namestring |
render font name |
font_sizeint |
size of created font |
font_weightint |
weight of created font |
font_flagse_font_flags |
[optional] [variadic] font flags |
Example
local main_font = render.create_font("Arial", 20, 600, e_font_flags.ANTIALIAS, e_font_flags.ITALIC, e_font_flags.DROPSHADOW)
text#
Renders text
void text(<font_t> font_object, <string> text, <vec2_t> screen_pos, <color_t> text_color, [optional] <bool> centered)
| Fields | Description |
|---|---|
font_objectfont_t |
font object |
textstring |
text to render |
screen_posvec2_t |
position of text |
text_colorcolor_t |
color of text |
centeredbool |
should text be centered |
Example
get_text_size#
Returns size of text as a vec2_t
| Fields | Description |
|---|---|
font_objectfont_t |
render font object |
textstring |
text to measure |
Example
weapon_icon#
renders the weapon icon of the specified weapon id
void weapon_icon(<int> weapon_id, <vec2_t> screen_pos, <color_t> text_color, [optional] <bool> centered)
| Fields | Description |
|---|---|
weapon_idint |
weapon id to render |
screen_posvec2_t |
position of text |
text_colorcolor_t |
color of text |
centeredbool |
should text be centered |
Example
get_default_font#
Returns the cheat's default font
Example
local default_font = render.get_default_font()
callbacks.add(e_callbacks.PAINT,function()
render.text(default_font,"Hi",vec2_t(0,25),color_t(255,255,255))
end)
push_clip#
Pushes a clip onto render elements
| Fields | Description |
|---|---|
startvec2_t |
clip start |
sizevec2_t |
clip size |
Example
pop_clip#
Stops all other render calls from being clipped
Example
render.push_clip(vec2_t(100, 100), vec2_t(100, 100))
render.rect_filled(vec2_t(100, 100), vec2_t(200, 100), color_t(255, 255, 255, 255)) -- this rectangle will be cut off in the middle
render.pop_clip() -- you always have to pop it to stop other render.* calls from being clipped
push_alpha_modifier#
Pushes a alpha modifier onto render elements
| Fields | Description |
|---|---|
alpha_modifierfloat |
alpha modifier |
Example
pop_alpha_modifier#
Stops all other elements from having their alpha modified
Example
render.push_alpha_modifier(0.5)
render.rect_filled(vec2_t(100, 100), vec2_t(100, 100), color_t(255, 255, 255, 200)) -- this will draw with only 100 alpha
render.pop_alpha_modifier() -- you always have to pop the alpha modifier to end it
get_screen_size#
Returns current screen size as a vec2_t
Example
line#
Renders a 2D line
| Fields | Description |
|---|---|
fromvec2_t |
starting point |
tovec2_t |
end point |
colorcolor_t |
line color |
Example
rect#
Renders a 2D rectangle
void rect(<vec2_t> screen_coords, <vec2_t> rectangle_size, <color_t> color, [optional] <float> rounding)
| Fields | Description |
|---|---|
screen_coordsvec2_t |
x and y coordinates |
rectangle_sizevec2_t |
rectangle width and height |
colorcolor_t |
rectangle color |
roundingfloat |
rectangle rounding |
Example
rect_filled#
Renders a 2D filled rectangle
void rect_filled(<vec2_t> screen_coords, <vec2_t> rectangle_size, <color_t> color, [optional] <float> rounding)
| Fields | Description |
|---|---|
screen_coordsvec2_t |
x and y coordinates |
rectangle_sizevec2_t |
rectangle width and height |
colorcolor_t |
rectangle fill color |
roundingfloat |
rectangle fill rounding |
Example
rect_fade#
Renders a 2D rectangle with a gradient
void rect_fade(<vec2_t> screen_coords, <vec2_t> rectangle_size, <color_t> color_start, <color_t> color_end, [optional] <bool> horizontal)
| Fields | Description |
|---|---|
screen_coordsvec2_t |
x and y coordinates |
rectangle_sizevec2_t |
rectangle width and height |
color_startcolor_t |
rectangle gradient color start |
color_endcolor_t |
rectangle gradient color end |
horizontalbool |
[optional] makes the gradient horizontal |
Example
triangle#
Renders a 2D triangle
| Fields | Description |
|---|---|
screen_coordsvec2_t |
x and y coordinates |
sizeint |
triangle size |
colorcolor_t |
triangle color |
rotationint |
[optional] triangle rotation |
Example
triangle_filled#
Renders a 2D triangle
void triangle_filled(<vec2_t> screen_coords, <int> size, <color_t> color, [optional] <int> rotation)
| Fields | Description |
|---|---|
screen_coordsvec2_t |
x and y coordinates |
sizeint |
triangle size |
colorcolor_t |
triangle color |
rotationint |
[optional] triangle rotation |
Example
circle#
Renders a 2D circle
| Fields | Description |
|---|---|
screen_coordsvec2_t |
x and y coordinates |
radiusint |
circle size |
colorcolor_t |
circle color |
thicknessint |
Example
circle_filled#
Renders a 2D filled circle
| Fields | Description |
|---|---|
screen_coordsvec2_t |
x and y coordinates |
radiusint |
circle size |
colorcolor_t |
circle fill color |
Example
progress_circle#
Renders a 2D progress_circle
void progress_circle(<vec2_t> screen_coords, <int> radius, <color_t> color, <int> width, <float> progress)
| Fields | Description |
|---|---|
screen_coordsvec2_t |
x and y coordinates |
radiusint |
progress bar size |
colorcolor_t |
progress bar color |
widthint |
progress bar width |
progressfloat |
progress value |
Example
polygon#
Renders a 2D polygon
| Fields | Description |
|---|---|
points[table] vec2_t |
array of 2D points |
colorcolor_t |
polygon color |
Example
render.polygon({vec2_t(100, 100), vec2_t(150, 100), vec2_t(150, 200), vec2_t(100, 200), vec2_t(50, 150), vec2_t(100, 200), vec2_t(150, 200), vec2_t(150, 100)}, color_t(255,255,255))
polyline#
Renders a 2D polyline
| Fields | Description |
|---|---|
points[table] vec2_t |
array of 2D points |
colorcolor_t |
polygon color |
Example
render.polyline({vec2_t(100, 100), vec2_t(150, 100), vec2_t(150, 200), vec2_t(100, 200), vec2_t(50, 150), vec2_t(100, 200), vec2_t(150, 200), vec2_t(150, 100)}, color_t(255,255,255))
world_to_screen#
Returns 2D coordinates for a 3D world point or nil on failure
| Fields | Description |
|---|---|
world_positionvec3_t |
x, y, z coordinates |
Example
local screen_pos = render.world_to_screen(world_position)
if screen_pos ~= nil then
print(screen_pos) --unpacks 2D vector
end
load_image#
loads an image from a path and returns a texture
supports .jpg, .jpeg, .png, .svg, .tga, .bmp
load_image_buffer#
loads an image from the raw file (has to include header) and returns a texture
supports .jpg, .jpeg, .png, .svg, .tga, .bmp
texture#
renders a texture received from load_image or load_image_buffer
Example
local img = render.load_image("ak47.svg")
print(img.size.x, img.size.y)
function on_paint()
render.texture(img.id, vec2_t(100, 100), img.size)
end