I once implemented rounded rectangles by drawing circles with regards to arbitrary p-norms [1,2] – I did not think about it at the time, but the derivatives are probably quite nice. (It did have the advantage of using the same code for rounded rectangles and for circles.)
[1] https://en.wikipedia.org/wiki/Norm_(mathematics)#p-norm
[2] https://en.wikipedia.org/wiki/Lp_space#/media/File:Vector-p-...