Page 1 of 1

Best way to draw a rounded-corner square image with borders?

Posted: Sun Apr 10, 2016 10:06 am
by bitinn
What's the best approach to drawing a square image with borders and rounded-corners.

To give an example, from this:
Screen Shot 2016-04-10 at 6.02.25 PM.png
Screen Shot 2016-04-10 at 6.02.25 PM.png (30.1 KiB) Viewed 3207 times
To this:
Screen Shot 2016-04-10 at 6.02.34 PM.png
Screen Shot 2016-04-10 at 6.02.34 PM.png (27.37 KiB) Viewed 3207 times
My first thought are line mode rectangle with radius on top of the image, but what about the image itself, how can I mask / clip the image with a rounded-corner square efficiently. I don't need a mesh here, do I?

PS: this is my post here, let me know if I am missing any forum rules :)

Re: Best way to draw a rounded-corner square image with borders?

Posted: Sun Apr 10, 2016 10:24 am
by pgimeno
If the border is thick enough, the corner will be hidden. In your case it is:

Image

So, the most efficient way is probably to draw the image (with a size smaller than the rounded rect) and the rounded rect over it.

Re: Best way to draw a rounded-corner square image with borders?

Posted: Sun Apr 10, 2016 10:50 am
by s-ol
and otherwise, you can use a stencstencil function to do the clipping. I would advise to make the stencil a bit smaller than the border also though, so you don't end up with any weird edges.

Re: Best way to draw a rounded-corner square image with borders?

Posted: Sun Apr 10, 2016 5:39 pm
by bitinn
Thx folks, stencil is what I want.

Re: Best way to draw a rounded-corner square image with borders?

Posted: Sun Apr 10, 2016 7:58 pm
by Manyrio
For border you can use GLSL shaders