Anvil Scripting Reference
  • Getting started
    • Introduction
  • ๐Ÿš€Examples
    • Create a speed overlay
    • Creating a Clock with ImGui
    • Calculating Distances Tool
  • โš™๏ธ User Settings
    • Make use of our settings API
  • ๐Ÿ“ฆNamespaces
    • engine
    • player
    • key
    • mouse
    • memory
    • draw
    • ImGui
  • ๐ŸงชTypes
    • Vec2
    • Vec3
    • Vec4
    • playerState
    • refDef
    • clientEntity
    • cg
    • usercmd
    • trace
    • dvar
  • ๐Ÿ“„Enums
    • CmdButton
    • ImGuiWindowFlags
    • ImGuiStyleVar
    • ImGuiCol
Powered by GitBook
On this page
  • Methods
  • draw.text(content, pos, color, fontSize, fontName)
  • draw.line(start, end, color, thickness)
  • draw.rectangle(topLeft, botRight, color, rounding)
  • draw.rectangleFilled(start, end, color, thickness)
  • draw.circle(center, radius, color, segments)
  • draw.circleFilled(center, radius, color, segments)
  1. Namespaces

draw

Let's you draw things to the screen.

PreviousmemoryNextImGui

Last updated 2 years ago

IMPORTANT

A single call to any methods of draw will not keep drawing, it is just for one single frame.

Therefore in order to render something every frame, attach an eventlistener to the

and listen to the event, like in the examples below.

Methods

draw.text(content, pos, color, fontSize, fontName)

  • content - The text you wish to draw

  • pos - The screen position where to draw the text as a

  • color - The color of the text as a , e.g. Vec4:new(255, 0, 0, 255) for red with 100% alpha

  • fontSize - The size of the text in pixels

  • fontName - The name of the font

Available Font sizes:

  • 12, 14, 16, 18, 24, 32, 36, 48, 60

Available Fonts:

  • Verdana

  • VerdanaBold

  • Impact

  • Beyblade

  • Dameron

  • RobotoMono-Light

Draws text at a position.

Example:

function render()
	draw.text("Hey", Vec2:new(200, 200), Vec4:new(255, 0, 0, 255), 60, "Verdana")
end

engine.addEventListener("render", render)

draw.line(start, end, color, thickness)

  • thickness - The thickness of the line in pixels

Draws a line from point A to B.

Example:

function render()
	draw.line(Vec2:new(200,300), Vec2:new(500, 500), Vec4:new(255, 0, 0, 255), 2, "Verdana")
end

engine.addEventListener("render", render)

draw.rectangle(topLeft, botRight, color, rounding)

  • rounding- Edge rounding in pixels

Draws a rectangle spanning from topLeft to botRight.

Example:

function render()
	draw.rectangle(Vec2:new(200,200), Vec2:new(250, 300), Vec4:new(255, 0, 0, 255), 0)
end

engine.addEventListener("render", render)

draw.rectangleFilled(start, end, color, thickness)

  • rounding- Edge rounding in pixels

Draws a filled rectangle spanning from topLeft to botRight.

Example:

function render()
	draw.rectangleFilled(Vec2:new(200,200), Vec2:new(250, 300), Vec4:new(255, 0, 0, 255), 0)
end

engine.addEventListener("render", render)

draw.circle(center, radius, color, segments)

  • radius - The radius of the circle in pixels

  • segments - The circle is made up of lines, the more segments the smoother

Draws a circle.

Example:

function render()
	draw.circle(Vec2:new(200,300), 60, Vec4:new(255, 0, 0, 255), 20)
end

engine.addEventListener("render", render)

draw.circleFilled(center, radius, color, segments)

  • radius - The radius of the circle in pixels

  • segments - The circle is made up of lines, the more segments the smoother

Draws a filled circle.

Example:

function render()
	draw.circleFilled(Vec2:new(200,300), 60, Vec4:new(255, 0, 0, 255), 20)
end

engine.addEventListener("render", render)

start - Start position of the line as a

end - End Position of the line as a

color - The color of the line as a , e.g. Vec4:new(255, 0, 0, 255) for red with 100% alpha

topLeft - Top left corner as a

botRight- Bottom right corner as a

color - The color of the rect as a , e.g. Vec4:new(255, 0, 0, 255) for red with 100% alpha

topLeft - Top left corner as a

botRight- Bottom right corner as a

color - The color of the rect as a , e.g. Vec4:new(255, 0, 0, 255) for red with 100% alpha

center - The center of the circle as a

color - The color of the circle as a , e.g. Vec4:new(255, 0, 0, 255) for red

center - The center of the circle as a

color - The color of the circle as a , e.g. Vec4:new(255, 0, 0, 255) for red

๐Ÿ“ฆ
engine
render
text
line
rectangle
rectangleFilled
circle
circleFilled
Vec2
Vec4
Vec2
Vec2
Vec4
Vec2
Vec2
Vec4
Vec2
Vec2
Vec4
Vec2
Vec4
Vec2
Vec4
Drawing text
Drawing a line
Drawing a rectangle
Drawing a filled rectangle
Drawing a circle