draw
Overlay drawing; colours are packed 0xAABBGGRR integers, and calls outside on_paint are silently ignored.
Functions
draw.color
draw.color(r, g, b [, a]) -> color| Name | Type | Description |
|---|---|---|
| r | integer | 0 to 255. |
| g | integer | 0 to 255. |
| b | integer | 0 to 255. |
| aoptional | integer | 0 to 255. Default 255. |
Packs channels into a colour integer.
- Values wrap at 256 instead of clamping.
- Fractional values raise an error; use math.floor.
draw.color_hsv
draw.color_hsv(h, s, v [, a]) -> color| Name | Type | Description |
|---|---|---|
| h | number | 0 to 1, not degrees. |
| s | number | 0 to 1. |
| v | number | 0 to 1. |
| aoptional | number | 0 to 1. Default 1. |
Colour from HSV floats; rainbow: draw.color_hsv(t % 1, 1, 1).
draw.rgba
draw.rgba(color) -> r, g, b, a| Name | Type |
|---|---|
| color | integer |
Unpacks a colour into channels.
Returns integers, 0 to 255
draw.lerp_color
draw.lerp_color(a, b, t) -> color| Name | Type | Description |
|---|---|---|
| a | integer | Start colour. |
| b | integer | End colour. |
| t | number | 0 = a, 1 = b, clamped. |
Blends two colours per channel, alpha included.
draw.text
draw.text(x, y, color, text [, flags [, outline_color]])| Name | Type | Description |
|---|---|---|
| x | number | Left edge. |
| y | number | Top edge. |
| color | integer | |
| text | string | Numbers are converted. |
| flagsoptional | integer | Sum of draw.flags. Default draw.flags.SHADOW. |
| outline_coloroptional | integer | Outline or shadow colour. Default black. |
Draws text in the menu font.
Truncated past about 4 KB.
draw.text_scaled
draw.text_scaled(x, y, color, text [, size [, center]])| Name | Type | Description |
|---|---|---|
| x | number | Left edge, or centre if center. |
| y | number | Top edge. |
| color | integer | |
| text | string | |
| sizeoptional | number | Pixel height. Default 13. |
| centeroptional | boolean | Centre horizontally on x. Default false. |
Menu font at any pixel size, for big readouts.
- Large sizes look soft; use draw.create_font for crisp text.
- No shadow or outline.
draw.text_sized
draw.text_sized(x, y, size, color, text)| Name | Type | Description |
|---|---|---|
| x | number | Left edge. |
| y | number | Top edge. |
| size | number | Pixel height. |
| color | integer | |
| text | string |
Menu font at a set size; size comes before colour.
No shadow, outline or centring; use draw.text_font for flags.
draw.text_font
draw.text_font(font, x, y, color, text [, size [, flags [, outline_color]]])| Name | Type | Description |
|---|---|---|
| font | Font | From draw.create_font. |
| x | number | |
| y | number | |
| color | integer | |
| text | string | |
| sizeoptional | number | Pixel height. Default the font's created size (13 before it is ready). |
| flagsoptional | integer | Sum of draw.flags. Default draw.flags.NONE. |
| outline_coloroptional | integer | Outline or shadow colour. Default black. |
Draws text in a custom font.
- Uses the menu font until ready, or if the file is missing.
- No shadow by default, unlike draw.text.
draw.gradient_text
draw.gradient_text(x, y, text, color_start, color_end [, flags])| Name | Type | Description |
|---|---|---|
| x | number | |
| y | number | |
| text | string | |
| color_start | integer | First character. |
| color_end | integer | Last character. |
| flagsoptional | integer | Sum of draw.flags. Default draw.flags.SHADOW. |
Menu-font text fading from color_start to color_end.
draw.text_3d
draw.text_3d(pos, color, text [, flags [, outline_color]])| Name | Type | Description |
|---|---|---|
| pos | Vector | World position. |
| color | integer | |
| text | string | |
| flagsoptional | integer | Sum of draw.flags. Default draw.flags.SHADOW. |
| outline_coloroptional | integer | Outline or shadow colour. Default black. |
Menu-font text at a projected world point.
- Skipped when off-screen or behind the camera.
- pos must be a Vector, not separate x, y, z.
draw.text_size
draw.text_size(text) -> w, h| Name | Type |
|---|---|
| text | string |
Measures text as draw.text draws it; works outside on_paint.
Returns pixels, menu font
Returns 0, 0 before the menu's first frame, like during load.
draw.line
draw.line(x1, y1, x2, y2, color [, thickness])| Name | Type | Description |
|---|---|---|
| x1 | number | |
| y1 | number | |
| x2 | number | |
| y2 | number | |
| color | integer | |
| thicknessoptional | number | Pixels. Default 1. |
Draws a screen line.
draw.rect
draw.rect(x, y, w, h, color [, rounding [, thickness]])| Name | Type | Description |
|---|---|---|
| x | number | Left edge. |
| y | number | Top edge. |
| w | number | Pixels. |
| h | number | Pixels. |
| color | integer | |
| roundingoptional | number | Corner radius, pixels. Default 0. |
| thicknessoptional | number | Pixels. Default 1. |
Rectangle outline with thin black borders, ESP box style.
- The black border always draws, at the colour's alpha.
- thickness only applies with non-zero rounding.
draw.rect_filled
draw.rect_filled(x, y, w, h, color [, rounding])| Name | Type | Description |
|---|---|---|
| x | number | Left edge. |
| y | number | Top edge. |
| w | number | Pixels. |
| h | number | Pixels. |
| color | integer | |
| roundingoptional | number | Corner radius, pixels. Default 0. |
Draws a filled rectangle.
draw.rect_gradient
draw.rect_gradient(x, y, w, h, col_tl, col_tr, col_br, col_bl)| Name | Type | Description |
|---|---|---|
| x | number | Left edge. |
| y | number | Top edge. |
| w | number | |
| h | number | |
| col_tl | integer | Top-left. |
| col_tr | integer | Top-right. |
| col_br | integer | Bottom-right. |
| col_bl | integer | Bottom-left. |
Fills a rectangle with a four-corner gradient, no rounding.
draw.circle
draw.circle(x, y, radius, color [, segments [, thickness]])| Name | Type | Description |
|---|---|---|
| x | number | Centre x. |
| y | number | Centre y. |
| radius | number | Pixels. |
| color | integer | |
| segmentsoptional | integer | 3 to 256; 0 or less = auto. Default 24. |
| thicknessoptional | number | Pixels. Default 1. |
Draws a circle outline.
draw.circle_filled
draw.circle_filled(x, y, radius, color [, segments])| Name | Type | Description |
|---|---|---|
| x | number | Centre x. |
| y | number | Centre y. |
| radius | number | Pixels. |
| color | integer | |
| segmentsoptional | integer | 3 to 256; 0 or less = auto. Default 24. |
Draws a filled circle.
draw.triangle
draw.triangle(x1, y1, x2, y2, x3, y3, color [, thickness])| Name | Type | Description |
|---|---|---|
| x1 | number | |
| y1 | number | |
| x2 | number | |
| y2 | number | |
| x3 | number | |
| y3 | number | |
| color | integer | |
| thicknessoptional | number | Pixels. Default 1. |
Draws a triangle outline.
draw.triangle_filled
draw.triangle_filled(x1, y1, x2, y2, x3, y3, color)| Name | Type |
|---|---|
| x1 | number |
| y1 | number |
| x2 | number |
| y2 | number |
| x3 | number |
| y3 | number |
| color | integer |
Draws a filled triangle.
draw.triangles
draw.triangles(points, color)| Name | Type | Description |
|---|---|---|
| points | table | Flat {x1,y1, ...}; 3 points per triangle. |
| color | integer |
Draws a triangle list, unantialiased so shared edges don't double-blend.
Leftover points are ignored; non-numbers read as 0.
draw.polyline
draw.polyline(points, color [, thickness [, closed]])| Name | Type | Description |
|---|---|---|
| points | table | Flat {x1,y1, x2,y2, ...}. |
| color | integer | |
| thicknessoptional | number | Pixels. Default 1. |
| closedoptional | boolean | Join last point to first. Default false. |
Draws connected segments through the points.
Needs at least 2 points; a non-number raises an error.
draw.polygon
draw.polygon(points, color [, thickness])| Name | Type | Description |
|---|---|---|
| points | table | Flat {x1,y1, x2,y2, ...}. |
| color | integer | |
| thicknessoptional | number | Pixels. Default 1. |
Draws a closed polygon outline.
Needs at least 2 points.
draw.polygon_filled
draw.polygon_filled(points, color)| Name | Type | Description |
|---|---|---|
| points | table | Flat {x1,y1, ...}, clockwise. |
| color | integer |
Fills a convex polygon.
- Needs at least 3 points.
- Concave shapes fill wrong; split them or use draw.triangles.
draw.arc
draw.arc(x, y, radius, start_deg, end_deg, color [, thickness [, segments]])| Name | Type | Description |
|---|---|---|
| x | number | Centre x. |
| y | number | Centre y. |
| radius | number | Pixels. |
| start_deg | number | 0 = right, clockwise. |
| end_deg | number | |
| color | integer | |
| thicknessoptional | number | Pixels. Default 1. |
| segmentsoptional | integer | Clamped to 3 to 256. Default 32. |
Draws an open arc, like a progress ring.
draw.pie
draw.pie(x, y, radius, start_deg, end_deg, color [, segments])| Name | Type | Description |
|---|---|---|
| x | number | Centre x. |
| y | number | Centre y. |
| radius | number | Pixels. |
| start_deg | number | |
| end_deg | number | |
| color | integer | |
| segmentsoptional | integer | Clamped to 3 to 256. Default 32. |
Draws a filled pie slice from the centre.
Slices over 180 degrees draw wrong; split them in two.
draw.capsule
draw.capsule(x1, y1, x2, y2, radius, color [, segments])| Name | Type | Description |
|---|---|---|
| x1 | number | First end centre. |
| y1 | number | First end centre. |
| x2 | number | Second end centre. |
| y2 | number | Second end centre. |
| radius | number | Half the thickness, pixels. |
| color | integer | |
| segmentsoptional | integer | Per end, clamped 3 to 256. Default 16. |
Draws a filled pill between two points at any angle.
draw.glow
draw.glow(x, y, w, h, color [, size])| Name | Type | Description |
|---|---|---|
| x | number | Left edge. |
| y | number | Top edge. |
| w | number | |
| h | number | |
| color | integer | Alpha sets strength. |
| sizeoptional | number | Outward spread, pixels. Default 14. |
Soft halo around a rectangle; the rectangle itself is not drawn.
Looks squarish; use draw.glow_circle for round shapes.
draw.glow_circle
draw.glow_circle(x, y, radius, color [, size])| Name | Type | Description |
|---|---|---|
| x | number | Centre x. |
| y | number | Centre y. |
| radius | number | Glowing shape radius, pixels. |
| color | integer | Alpha sets strength. |
| sizeoptional | number | Outward spread, pixels. Default 14. |
Soft halo around a circle, without the circle.
draw.blur
draw.blur(x, y, w, h [, rounding [, alpha [, dim]]])| Name | Type | Description |
|---|---|---|
| x | number | Left edge. |
| y | number | Top edge. |
| w | number | |
| h | number | |
| roundingoptional | number | Corner radius, pixels. Default 0. |
| alphaoptional | number | Opacity, 0 to 1. Default 1. |
| dimoptional | number | Darkening, 0 to 1. Default 0. |
Frosted-glass game blur; draw it before the panel contents.
- Draws nothing unless HUD blur is on in Visuals.
- The first call may show nothing (captured for next frame).
draw.push_clip
draw.push_clip(x, y, w, h)| Name | Type | Description |
|---|---|---|
| x | number | Left edge. |
| y | number | Top edge. |
| w | number | |
| h | number |
Clips later draws to this rectangle (intersected) until draw.pop_clip.
Pop it in the same frame.
draw.pop_clip
draw.pop_clip()Ends the latest draw.push_clip.
Extra pops are ignored.
draw.push_additive
draw.push_additive()Additive blending for later draws, so overlaps brighten.
Pop it in the same frame, or the whole overlay turns additive.
draw.pop_additive
draw.pop_additive()Restores normal alpha blending.
draw.line_3d
draw.line_3d(a, b, color [, thickness [, opts]])| Name | Type | Description |
|---|---|---|
| a | Vector | Start, world. |
| b | Vector | End, world. |
| color | integer | |
| thicknessoptional | number | Pixels. Default 1. |
| optsoptional | table | Occlusion table, tested at midpoint. |
Draws a line between two world points.
- Skipped if either end is off-screen; never clipped.
- occlude dims to occlude_alpha (0.3) when world brushes block; hide_occluded skips.
draw.box_3d
draw.box_3d(mins, maxs, color [, thickness [, opts]])| Name | Type | Description |
|---|---|---|
| mins | Vector | Min corner, world. |
| maxs | Vector | Max corner, world. |
| color | integer | |
| thicknessoptional | number | Pixels. Default 1. |
| optsoptional | table | Like draw.line_3d, tested at centre. |
Draws the 12 edges of an axis-aligned world box.
Edges with an off-screen corner are skipped.
draw.box_3d_filled
draw.box_3d_filled(mins, maxs, color [, opts])| Name | Type | Description |
|---|---|---|
| mins | Vector | Min corner, world. |
| maxs | Vector | Max corner, world. |
| color | integer | Best translucent. |
| optsoptional | table | Like draw.line_3d, tested at centre. |
Draws a solid world box with six faces.
A face draws only if all four corners are on screen.
draw.circle_3d
draw.circle_3d(center, radius, color [, segments [, thickness [, opts]]])| Name | Type | Description |
|---|---|---|
| center | Vector | World centre. |
| radius | number | World units. |
| color | integer | |
| segmentsoptional | integer | Clamped to 3 to 128. Default 32. |
| thicknessoptional | number | Pixels. Default 1. |
| optsoptional | table | Like draw.line_3d, tested at centre. |
Flat horizontal world ring, like a ground range marker.
Segments with an off-screen end are skipped.
draw.triangle_3d_filled
draw.triangle_3d_filled(a, b, c, color)| Name | Type |
|---|---|
| a | Vector |
| b | Vector |
| c | Vector |
| color | integer |
Draws a filled triangle between three world points.
Skipped unless all three corners are on screen.
draw.polygon_3d_filled
draw.polygon_3d_filled(points, color)| Name | Type | Description |
|---|---|---|
| points | table | Convex list of world Vectors. |
| color | integer |
Fills a convex world polygon as a fan from the first point.
- Needs 3 or more points; skipped if any is off-screen.
- A non-Vector entry raises an error.
draw.icon
draw.icon(icon, x, y, size [, color])| Name | Type | Description |
|---|---|---|
| icon | string | integer | draw.icons name or numeric id. |
| x | number | Left edge. |
| y | number | Top edge. |
| size | number | Side length, pixels. |
| coloroptional | integer | Tint. Default white (untinted). |
Draws a built-in menu icon as a square.
An unknown name or id draws nothing, with no error.
draw.weapon_icon
draw.weapon_icon(weapon_id, x, y, height [, color])| Name | Type | Description |
|---|---|---|
| weapon_id | integer | 1 (P228) to 30 (P90) |
| x | number | Left edge. |
| y | number | Top edge. |
| height | number | Pixels; width follows aspect ratio. |
| coloroptional | integer | Tint. Default white (untinted). |
Draws the ESP weapon icon for a weapon id.
Out-of-range ids draw nothing.
draw.avatar
draw.avatar(player, x, y, size [, color [, rounding]]) -> boolean| Name | Type | Description |
|---|---|---|
| player | Entity | integer | |
| x | number | Left edge. |
| y | number | Top edge. |
| size | number | Width and height, pixels. |
| coloroptional | integer | Tint. Default white (untinted). |
| roundingoptional | number | Pixels; size / 2 for round. Default 0. |
Draws a player's Steam avatar; call it every frame.
Returns true if drawn
- False until the picture downloads; draw a placeholder then.
- Always false for bots and players without a custom picture.
draw.load_image
draw.load_image(file) -> Image | nil| Name | Type | Description |
|---|---|---|
| file | string | Under scripts\images\, or absolute path. |
Loads PNG, JPG, BMP, TGA, DDS, PSD or HDR into a texture.
Returns nil if missing or unreadable
- Call inside on_paint; load once and keep the handle.
- Cached by path; disk edits show only after a game restart.
draw.load_image_bytes
draw.load_image_bytes(data) -> Image| Name | Type | Description |
|---|---|---|
| data | string | Like a download or game.read_file. |
An image file held in a string: PNG, JPG, BMP or TGA.
Returns nil when it can't be read
- Same bytes give the same Image, so per-frame calls make no new texture.
- No SVG.
draw.load_sprite
draw.load_sprite(path [, frame]) -> Image, frames| Name | Type | Description |
|---|---|---|
| path | string | |
| frameoptional | integer | 0-based. Default 0. |
A game sprite, like "sprites/muzzleflash1.spr".
Returns nil when missing
- Reads through the engine, so .pak sprites work.
- Additive sprites carry brightness as alpha; draw them inside draw.push_additive().
draw.image
draw.image(image, x, y [, w, h [, color [, uv]]])| Name | Type | Description |
|---|---|---|
| image | Image | |
| x | number | Left edge. |
| y | number | Top edge. |
| woptional | number | Pixels. Default image width. |
| hoptional | number | Pixels. Default image height. |
| coloroptional | integer | Tint and alpha. Default white (untinted). |
| uvoptional | table | {u0, v0, u1, v1}, 0..1: draws part of the image. Default whole image. |
Draws a loaded image stretched to w x h.
To tint at native size, pass img:width(), img:height().
draw.image_rotated
draw.image_rotated(image, cx, cy, w, h, angle_deg [, color])| Name | Type | Description |
|---|---|---|
| image | Image | |
| cx | number | Centre x. |
| cy | number | Centre y. |
| w | number | Pixels; nil = image width. |
| h | number | Pixels; nil = image height. |
| angle_deg | number | Clockwise on screen. |
| coloroptional | integer | Tint. Default white (untinted). |
Draws an image rotated around its centre.
angle_deg is required even when w and h are nil.
draw.image_quad
draw.image_quad(image, x1, y1, x2, y2, x3, y3, x4, y4 [, color [, uv]])| Name | Type | Description |
|---|---|---|
| image | Image | |
| x1 | number | Top-left x. |
| y1 | number | Top-left y. |
| x2 | number | Top-right x. |
| y2 | number | Top-right y. |
| x3 | number | Bottom-right x. |
| y3 | number | Bottom-right y. |
| x4 | number | Bottom-left x. |
| y4 | number | Bottom-left y. |
| coloroptional | integer | Tint. Default white (untinted). |
| uvoptional | table | {u0, v0, u1, v1}; its corners go to the four points. Default whole image. |
Warps an image onto four screen corners, for tilted 3D looks.
Not perspective-correct; heavy skew shows a diagonal seam.
draw.create_font
draw.create_font(name [, size [, opts]]) -> Font| Name | Type | Description |
|---|---|---|
| name | string | Family, font file or absolute path. |
| sizeoptional | number | Pixel height, 4 to 256. Default 16. |
| optsoptional | table | ranges, hinting, hinter, bold, oblique, monochrome. |
Adds a custom font for draw.text_font, ready next frame.
- ranges: ui, latin, cyrillic, greek, korean, japanese, chinese, thai, vietnamese; unknown raises an error.
- hinting, hinter, bold, oblique, monochrome need the FreeType rasteriser (Themes).
draw.framebuffer_read
draw.framebuffer_read(x, y, w, h) -> r, g, b| Name | Type | Description |
|---|---|---|
| x | number | Left edge. |
| y | number | Top edge. |
| w | number | Pixels. |
| h | number | Pixels. |
Averages the game frame's colour inside a rectangle.
Returns averages, 0 to 255
- Call from on_paint; it stalls the GPU, so keep reads small and rare.
- Samples the central 200 x 200 only; off-screen returns 0, 0, 0.
Constants
| Name | Value | Description |
|---|---|---|
| draw.flags.NONE | 1 | |
| draw.flags.SHADOW | 2 | 1 px black drop shadow |
| draw.flags.OUTLINE | 4 | 1 px black outline; overrides SHADOW |
| draw.flags.CENTER_X | 8 | Centre horizontally on x |
| draw.flags.CENTER_Y | 16 | Centre vertically on y |
| draw.flags.RIGHT | 32 | Text ends at x; wins over CENTER_X |
| draw.flags.BOTTOM | 64 | Text ends at y; wins over CENTER_Y |
| draw.icons.rage | 1 | Rage tab |
| draw.icons.legit | 2 | Legit tab |
| draw.icons.visuals | 3 | Visuals tab |
| draw.icons.kreedz | 4 | Kreedz tab |
| draw.icons.misc | 5 | Misc tab |
| draw.icons.configs | 6 | Configs tab |
| draw.icons.console | 7 | Console tab |
| draw.icons.c4 | 20 | C4 bomb |
| draw.icons.defuser | 45 | Defuse kit |
| draw.icons.headshot | 46 | Kill-feed headshot, white for tinting |
| draw.icons.noscope | 47 | Kill-feed no-scope |
| draw.icons.inair | 48 | Kill-feed in-air |
| draw.icons.smoke | 49 | Kill-feed through-smoke |
| draw.icons.penetrate | 50 | Kill-feed wallbang |
| draw.icons.blind | 51 | Kill-feed blinded attacker |