I wrote this post before, but it got lost (together with everything else done on the backup server, if I'm right).
But anyhow:
Introducting love.graphics.roundrect, version 1.1.
Usage: love.graphics.roundrect(mode, x, y, width, height, xround, yround)
The first four arguments are the same as love.graphics.rectangle. xround and yround determine the size of the rounding.
And it works completely fine with alpha. I made it to use for Space.
License: let's say WTFPL. Whatever you want to do with it, it is fine.
roundrect: a fully functioning implementation
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
roundrect: a fully functioning implementation
Help us help you: attach a .love.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: roundrect: a fully functioning implementation
It is a different version though: supplying too large values for xround and/or yround doesn't do any harm anymore.
Help us help you: attach a .love.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: roundrect: a fully functioning implementation
mmm...
a polygon. Very smart!
If I could just minimize the number of calls to sin and cos...
I might give it a try during this week.
a polygon. Very smart!
If I could just minimize the number of calls to sin and cos...
I might give it a try during this week.
When I write def I mean function.
Re: roundrect: a fully functioning implementation
Hello Robin! Sorry (or not) to revive this. I was doing a small function for doing rounded corners buttons (in 7.2). It works well and it's enough for me. But since my function is limited to a solid object, I got curious when I saw this thread and what alternative (something more mathematical I guess) could be done. However your examples in thread are gone. Please, just for educative motifs can you respost? Thanks.
As you see my solution spite working nicely, was quite rudimentary and crude. Draw four circles at corners and drop 2 rectangles over (ashamed)
As you see my solution spite working nicely, was quite rudimentary and crude. Draw four circles at corners and drop 2 rectangles over (ashamed)
Code: Select all
function UI.bt:new(args)
local v = {}
if args == nil then return end
--
if args.key then v.key = args.key else return end
if args.label then v.label = args.label else return end
v.bg_color = args.bg_color or color.grey
v.txt_color = args.txt_color or color.white
v.hover_color = args.hover_color or color.orange
v.x = args.x or 100
v.y = args.y or 100
v.w = args.w or tile_w or 32
v.h = args.h or tile_h or 32
v.r = args.radius or 5
v.v = args.vertices or 3
v.hover = false
v.hidden = false
table.insert (UI.bt,v)
end -- end of function
function UI.bt:draw()
if #UI.bt == 0 or UI.bt == nil then return end
for i,v in ipairs(UI.bt) do
setColor( v.bg_color )
love.graphics.rectangle("fill",v.x+v.r,v.y,v.w-v.r*2,v.h)
love.graphics.rectangle("fill",v.x,v.y+v.r,v.w,v.h-v.r*2)
love.graphics.circle("fill", v.x+v.r, v.y+v.r, v.r, v.v*v.r) -- NW
love.graphics.circle("fill", v.x+v.w-v.r, v.y+v.r, v.r, v.v*v.r) -- NE
love.graphics.circle("fill", v.x+v.w-v.r, v.y+v.h-v.r, v.r, v.v*v.r) -- SE
love.graphics.circle("fill", v.r+v.x, v.h+v.y-v.r, v.r, v.v*v.r) -- SW
-- text stuff
end
Re: roundrect: a fully functioning implementation
perhaps with the release of 0.8 you would be able to use arcs to produce lined rounded rectangles?
Re: roundrect: a fully functioning implementation
Yes, I already saw that some time ago in changelog. And that was very good news. But as for now it's better make it compatible with current stable version at least until 0.8 is available for all 3 OS's. But since this thread is from 2010 and Robin's function have "mode" I only can guess he found a way of simulate arcs or something close. So I got curious on this.Kingdaro wrote:perhaps with the release of 0.8 you would be able to use arcs to produce lined rounded rectangles?
- trubblegum
- Party member
- Posts: 192
- Joined: Wed Feb 22, 2012 10:40 pm
Re: roundrect: a fully functioning implementation
Looks neato .. I guess if 0.8 is adding to line-drawing functionality, a curve-drawing lib would be a bit pointless right now.
- Jasoco
- Inner party member
- Posts: 3725
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: roundrect: a fully functioning implementation
I wish we could draw ovals by way of extra parameters to the circle function. (X squish, Y squish and rotation)
Re: roundrect: a fully functioning implementation
Would be? Remember (if I'm right) that Linux users haven't yet a 0.8 version. Between use 0.8 because just only one command or use a outdated library (but that function in all Love versions) I would choose later one!trubblegum wrote:Looks neato .. I guess if 0.8 is adding to line-drawing functionality, a curve-drawing lib would be a bit pointless right now.
Hmmm... Maybe use l.g.scale to distort circles to make them ovals?I wish we could draw ovals by way of extra parameters to the circle function. (X squish, Y squish and rotation)
Who is online
Users browsing this forum: Ahrefs [Bot] and 1 guest