]> Repositories - hackapet/Adafruit_Blinka_Displayio.git/blobdiff - displayio/_area.py
More displayio code updates
[hackapet/Adafruit_Blinka_Displayio.git] / displayio / _area.py
index 3eba700590bb7bb03249aad980ad2d9bc1f53275..5b96e9370bf4e6b72b276f0e6bae3c89f9de897d 100644 (file)
@@ -25,9 +25,9 @@ __repo__ = "https://github.com/adafruit/Adafruit_Blinka_Displayio.git"
 
 
 class Area:
-    # pylint: disable=invalid-name,missing-function-docstring
-    """Area Class to represent an area to be updated. Currently not used."""
+    """Area Class to represent an area to be updated."""
 
+    # pylint: disable=invalid-name
     def __init__(self, x1: int = 0, y1: int = 0, x2: int = 0, y2: int = 0):
         self.x1 = x1
         self.y1 = y1
@@ -56,7 +56,8 @@ class Area:
         self.x2 += dx
         self.y2 += dy
 
-    def _compute_overlap(self, other, overlap) -> bool:
+    def compute_overlap(self, other, overlap) -> bool:
+        """Compute the overlap between two areas. Returns True if there is an overlap."""
         a = self
         overlap.x1 = max(a.x1, other.x1)
         overlap.x2 = min(a.x2, other.x2)
@@ -79,12 +80,11 @@ class Area:
             self.y1, self.y2 = self.y2, self.y1
 
     def _union(self, other, union):
-        # pylint: disable=protected-access
         if self._empty():
             self._copy_into(union)
             return
-        if other._empty():
-            other._copy_into(union)
+        if other._empty():  # pylint: disable=protected-access
+            other._copy_into(union)  # pylint: disable=protected-access
             return
 
         union.x1 = min(self.x1, other.x1)
@@ -93,12 +93,15 @@ class Area:
         union.y2 = max(self.y2, other.y2)
 
     def width(self) -> int:
+        """Return the width of the area."""
         return self.x2 - self.x1
 
     def height(self) -> int:
+        """Return the height of the area."""
         return self.y2 - self.y1
 
     def size(self) -> int:
+        """Return the size of the area."""
         return self.width() * self.height()
 
     def __eq__(self, other):
@@ -113,7 +116,7 @@ class Area:
         )
 
     @staticmethod
-    def _transform_within(
+    def transform_within(
         mirror_x: bool,
         mirror_y: bool,
         transpose_xy: bool,
@@ -121,6 +124,7 @@ class Area:
         whole: Area,
         transformed: Area,
     ):
+        """Transform an area within a larger area."""
         # pylint: disable=too-many-arguments
         # Original and whole must be in the same coordinate space.
         if mirror_x: