Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calculating outer corner radius for concentric rounded corners of a border

Tags:

math

geometry

I have rectangle with a border. The rectangle is 50x50 with a corner radius of 5.

When using the same corner radius for the border the result is:

wrong border corner radius

But I actually need something like this:

correct border corner radius

How to calculate the border corner radius? Can this be calculated somehow with only the border width and corner radius?

like image 673
Adnan Mujkanovic Avatar asked Dec 01 '25 00:12

Adnan Mujkanovic


1 Answers

In order to have both corner-curves concentric use

outerradius = cornerradius + borderwidth

This will get the straight parts start and end in parallel at the same (horizontal or vertical) position, i.e. the center of both quarter-circles is at the same point.

like image 67
Yunnosch Avatar answered Dec 07 '25 02:12

Yunnosch



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!