Calling Codeslinger

Hi All,

Hoping to get Codeslingers attention - I have a problem with loveCodea. That is I don’t seem to be able to fill ellipses by using the following code:


	background(0,0,255,255)
	stroke(255)
	strokeWidth(2)
	fill(125,125,125,255)
	ellipse(100,200,50,100)

Hope it’s not me being a little slow.

If anyone can help I’d appreciate it - I like to prototype on my PC as I find it easier to edit with.

Bri_G

:smiley:

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

Hi Codeslinger,

Thanks for the prompt feedback !!

‘Hope it’s not me being a little slow’. - that’s an apology if I was pestering when I could have made a stupid/obvious mistook (I have been known to make 'em).

Thanks for the hot fix - I’ll try them out and let you know how it goes. Thanks for the help loveCodea is a real boon for me.

Before I go - have you a list of the features not implemented in loveCodea, that would stop me (and others) pestering for updates.

Thanks again.

Bri_G

:smiley:

@Bri_G I have made a couple of small changes to loveCodea. I implemented close(),clip(), and made WIDTH&HEIGHTreturn non-hardcoded values. How would you like patches submitted?

Hi JockM,

That’s fantastic - best thing to do, if he’s amenable, is to pass them through Codeslinger then they can be checked for compatibility before release to the rest of the Codea population. You could also post your code so that other Codea users can see how it’s done - this should be a community project.

Thanks for the contribution.

Bri_G

=D>

@Bri_G oops I meant to address that to @Codeslinger and got distracted by something bright and shiny :wink: Mea Culpa

JockM, just post it where I can find it. Inline in this forum, in a pastebin, where ever. Perhaps with an example usage. I usually do the work on loveCodea based on what needs to be done to get some existing stuff working.

Bri_G, I haven’t checked how large the Codea API actually is, so I don’t want to make a list. 3D is far away on Löve2D (!), I haven’t looked at the physics API, so this is a huge “maybe”. You see, not really a list. I keep posting the games and examples that work with the wrapper.

@Codeslinger That is basically the same way I am working on loveCodea as well. So far I have done:

  • WIDTH
  • HEIGHT
  • close()
  • readProjectData() – only for strings
  • saveProjectData() – only for strings
  • clip()
  • enhanced to fill(), stroke(), strokeWidth, and tint() to return the current value

I’ll toss it up somewhere for you soon.

@Codeslinger You can find a zip of my enhancements here.

In addition to the enhancements I described in my previous post I have made a curde first cut at sound support. I used csfxr to make a set of basic sounds and saved them to OGG files (since Löve2d has some issues with non OGG files), for things like blit, jump, etc. These are included in the ZIP file.

I haven’t downloaded your latest update yet, so you will want to be aware of that as you reconcile the differences.

My next task is to see if I can get soundBuffer() to work…