local window = require('window') -- base prototype of all drawn things local m = { _t = 'entity', x = 0, y = 0, width = 0, height = 0, } m.__index = m function m:new() local t = {} t.__index = t return setmetatable(t, self) end function m:from(t) t.__index = t return setmetatable(t, self) end function m:setpos(x, y) self.x = x self.y = y end function m:draw() love.graphics.push('all') love.graphics.translate(self.x, self.y) love.graphics.setLineWidth(3) for _, l in ipairs(self.lines) do local mode = l[1] local segs = l[2] if mode == 'line' then love.graphics.line(segs) elseif mode == 'fill' then local ts = love.math.triangulate(segs) love.graphics.setColor(0, 0, 0) for i, t in ipairs(ts) do love.graphics.polygon('fill', t) end love.graphics.setColor(1, 1, 1) love.graphics.polygon('line', segs) else error(string.format("mode must be one of line or fill, not %s", mode)) end end love.graphics.pop() end return m