Hello. How can I simply draw semi-transparent rounded rectangle? Most of code snippets I found on forums don't work.
Thanks for help.
rounded rectangle
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
rounded rectangle
DRAW DRAW - online painting app CLICK NUMBERS - cool game with numbers THEME LOVEFRAMES - a collection of my themes HOST FOR FREE - free hosting for online LOVE games STALK PEOPLE - a map of LOVE users
Re: rounded rectangle
For semi transparency use:
where a is the transparency from 1 (transparent) to 255 (solid).
for a rounded rectangle, I would just use a image.
Code: Select all
love.graphics.setColor(255, 255, 255, a)
--draw something
love.graphics.setColor(255, 255, 255, 255)
for a rounded rectangle, I would just use a image.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: rounded rectangle
Try a polygon. (Also, forum search is your friend )Nsmurf wrote:for a rounded rectangle, I would just use a image.
When I write def I mean function.
Re: rounded rectangle
kikito wrote:Try a polygon. (Also, forum search is your friend )Nsmurf wrote:for a rounded rectangle, I would just use a image.
The selected attachment does not exist anymore.
DRAW DRAW - online painting app CLICK NUMBERS - cool game with numbers THEME LOVEFRAMES - a collection of my themes HOST FOR FREE - free hosting for online LOVE games STALK PEOPLE - a map of LOVE users
Re: rounded rectangle
But it's still good to know about a polygon. How much better/faster is it to draw a polygon as opposed to an image?forums wrote:The selected attachment does not exist anymore.
Re: rounded rectangle
I made this once. Perhaps you can use it.
You can call it like this rwrc(10, 50, 200, 350, 40).
Code: Select all
local right = 0
local left = math.pi
local bottom = math.pi * 0.5
local top = math.pi * 1.5
function rwrc(x, y, w, h, r)
r = r or 15
love.graphics.rectangle("fill", x, y+r, w, h-r*2)
love.graphics.rectangle("fill", x+r, y, w-r*2, r)
love.graphics.rectangle("fill", x+r, y+h-r, w-r*2, r)
love.graphics.arc("fill", x+r, y+r, r, left, top)
love.graphics.arc("fill", x + w-r, y+r, r, -bottom, right)
love.graphics.arc("fill", x + w-r, y + h-r, r, right, bottom)
love.graphics.arc("fill", x+r, y + h-r, r, bottom, left)
end
Shallow indentations.
Re: rounded rectangle
Thanks Boolsheet! That is exactly what I was looking for!
DRAW DRAW - online painting app CLICK NUMBERS - cool game with numbers THEME LOVEFRAMES - a collection of my themes HOST FOR FREE - free hosting for online LOVE games STALK PEOPLE - a map of LOVE users
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: rounded rectangle
Omf. I forgot that LÖVE can draw arcs now.
Back in my time, we had to calculate segment coordinates with our bare trigonometrics functions. You youngsters have it very easy nowadays .
Back in my time, we had to calculate segment coordinates with our bare trigonometrics functions. You youngsters have it very easy nowadays .
When I write def I mean function.
Re: rounded rectangle
well, you still do if you don't want those extra two lines connecting the center point in line draw modekikito wrote:Back in my time, we had to calculate segment coordinates with our bare trigonometrics functions.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: rounded rectangle
Apparently, this is the third time I have to upload these things:
Help us help you: attach a .love.
Who is online
Users browsing this forum: Amazon [Bot], Bing [Bot] and 3 guests