Calculate the free area and overlap of complex shapes

Godot Version

v.4.3.stable

Question

Hi,
I try to compute the area of elements to find out, how well the user fitted the objects.
I’d like to calculate the overlap and the free area in a rectangle:
grafik

the shape of the sprite will change. Think stars and other shapes I’d prefer not to calculate using area-formulas.

I was thinking to create a image out of the elements and color in the background. Then count the pixel in color of the background.

I have no prior knowledge of shaders and couldn’t get results with a subviewport. I also tried to adapt some cryptic tutorials about changing pixel-colors but failed.

Thanks for any kind of help