45 lines
951 B
Lua
45 lines
951 B
Lua
|
|
local function gm(m)
|
|
return m == FILL and 'fill' or 'line'
|
|
end
|
|
|
|
return function(draw)
|
|
|
|
function draw:rect(m, x, y, w, h)
|
|
love.graphics.rectangle(gm(m), x, y, w, h)
|
|
return self
|
|
end
|
|
|
|
function draw:ellipse(m, x, y, rx, ry)
|
|
love.graphics.ellipse(gm(m), x, y, rx, ry)
|
|
if m == FILL then
|
|
self:ellipse(LINE, x, y, rx, ry)
|
|
end
|
|
return self
|
|
end
|
|
|
|
function draw:circle(m, x, y, r)
|
|
return self:ellipse(m, x, y, r, r)
|
|
end
|
|
|
|
function draw:triang(m, x, y, ox1, oy1, ox2, oy2)
|
|
if m == FILL then self:triang(LINE, x, y, ox1, oy1, ox2, oy2) end
|
|
love.graphics.polygon(gm(m), x, y, x + ox1, y + oy1, x + ox2, y + oy2)
|
|
return self
|
|
end
|
|
|
|
function draw:arc(m, cx, cy, r, sa, ea)
|
|
love.graphics.arc(gm(m), m == FILL and 'pie' or 'open',
|
|
cx, cy, r, sa, ea)
|
|
if m == FILL then self:arc(LINE, cx, cy, r, sa, ea) end
|
|
return self
|
|
end
|
|
|
|
function draw:text(t, x, y)
|
|
love.graphics.setFont(self.f)
|
|
love.graphics.print(t, x, y)
|
|
return self
|
|
end
|
|
|
|
end
|