ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Client functions
  3. dxDrawCircle

Function

dxDrawCircle

ClientDrawing (dx)Identical to MTA:SA

Draws a circle, an ellipse or a pie slice with centre (x, y) and a radius in pixels. The short form takes just a colour as the fourth argument.

Syntax

Full

bool dxDrawCircle(float posX, float posY, float radius [, float startAngle = 0, float stopAngle = 360, int color = white, int centerColor = color, int segments = 32, float ratio = 1, bool postGUI = false])

Short

bool dxDrawCircle(float posX, float posY, float radius, int color)

Arguments

posXfloat
Centre X.
posYfloat
Centre Y.
radiusfloat
Radius.
startAnglefloat, optional = 0
Slice start angle in degrees (0 = right, grows clockwise).
stopAnglefloat, optional = 360
Slice end angle in degrees.
colorint, optional = tocolor(255, 255, 255)
Edge colour.
centerColorint, optional = color
Colour at the centre: different from color gives a radial gradient.
segmentsint, optional = 32
Number of edge segments (more = smoother edge).
ratiofloat, optional = 1
Width to height ratio (other than 1 = ellipse).
postGUIbool, optional = false
Draw above the GUI.

Returns

true if drawn.

Example

A full circle, a progress indicator as a slice, and a circle with a gradient.

addEventHandler("onClientRender", root, function()
    dxDrawCircle(100, 100, 30, tocolor(95, 207, 115))
    local progress = (getTickCount() % 3000) / 3000
    dxDrawCircle(200, 100, 30, -90, -90 + 360 * progress, tocolor(255, 122, 34))
    dxDrawCircle(300, 100, 30, 0, 360, tocolor(255, 122, 34, 0), tocolor(255, 122, 34, 220), 48)
end)

Notes

Fast path. A full single-colour circle with ratio = 1 and no postGUI is drawn by the game in one call; slices, gradients and ellipses go through triangles. The short form is recognised by a fourth argument above 720 (a colour from tocolor).

See also