Title: [Bug] Shape.area calculates inaccurate cell coverage when constructed with overlapping Regions
Description:
The Shape geometric class tracks a collection of Region bounds. Currently, the Shape.area property calculates the aggregate coverage by executing a naive sum over each region's individual area:
@property
def area(self) -> int:
"""Cells covered by the shape."""
# TODO: Currently doesn't handle overlapping regions
return sum(region.area for region in self._regions)
If a Shape is instantiated with regions that intersect or overlap, the intersection cells are double-counted, resulting in a physically invalid area value that exceeds the genuine logical screen matrix coverage.
Expected Behavior:
The area property should correctly aggregate the union of the regions without double-counting intersections. While rigorous planar geometric unions might be expensive, ensuring Shape.area doesn't balloon past real values is critical for accurate UI layer render bounding.
Environment:
- Located in
src/textual/geometry.py:1364
Title: [Bug]
Shape.areacalculates inaccurate cell coverage when constructed with overlapping RegionsDescription:
The
Shapegeometric class tracks a collection ofRegionbounds. Currently, theShape.areaproperty calculates the aggregate coverage by executing a naive sum over each region's individual area:If a
Shapeis instantiated with regions that intersect or overlap, the intersection cells are double-counted, resulting in a physically invalid area value that exceeds the genuine logical screen matrix coverage.Expected Behavior:
The
areaproperty should correctly aggregate the union of the regions without double-counting intersections. While rigorous planar geometric unions might be expensive, ensuringShape.areadoesn't balloon past real values is critical for accurate UI layer render bounding.Environment:
src/textual/geometry.py:1364