Vital.sandbox
Engine

engine.draw_circle

Client

Draws a filled circle on the canvas


Syntax

local status = engine.draw_circle(
    position, 
    radius, 
    color = {1, 1, 1, 1}, 
    stroke = 0, 
    stroke_color = {1, 1, 1, 1}, 
    rotation = 0, 
    pivot = {0, 0}
)

Must be called within the vital.sandbox:draw event. Invoking this function outside of that event will have no effect.

  • Inside the event — executes as expected, rendering the filled circle to the canvas each frame
  • Outside the event — the call will be silently ignored and nothing will be drawn
  • Recommended usage — register a handler via network:fetch("vital.sandbox:draw", true):on(...) and place all canvas draw calls inside it

Parameters

TypeNameDescription
vector2positionCenter point of the circle
floatradiusRadius of the circle in pixels
colorcolorFill color of the circle
floatstrokeOutline thickness in pixels — set to 0 to disable
colorstroke_colorColor of the outline
floatrotationRotation angle in radians
vector2pivotPivot point for rotation, relative to the circle's position

Returns

TypeNameDescription
boolstatustrue on successful execution, or false on failure

Examples

Draw circles with various styles
network:fetch("vital.sandbox:draw", true):on(function()
    --Draw a plain white circle
    engine.draw_circle({200, 200}, 50)

    --Draw a filled red circle with a dark outline
    engine.draw_circle({200, 200}, 50, {1, 0, 0, 1}, 3, {0.2, 0, 0, 1})

    --Draw a semi-transparent circle
    engine.draw_circle({200, 200}, 80, {0, 0.5, 1, 0.5})
end)

On this page