I have an SVG with a fish bowl shape, and I am attempting to calculate the volume of the pink area as a percentage of the space between the "fill level" and "empty level".
It's not straightforward to calculate this percentage due to the irregular shape of the fish bowl. A simple top-to-bottom approach won't give accurate results, so I need an algorithm to accurately determine the volume for various fish bowls of different shapes.
Is there a way to achieve this using JavaScript on an SVG element? If it is possible, how can I go about calculating these volumes within specific element areas as percentages?
Update: A sample SVG has been uploaded to jsfiddle