Update: Someone changed the title to this post to a possible answer ("Fourier decomposition of parametric shapes") but I changed it to a different title as that makes it clear what I was asking. As I think putting the answer in the title makes it confusing to a new reader.
I am learning about programming so this question may be obvious.
We know that a Fourier series can approximate any sort of waveform for example, a square tooth waveform has to be decomposed into curved waveforms using Fourier series that have infinite analytic terms.
My question is is there an analogue (2D version) algorithm to the known Fourier decomposition algorithm for implicit 2 variable equations? An example of what I mean is as follows. Consider $$aX^2+bY^2=c$$ is the equation of an ellipse. Is there an algorithm that can express an (infinite?) number the ellipses terms (and maybe terms representing other shapes) in a way to get a rectangle. Say, a rectangle 50 units wide and 100 units high centered at $(0,0)$. The output of the algorithm would be an analytic function differentiable everywhere (like a Fourier series). The analogue of the periodicity I would guess is the angle if the equations were converted to parametric form. So this algorithm (or concept) if it exists I would say is Fourier like.
I would imagine if such an algorithm exists then probably using a few terms to approximate the rectangle using ellipses would result in a rectangle with some curvature in its side and the corners of the rectangle wouldn't look sharp, and using enough terms to approximate the rectangle using ellipses would result in a rectangle (if the equation was plotted on the screen by a computer program) and the corners would look sharper and sides more straight. I'm aware there are ways to plot a rectangle but I want to know if this algorithm exists.
In other words, my question is, is there an algorithm that takes as input equations representing 2D shapes (using some representation) and outputs an analytical expression of a desired shape that may not be analytical everywhere (such as rectangle- and it must be able to do a rectangle shape) and I would suspect this algorithm has similarities to the existing Fourier algorithms.