Draw
The Draw utility provides functionality for rendering visual elements in the game world. It's built on top of Tinkr's Draw utility and provides additional features for color management and callback-based drawing.
Basic Usage
local Draw = Aurora.Draw
-- Register a drawing callback
Draw:RegisterCallback("myDrawing", function(canvas, unit)
-- Drawing code here
end, "units")
Callback Registration
RegisterCallback
Register a drawing callback for units, objects, or both.
Draw:RegisterCallback(name, callback, targetType)
name
: Unique identifier for the callbackcallback
: Function that will be called for drawingtargetType
: "units" | "objects" | "both" (default: "both")
UnregisterCallback
Remove a previously registered callback.
Draw:UnregisterCallback(name)
Drawing Methods
Atlas
Draw a texture from the game's atlas.
Draw:Atlas(atlasName, x, y, z, width, height, alpha, scale)
Example:
Draw:Atlas("Mobile-QuestIcon", unitPos.x, unitPos.y, unitPos.z + 3, 50, 50, 1, 0.4)
Color Management
GetColor
Get RGB values for predefined colors.
local r, g, b, a = Draw:GetColor(colorName, opacity)
Available Colors:
-- Basic Colors
"Red" -- RGB(255, 0, 0)
"Green" -- RGB(0, 255, 0)
"Blue" -- RGB(0, 0, 255)
"Yellow" -- RGB(254, 199, 74)
"Orange" -- RGB(255, 165, 0)
"Brown" -- RGB(205, 133, 63)
"Text" -- RGB(255, 255, 255)
-- Class Colors
"Deathknight" -- RGB(196, 30, 58)
"Demonhunter" -- RGB(163, 48, 201)
"Druid" -- RGB(255, 124, 10)
"Evoker" -- RGB(51, 147, 127)
"Hunter" -- RGB(170, 211, 114)
"Mage" -- RGB(63, 199, 235)
"Monk" -- RGB(0, 255, 152)
"Paladin" -- RGB(244, 140, 186)
"Priest" -- RGB(255, 255, 255)
"Rogue" -- RGB(255, 244, 104)
"Shaman" -- RGB(0, 112, 221)
"Warlock" -- RGB(135, 136, 238)
"Warrior" -- RGB(198, 155, 109)
-- Special
"Rainbow" -- Cycling RGB colors
Examples
Drawing Unit Markers
Draw:RegisterCallback("unitMarkers", function(canvas, unit)
if unit.enemy and unit.alive then
-- Draw red circle for enemies
local r, g, b, a = Draw:GetColor("Red", 70)
canvas:SetColor(r, g, b, a)
canvas:Circle(unit.position.x, unit.position.y, unit.position.z, 1)
end
end, "units")
Class-Colored Names
Draw:RegisterCallback("classNames", function(canvas, unit)
if unit.player then
local r, g, b, a = Draw:GetColor(unit.class2, 255)
canvas:SetColor(r, g, b, a)
canvas:Text(unit.name,"GameFontHighlight", unit.position.x, unit.position.y, unit.position.z + 2)
end
end, "units")
Best Practices
Performance
- Minimize the number of draw operations in callbacks
- Use appropriate target types to avoid unnecessary iterations
- Cache color values if using them frequently
- Remove callbacks when they're no longer needed
Common Pitfalls
- Don't create new vectors or perform heavy calculations in draw callbacks
- Be mindful of draw operation stacking and opacity
- Consider distance and visibility for drawing operations
- Remember that drawing happens every frame
Notes
Draw Updates
- Drawing callbacks are executed every frame
- Drawing is disabled while resting
- The Draw utility must be enabled with
Draw:Enable()
Color Management
- Colors are normalized to 0-255 range
- Opacity is optional and defaults to 90
- Class colors are automatically matched to WoW standards
- Rainbow color updates automatically
Tinkr's Native Drawing API
Click to view all available drawing methods
Coordinate and Camera Methods
-- Convert world coordinates to screen coordinates
Draw:WorldToScreen(wx, wy, wz)
-- Get current camera position
Draw:CameraPosition()
-- Map a value from one range to another
Draw:Map(value, fromLow, fromHigh, toLow, toHigh)
Color Management
-- Set color with normalized values (0-1)
Draw:SetColor(r, g, b, a)
-- Set color with raw values (0-255)
Draw:SetColorRaw(r, g, b, a)
-- Set alpha value
Draw:SetAlpha(a)
-- Convert hex color to RGB
Draw:HexToRGB(hex)
-- Set/Get color from object
Draw:SetColorFromObject(object)
Draw:GetColorFromObject(object)
Distance and Measurements
-- Calculate 3D distance between points
Draw:Distance(ax, ay, az, bx, by, bz)
-- Calculate 2D distance between points
Draw:Distance2D(x1, y1, x2, y2)
-- Set line width
Draw:SetWidth(width)
Rotation Methods
-- Rotate around X axis
Draw:RotateX(cx, cy, cz, px, py, pz, r)
-- Rotate around Y axis
Draw:RotateY(cx, cy, cz, px, py, pz, r)
-- Rotate around Z axis
Draw:RotateZ(cx, cy, cz, px, py, pz, r)
Drawing Primitives
-- Draw line with distance check
Draw:Line(x1, y1, z1, x2, y2, z2, maxD)
-- Draw line without distance check
Draw:LineRaw(x1, y1, z1, x2, y2, z2)
-- Draw 2D line
Draw:Line2D(sx, sy, ex, ey)
-- Draw circle
Draw:Circle(x, y, z, radius, steps)
-- Draw cylinder
Draw:Cylinder(x, y, z, radius, height)
-- Draw array of vectors
Draw:Array(vectors, x, y, z, rotationX, rotationY, rotationZ)
-- Draw text
Draw:Text(text, font, x, y, z)
-- Draw texture
Draw:Texture(config, x, y, z, alphaA)
-- Draw arc
Draw:Arc(x, y, z, size, arc, rotation)
-- Draw rectangle
Draw:Rectangle(x, y, z, w, l, rot)
Canvas Control
-- Clear the canvas
Draw:ClearCanvas()
-- Update the canvas
Draw:Update()
-- Show helper grid
Draw:Helper()
-- Enable drawing
Draw:Enable()
-- Disable drawing
Draw:Disable()
-- Check if drawing is enabled
Draw:Enabled()
-- Register sync callback
Draw:Sync(callback)
-- Create new canvas
Draw:New(canvas)
Using Native Methods
The native drawing methods provide lower-level access to the drawing system. They're useful when you need:
- Precise control over coordinates and transformations
- Custom shapes and patterns
- Performance optimization for complex drawings
- Direct manipulation of the canvas
Callback vs Canvas Management
Recommended: Single Canvas, Multiple Callbacks
-- Multiple callbacks sharing one canvas
Draw:RegisterCallback("enemies", function(canvas, unit)
if unit.enemy then
canvas:Circle(unit.position.x, unit.position.y, unit.position.z, 1)
end
end, "units")
Draw:RegisterCallback("friends", function(canvas, unit)
if unit.friendly then
canvas:Text(unit.name, "GameFontNormal", unit.position.x, unit.position.y, unit.position.z)
end
end, "units")
✅ Better performance, shared canvas, easy feature management
Not Recommended: Multiple Canvases
-- Separate canvas per feature
local enemyCanvas = Tinkr.Util.Draw:New()
enemyCanvas:Sync(function(self)
Aurora.ObjectManager.units:each(function(unit)
if unit.enemy then
self:Circle(unit.position.x, unit.position.y, unit.position.z, 1)
end
end)
end)
❌ Higher memory usage, redundant loops, complex management
Performance
- Cache frequently used values (
position
,enemy
, etc.) - Group similar operations (same color, same type)
- Use early returns for invalid states
- Avoid creating objects in callbacks