docstringd and comments

This commit is contained in:
Will McGugan
2022-05-17 14:32:15 +01:00
parent 806017f0e2
commit 9f006bb770
2 changed files with 7 additions and 5 deletions

View File

@@ -63,6 +63,7 @@ class MapGeometry(NamedTuple):
return self.clip.intersection(self.region)
# Maps a widget on to its geometry (information that describes its position in the composition)
CompositorMap: TypeAlias = "dict[Widget, MapGeometry]"
@@ -171,10 +172,11 @@ class Compositor:
Iterable[tuple[int, int, int]]: Yields tuples of (Y, X1, X2)
"""
inline_ranges: dict[int, list[tuple[int, int]]] = {}
setdefault = inline_ranges.setdefault
for region_x, region_y, width, height in regions:
span = (region_x, region_x + width)
for y in range(region_y, region_y + height):
inline_ranges.setdefault(y, []).append(span)
setdefault(y, []).append(span)
for y, ranges in sorted(inline_ranges.items()):
if len(ranges) == 1:

View File

@@ -484,13 +484,13 @@ class Region(NamedTuple):
)
def intersection(self, region: Region) -> Region:
"""Get that covers both regions.
"""Get the overlapping portion of the two regions.
Args:
region (Region): A region that overlaps this region.
Returns:
Region: A new region that fits within ``region``.
Region: A new region that covers when the two regions overlap.
"""
# Unrolled because this method is used a lot
x1, y1, w1, h1 = self
@@ -511,10 +511,10 @@ class Region(NamedTuple):
"""Get a new region that contains both regions.
Args:
region (Region): [description]
region (Region): Another region.
Returns:
Region: [description]
Region: An optimally sized region to cover both regions.
"""
x1, y1, x2, y2 = self.corners
ox1, oy1, ox2, oy2 = region.corners