What's the proper way to do this?
Here's the whole program for this test:
Code: Select all
local concavePolygon = {
0, 170,
300, 100,
600, 120,
900, 100,
1200, 170,
}
local triangles = love.math.triangulate ( concavePolygon )
local colors = {
{ 255, 128, 128, 255 },
{ 128, 255, 128, 255 },
{ 128, 128, 255, 255 },
{ 255, 255, 128, 255 },
{ 255, 128, 255, 255 },
{ 128, 255, 255, 255 },
}
love.window.setMode ( 1920, 1080 )
love.draw = function ( )
for triNo, triangle in ipairs ( triangles ) do
love.graphics.setColor ( colors [ triNo ] )
love.graphics.polygon ( "line", triangle )
end
-- highlight the vertices...
love.graphics.setColor ( 255, 255, 0, 255 )
for ptNo = 1, #concavePolygon, 2 do
local x = concavePolygon [ ptNo ]
local y = concavePolygon [ ptNo + 1 ]
love.graphics.circle ( "line", x, y, 3 )
end
end