Skip to content

drawPie

Draws a filled sector of a circle (a “pie slice”). This function can also draw a full circle if the angle difference exceeds . Unlike standard drawing functions, this one supports masking a texture inside the shape.

ui.drawPie(center, radius, angleFrom, angleTo, color, image)

This function renders a convex shape from the center point out to the arc defined by the start and end angles.

  • If angleTo is less than angleFrom, they are swapped automatically.
  • If the difference between angles is greater than math.tau (), it efficiently renders a full ui.drawCircleFilled instead.
  • If an image is provided, it applies ui.beginTextureShade to mask the texture within the pie shape.
ParameterTypeRequiredDefaultDescription
centervec2Yes-Screen coordinates for the center of the circle.
radiusnumberYes-The radius of the circle in pixels.
angleFromnumberYes-Starting angle in radians.
angleTonumberYes-Ending angle in radians.
colorrgbmNorgbm.colors.whiteThe fill color.
imageui.ImageSourceNonilAn optional texture (filename, ui.MediaPlayer, etc.) to draw inside the shape.
  • None

Draw a yellow circle with a “mouth” open (missing sector).

local center = vec2(100, 100)
local radius = 50
local yellow = rgbm(1, 1, 0, 1)
-- angles in radians
-- 0.2 rad to 6.08 rad leaves a slice open
ui.drawPie(center, radius, 0.2, math.tau - 0.2, yellow)