You could also apply this on an ellipse. The main idea is, to reduce the brightness depending on the distance to the edge.
So you have the width/height and the location (x, y). Now you must change the inner/outer radius from a absolute to a relative value.
Argh

at the moment I'm too tired to explain this complete.
Fabian