Skip to content

Draft: New HUD functions

Lactozilla requested to merge Lactozilla/SRB2:draw2d-functions into next

Adds drawRectangle, drawLine, drawTriangle, drawQuad, and drawPolygon to Lua.
Parameters:

drawRectangle(fixed x, fixed y, fixed w, fixed h, color+flags)
drawLine(fixed x1, fixed y1, fixed x2, fixed y2, color+flags)
drawTriangle(fixed x1, fixed y1, fixed x2, fixed y2, fixed x3, fixed y3, color+flags)
drawQuad(fixed x1, fixed y1, fixed x2, fixed y2, fixed x3, fixed y3, fixed x4, fixed y4, color+flags)
drawPolygon(table vertices, color+flags)

drawPolygon table format:

-- x and y are fixed point coordinates
local vertices = {
   { x = num, y = num },
   { x = num, y = num },
   -- (...)
   { x = num, y = num }
}
v.drawPolygon(vertices, 181)

-- or
vertices = {
   { num, num },
   { num, num },
   -- (...)
   { num, num }
}
v.drawPolygon(vertices, 181)

Also adds vector2 and vector3 libraries

Examples:

drawRectangle:
srb20051

drawLine:
srb20050

drawTriangle:
srb20052

drawPolygon:
srb20045

Edited by Lactozilla

Merge request reports

Loading