Search code examples
mathgeometry

Calculating outer corner radius for concentric rounded corners of a border


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?


Solution

  • 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.