Try the demo here.
This example shows how to calculate the percentage of a rectangular area that is covered by one or more other rectangular shapes. For example, this method would calculate the percentage of the black square that is covered in red:
The process first breaks up the total area into smaller rectangles. Here's a visual representation of how the area is divided:
The smaller rectangles are then used to determine the total percentage covered by red.
For more info, check out the fully annotated CAPX.