Hacker News new | ask | show | jobs
by suyjuris 1434 days ago
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-...

1 comments

Pretty sure that's how squircles are supposed to be mathematically implemented—at least in the option based on superellipses: https://en.wikipedia.org/wiki/Squircle