So yeah, I'm releasing the function DrawPoly(). It can be used to draw any shape, regardless of the number of points or orientation of the shape. It can be fully deformable, transformable, or simply a static shape. The colour, alpha, and line thickness are all customisable.
There are a few problems though: There isn't (I think) a way of defining a polygon at runtime, it must all be set up at design time and it can't draw circles. To draw circles, use DrawSprite().
Also, there may be a few bugs that can be avoided by giving values for all arguments, but I might put preventatives in for that later. You can, however move, deform, rotate, scale, etc. a previously defined polygon, and if people want explanations, I'll give them later.
It seems fairly self explanatory, so there aren't any comments this time, but I'll explain more if I'm asked.
function DrawPoly(X,Y,r,g,b,a,thickness)
Xcount = 0
Ycount = 0
for i in ipairs(X) do
Xcount = Xcount + 1
end
for i in ipairs(Y) do
Ycount = Ycount + 1
end
if Xcount = Ycount then
for i in ipairs(X) do
if X[i+1] == nil then
DrawLine(X[i], Y[i], X[1], Y[1],r,g,b,a,r,g,b,a,thickness)
else
DrawLine(X[i], Y[i], X[i+1], Y[i+1],r,g,b,a,r,g,b,a,thickness)
end
end
else
MessageBox("One of your polygons has invalid coordinates.")
end
end
A demo is attached, so download it and have a look.