surface.DrawPoly
Example
Draws a red triangle in the top left corner of the screen.
local triangle = {
{ x = 100, y = 200 },
{ x = 150, y = 100 },
{ x = 200, y = 200 }
}
hook.Add("HUDPaint", "PolygonTest", function()
surface.SetDrawColor( 255, 0, 0, 255 )
draw.NoTexture()
surface.DrawPoly( triangle )
end )
Output: 

Example
Draws a yellow polygon in the top left corner of the screen.
Example
A helper function to draw a circle using surface.DrawPoly.
function draw.Circle( x, y, radius, seg )
local cir = {}
table.insert( cir, { x = x, y = y, u = 0.5, v = 0.5 } )
for i = 0, seg do
local a = math.rad( ( i / seg ) * -360 )
table.insert( cir, { x = x + math.sin( a ) * radius, y = y + math.cos( a ) * radius, u = math.sin( a ) / 2 + 0.5, v = math.cos( a ) / 2 + 0.5 } )
end
local a = math.rad( 0 ) -- This is needed for non absolute segment counts
table.insert( cir, { x = x + math.sin( a ) * radius, y = y + math.cos( a ) * radius, u = math.sin( a ) / 2 + 0.5, v = math.cos( a ) / 2 + 0.5 } )
surface.DrawPoly( cir )
end
hook.Add("HUDPaint", "PolygonCircleTest", function()
surface.SetDrawColor( 0, 0, 0, 200)
draw.NoTexture()
draw.Circle( ScrW() / 2, ScrH() / 2, 200, math.sin( CurTime() ) * 20 + 25 )
--Usage:
--draw.Circle( x, y, radius, segments )
end )