Or am I a being a little slow? Codea is just one of my many interests, so it takes time …
Löve cannot draw ellipses, so they are drawn by hand (well, by algorithm). The function is still the one that came with loveCodify and it can only draw outlines.
But it’s good you’re asking for it. I’m currently looking at the new version of BattleChips and it looks as if I might need filled ellipses as well. (Don’t try it yet, Mark did some fancy stuff that is absolutely not rendered properly with loveCodea. If you do anyway, set the background color in draw() to some shade of gray to see something.)
Here’s a hot fix for filled ellipses:
function ellipse(x, y, width, height)
setContext(_context)
_invalidateImageData(_context)
if height == nil or width == height then
love.graphics.setLineWidth(_strokewidth)
local radius = width
if _ellipsemode == CENTER then radius = width / 2 end
if _fillmode == "fill" then
love.graphics.setColor(unpack(_fillcolor))
love.graphics.circle("fill", x, y, radius, 50)
end
local lw = _strokewidth
love.graphics.setLineWidth(_strokewidth)
love.graphics.setColor(unpack(_strokecolor))
love.graphics.circle("line", x, y, radius - lw / 2, 50)
else
if _fillmode == "fill" then
love.graphics.setColor(unpack(_fillcolor))
ellipse2("fill", x, y, width/2, height/2)
end
love.graphics.setLineWidth(_strokewidth)
love.graphics.setColor(unpack(_strokecolor))
ellipse2("line", x, y, width/2, height/2)
end
end
-- Love2d does not have a ellipse function, so we have todo it by ourself
-- a & b are axis-radius
function ellipse2(mode, x, y, a, b) --,stp,rot)
local stp=50
local rot=0
local m,rad,sa,ca,sb,cb,x1,y1,ast
m = math; rad = m.pi/180; ast = rad * 360/stp;
sb = m.sin(-rot * rad); cb = m.cos(-rot * rad)
local vertices = {}
for n = 1, stp do
sa = m.sin(ast*n) * b
ca = m.cos(ast*n) * a
x1 = x + ca * cb - sa * sb
y1 = y + ca * sb + sa * cb
table.insert(vertices, x1)
table.insert(vertices, y1)
end
love.graphics.polygon(mode, vertices)
end