VERGELua API

draw

2D drawing: text, rects, circles, textures, fonts.

draw.Text(x:number, y:number, text:string, color?:Color)

Draw top-left aligned text.

draw.TextOutlined(x:number, y:number, text:string, color?:Color, outlineColor?:Color)

Draw text with an outline.

draw.Rect(x:number, y:number, w:number, h:number, color?:Color)

Draw a filled rectangle by width and height.

draw.LineRect(x:number, y:number, w:number, h:number, color?:Color)

Draw an outlined rectangle by width and height.

draw.Line(x1:number, y1:number, x2:number, y2:number, color?:Color)

Draw a line between two points.

draw.FillCircle(x:number, y:number, radius:number, color?:Color)

Draw a filled circle.

draw.Circle(x:number, y:number, radius:number, color?:Color)

Draw an outlined circle.

draw.GetScreenSize():number,number

Screen width and height.

draw.GetTextSize(text:string):number,number

Rendered width and height of a text string.

draw.WorldToScreen(origin:Vector3):Vector3

World position to screen coordinates, or nil when off-screen.

draw.Color(r:number, g:number, b:number, a:number)

Set the current draw color used by primitives.

draw.String(x:number, y:number, text:string, color?:Color)

Alias of draw.Text.

draw.FilledRect(x1:number, y1:number, x2:number, y2:number, color?:Color)

Filled rectangle between two corner points.

draw.OutlinedRect(x1:number, y1:number, x2:number, y2:number, color?:Color)

Alias of draw.LineRect with corner points.

draw.FilledCircle(x:number, y:number, radius:number, color?:Color)

Alias of draw.FillCircle.

draw.FilledRectFade(x1:number, y1:number, x2:number, y2:number, a1:number, a2:number, horizontal:boolean)

Filled rectangle fading alpha from a1 to a2.

draw.FilledRectFastFade(x1:number, y1:number, x2:number, y2:number, fadeStart:number, fadeEnd:number, a1:number, a2:number, horizontal:boolean)

Filled rectangle with solid, then gradient, then solid alpha regions.

draw.ColoredCircle(x:number, y:number, radius:number, r:number, g:number, b:number, a:number)

Filled circle with an explicit RGBA color.

draw.OutlinedCircle(x:number, y:number, radius:number, segments:number)

Outlined circle with a segment count.

draw.TextShadow(x:number, y:number, text:string)

Text with a black outline.

textures

draw.CreateTexture(path:string):number

Load an image file into a texture, or -1 on failure.

draw.CreateTextureRGBA(rgba:string, w:number, h:number):number

Create a texture from raw RGBA8888 bytes, or -1.

draw.GetTextureSize(tex:number):number,number

Width and height of a texture.

draw.TexturedRect(tex:number, x1:number, y1:number, x2:number, y2:number)

Draw a texture rectangle tinted with the current draw color.

draw.TexturedPolygon(tex:number, vertices:table, clip:boolean)

Draw a textured polygon from {x, y, u, v} vertex tables.

draw.DeleteTexture(tex:number)

Free a texture created by CreateTexture.

fonts

draw.CreateFont(name:string, height:number, weight:number, flags?:number):number

Create a surface font and return its handle.

draw.AddFontResource(path:string)

Register a TTF file with the system.

Examples

Player box + health ESP

Draws a box, name and health bar above every living enemy.

callbacks.Register("Draw", function()
    local me = client.GetLocalPlayer()
    if not me:IsValid() then return end

    for _, ent in pairs(entities.GetPlayers()) do
        if ent:IsValid() and ent:IsAlive() and ent:GetTeam() ~= me:GetTeam() then
            local fx, fy = client.WorldToScreen(ent:GetAbsOrigin())
            local hx, hy = client.WorldToScreen(ent:GetAbsOrigin() + Vector3(0, 0, 72))
            if fx and fy and hx and hy then
                local h = fy - hy
                local w = h * 0.5
                local x1, y1 = fx - w / 2, fy - h
                local x2, y2 = fx + w / 2, fy

                draw.Color(255, 60, 60, 255)
                draw.FilledRect(x1, y1, x2, y2)

                local frac = math.max(ent:GetHealth(), 0) / math.max(ent:GetMaxHealth(), 1)
                draw.Color(80, 220, 80, 255)
                draw.FilledRect(x1 - 4, y1 + h * (1 - frac), x1 - 1, y2)

                draw.Color(255, 255, 255, 255)
                draw.Text(x1, y1 - 12, ent:GetName())
            end
        end
    end
end)