Rounded corners and quads?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
unixfreak
Citizen
Posts: 82
Joined: Thu Oct 15, 2015 6:25 am
Location: Bristol, UK
Contact:

Rounded corners and quads?

Post by unixfreak »

Hello! I had to sign up to ask this, as i've been searching different methods for the past day, but have not found a solution yet. :vamp:

Basically, i have alot of square platforms in a game i have recently started working on. I would like to get the bottom corners of the platforms to be rounded.

They look like this at the moment:
Image
And here is my crude gimp edit of how i would like them to look:
Image

The draw section contains this relevant part to draw the platform.

Code: Select all

--the platform
local quad = love.graphics.newQuad( 0,0, platform.w, platform.h, platform.gfx:getDimensions() )
platform.gfx:setWrap("repeat", "repeat")
love.graphics.draw(platform.gfx, quad, platform.x,platform.y)

--the grass top
love.graphics.setColor(30,80,30,255)
love.graphics.rectangle("fill", platform.x, platform.y-5, platform.w, 10)	
Is there a way to apply some kind of mask to a quad, or some way to delete part of the quad so that it is fully transparent? I'm aware of the arc drawing function, but can only draw an arc on top of the quad. The problem there is that the square corner underneath, is still there...
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

Re: Rounded corners and quads?

Post by micha »

Hi and welcome to the forum!

Rounded corners cannot be achieved with quads directly, because quads are always rectangular. There are some other solutions:

1) Put the rounded corners into the image file. If you look at some free art files, you see that this is what most people are doing (example). That means you have to draw individual tiles for all possible positions of a tile (center, top, bottom, left, right, top-left, ...)
2) You can try to use a mesh instead of a quad. A mesh is basically a quad with arbitrary (polygon-) geometry. See here.
User avatar
unixfreak
Citizen
Posts: 82
Joined: Thu Oct 15, 2015 6:25 am
Location: Bristol, UK
Contact:

Re: Rounded corners and quads?

Post by unixfreak »

Thanks for the speedy reply, I did try already with some rounded images placed on the corners, but the tiling within the quad wouldn't match up depending on the height/width of the platform. I will try look at using a mesh. :awesome:
User avatar
DeltaF1
Citizen
Posts: 64
Joined: Mon Apr 27, 2015 4:12 pm
Location: The Bottom of the Stack
Contact:

Re: Rounded corners and quads?

Post by DeltaF1 »

you could also use stencils
Post Reply

Who is online

Users browsing this forum: Google [Bot], K2-XT and 126 guests