xhookLua
Game

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
NameTypeDescription
rinteger0 to 255.
ginteger0 to 255.
binteger0 to 255.
aoptionalinteger0 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
NameTypeDescription
hnumber0 to 1, not degrees.
snumber0 to 1.
vnumber0 to 1.
aoptionalnumber0 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
NameType
colorinteger

Unpacks a colour into channels.

Returns integers, 0 to 255

draw.lerp_color

draw.lerp_color(a, b, t) -> color
NameTypeDescription
aintegerStart colour.
bintegerEnd colour.
tnumber0 = a, 1 = b, clamped.

Blends two colours per channel, alpha included.

draw.text

draw.text(x, y, color, text [, flags [, outline_color]])
NameTypeDescription
xnumberLeft edge.
ynumberTop edge.
colorinteger
textstringNumbers are converted.
flagsoptionalintegerSum of draw.flags. Default draw.flags.SHADOW.
outline_coloroptionalintegerOutline 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]])
NameTypeDescription
xnumberLeft edge, or centre if center.
ynumberTop edge.
colorinteger
textstring
sizeoptionalnumberPixel height. Default 13.
centeroptionalbooleanCentre 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)
NameTypeDescription
xnumberLeft edge.
ynumberTop edge.
sizenumberPixel height.
colorinteger
textstring

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]]])
NameTypeDescription
fontFontFrom draw.create_font.
xnumber
ynumber
colorinteger
textstring
sizeoptionalnumberPixel height. Default the font's created size (13 before it is ready).
flagsoptionalintegerSum of draw.flags. Default draw.flags.NONE.
outline_coloroptionalintegerOutline 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])
NameTypeDescription
xnumber
ynumber
textstring
color_startintegerFirst character.
color_endintegerLast character.
flagsoptionalintegerSum 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]])
NameTypeDescription
posVectorWorld position.
colorinteger
textstring
flagsoptionalintegerSum of draw.flags. Default draw.flags.SHADOW.
outline_coloroptionalintegerOutline 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
NameType
textstring

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])
NameTypeDescription
x1number
y1number
x2number
y2number
colorinteger
thicknessoptionalnumberPixels. Default 1.

Draws a screen line.

draw.rect

draw.rect(x, y, w, h, color [, rounding [, thickness]])
NameTypeDescription
xnumberLeft edge.
ynumberTop edge.
wnumberPixels.
hnumberPixels.
colorinteger
roundingoptionalnumberCorner radius, pixels. Default 0.
thicknessoptionalnumberPixels. 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])
NameTypeDescription
xnumberLeft edge.
ynumberTop edge.
wnumberPixels.
hnumberPixels.
colorinteger
roundingoptionalnumberCorner 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)
NameTypeDescription
xnumberLeft edge.
ynumberTop edge.
wnumber
hnumber
col_tlintegerTop-left.
col_trintegerTop-right.
col_brintegerBottom-right.
col_blintegerBottom-left.

Fills a rectangle with a four-corner gradient, no rounding.

draw.circle

draw.circle(x, y, radius, color [, segments [, thickness]])
NameTypeDescription
xnumberCentre x.
ynumberCentre y.
radiusnumberPixels.
colorinteger
segmentsoptionalinteger3 to 256; 0 or less = auto. Default 24.
thicknessoptionalnumberPixels. Default 1.

Draws a circle outline.

draw.circle_filled

draw.circle_filled(x, y, radius, color [, segments])
NameTypeDescription
xnumberCentre x.
ynumberCentre y.
radiusnumberPixels.
colorinteger
segmentsoptionalinteger3 to 256; 0 or less = auto. Default 24.

Draws a filled circle.

draw.triangle

draw.triangle(x1, y1, x2, y2, x3, y3, color [, thickness])
NameTypeDescription
x1number
y1number
x2number
y2number
x3number
y3number
colorinteger
thicknessoptionalnumberPixels. Default 1.

Draws a triangle outline.

draw.triangle_filled

draw.triangle_filled(x1, y1, x2, y2, x3, y3, color)
NameType
x1number
y1number
x2number
y2number
x3number
y3number
colorinteger

Draws a filled triangle.

draw.triangles

draw.triangles(points, color)
NameTypeDescription
pointstableFlat {x1,y1, ...}; 3 points per triangle.
colorinteger

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]])
NameTypeDescription
pointstableFlat {x1,y1, x2,y2, ...}.
colorinteger
thicknessoptionalnumberPixels. Default 1.
closedoptionalbooleanJoin 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])
NameTypeDescription
pointstableFlat {x1,y1, x2,y2, ...}.
colorinteger
thicknessoptionalnumberPixels. Default 1.

Draws a closed polygon outline.

Needs at least 2 points.

draw.polygon_filled

draw.polygon_filled(points, color)
NameTypeDescription
pointstableFlat {x1,y1, ...}, clockwise.
colorinteger

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]])
NameTypeDescription
xnumberCentre x.
ynumberCentre y.
radiusnumberPixels.
start_degnumber0 = right, clockwise.
end_degnumber
colorinteger
thicknessoptionalnumberPixels. Default 1.
segmentsoptionalintegerClamped 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])
NameTypeDescription
xnumberCentre x.
ynumberCentre y.
radiusnumberPixels.
start_degnumber
end_degnumber
colorinteger
segmentsoptionalintegerClamped 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])
NameTypeDescription
x1numberFirst end centre.
y1numberFirst end centre.
x2numberSecond end centre.
y2numberSecond end centre.
radiusnumberHalf the thickness, pixels.
colorinteger
segmentsoptionalintegerPer 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])
NameTypeDescription
xnumberLeft edge.
ynumberTop edge.
wnumber
hnumber
colorintegerAlpha sets strength.
sizeoptionalnumberOutward 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])
NameTypeDescription
xnumberCentre x.
ynumberCentre y.
radiusnumberGlowing shape radius, pixels.
colorintegerAlpha sets strength.
sizeoptionalnumberOutward spread, pixels. Default 14.

Soft halo around a circle, without the circle.

draw.blur

draw.blur(x, y, w, h [, rounding [, alpha [, dim]]])
NameTypeDescription
xnumberLeft edge.
ynumberTop edge.
wnumber
hnumber
roundingoptionalnumberCorner radius, pixels. Default 0.
alphaoptionalnumberOpacity, 0 to 1. Default 1.
dimoptionalnumberDarkening, 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)
NameTypeDescription
xnumberLeft edge.
ynumberTop edge.
wnumber
hnumber

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]])
NameTypeDescription
aVectorStart, world.
bVectorEnd, world.
colorinteger
thicknessoptionalnumberPixels. Default 1.
optsoptionaltableOcclusion 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]])
NameTypeDescription
minsVectorMin corner, world.
maxsVectorMax corner, world.
colorinteger
thicknessoptionalnumberPixels. Default 1.
optsoptionaltableLike 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])
NameTypeDescription
minsVectorMin corner, world.
maxsVectorMax corner, world.
colorintegerBest translucent.
optsoptionaltableLike 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]]])
NameTypeDescription
centerVectorWorld centre.
radiusnumberWorld units.
colorinteger
segmentsoptionalintegerClamped to 3 to 128. Default 32.
thicknessoptionalnumberPixels. Default 1.
optsoptionaltableLike 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)
NameType
aVector
bVector
cVector
colorinteger

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)
NameTypeDescription
pointstableConvex list of world Vectors.
colorinteger

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])
NameTypeDescription
iconstring | integerdraw.icons name or numeric id.
xnumberLeft edge.
ynumberTop edge.
sizenumberSide length, pixels.
coloroptionalintegerTint. 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])
NameTypeDescription
weapon_idinteger1 (P228) to 30 (P90)
xnumberLeft edge.
ynumberTop edge.
heightnumberPixels; width follows aspect ratio.
coloroptionalintegerTint. 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
NameTypeDescription
playerEntity | integer
xnumberLeft edge.
ynumberTop edge.
sizenumberWidth and height, pixels.
coloroptionalintegerTint. Default white (untinted).
roundingoptionalnumberPixels; 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
NameTypeDescription
filestringUnder 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
NameTypeDescription
datastringLike 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
NameTypeDescription
pathstring
frameoptionalinteger0-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]]])
NameTypeDescription
imageImage
xnumberLeft edge.
ynumberTop edge.
woptionalnumberPixels. Default image width.
hoptionalnumberPixels. Default image height.
coloroptionalintegerTint and alpha. Default white (untinted).
uvoptionaltable{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])
NameTypeDescription
imageImage
cxnumberCentre x.
cynumberCentre y.
wnumberPixels; nil = image width.
hnumberPixels; nil = image height.
angle_degnumberClockwise on screen.
coloroptionalintegerTint. 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]])
NameTypeDescription
imageImage
x1numberTop-left x.
y1numberTop-left y.
x2numberTop-right x.
y2numberTop-right y.
x3numberBottom-right x.
y3numberBottom-right y.
x4numberBottom-left x.
y4numberBottom-left y.
coloroptionalintegerTint. Default white (untinted).
uvoptionaltable{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
NameTypeDescription
namestringFamily, font file or absolute path.
sizeoptionalnumberPixel height, 4 to 256. Default 16.
optsoptionaltableranges, 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
NameTypeDescription
xnumberLeft edge.
ynumberTop edge.
wnumberPixels.
hnumberPixels.

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

NameValueDescription
draw.flags.NONE1
draw.flags.SHADOW21 px black drop shadow
draw.flags.OUTLINE41 px black outline; overrides SHADOW
draw.flags.CENTER_X8Centre horizontally on x
draw.flags.CENTER_Y16Centre vertically on y
draw.flags.RIGHT32Text ends at x; wins over CENTER_X
draw.flags.BOTTOM64Text ends at y; wins over CENTER_Y
draw.icons.rage1Rage tab
draw.icons.legit2Legit tab
draw.icons.visuals3Visuals tab
draw.icons.kreedz4Kreedz tab
draw.icons.misc5Misc tab
draw.icons.configs6Configs tab
draw.icons.console7Console tab
draw.icons.c420C4 bomb
draw.icons.defuser45Defuse kit
draw.icons.headshot46Kill-feed headshot, white for tinting
draw.icons.noscope47Kill-feed no-scope
draw.icons.inair48Kill-feed in-air
draw.icons.smoke49Kill-feed through-smoke
draw.icons.penetrate50Kill-feed wallbang
draw.icons.blind51Kill-feed blinded attacker
draw ยท Lua API ยท xhook