What's the equation for a rectircle? (Perfect rounded-corner rectangle without stretching on only one dim)

A rounded rectangle of size $2a\times2b$ with rounding radius $r$ is given by $$f(x;a,r) + f(y;b,r) = 1$$ where $$f(x;a,r)=\begin{cases}\left(\frac{|x|-(a-r)}r\right)^2&\text{if $|x|\ge a-r$,}\\0&\text{otherwise.}\end{cases}$$ You want to approximate this with some function of the form $(|x|/a)^p$. Compare derivatives at $x=a$ and you get $p=2a/r$. So a "rectircle" of size $2a\times2b$ with rounding radius $r$ is given by $$\left(\frac{|x|}a\right)^{2a/r} + \left(\frac{|y|}b\right)^{2b/r}=1.$$

enter image description here

enter image description here


This is all visually based so no proof here. But currently I have, given approximate corner radius $r$ and width $w$, height $h$, let $\alpha = w/2$, $\beta = h/2$, the the equation for a nice-enough looking rounded-corner rectangle, aka a rectircle, is:

$$ |\dfrac{x}{\alpha}|^{2\alpha/r} + |\dfrac{y}{\beta}|^{2\beta/r} = 1 \\ \alpha, \beta, r \gt 0 $$

The $\alpha, \beta$ in the exponent seems to get rid of the stretching I was talking about.

Here's a sample: rectircle 1

And with half that approximate corner radius: rectircle 2