Skip to content

Commit

Permalink
src/__init__.py: Rect:{height, width}: fix to classic, never return -ve.
Browse files Browse the repository at this point in the history
  • Loading branch information
julian-smith-artifex-com committed Jan 14, 2024
1 parent 34661b3 commit 2e2c2ab
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10778,6 +10778,10 @@ def contains(self, x):
"""Check if containing point-like or rect-like x."""
return self.__contains__(x)

@property
def height(self):
return max(0, self.y1 - self.y0)

def include_point(self, p):
"""Extend to include point-like p."""
if len(p) != 2:
Expand Down Expand Up @@ -10899,15 +10903,17 @@ def transform(self, m):
self.x0, self.y0, self.x1, self.y1 = util_transform_rect(self, m)
return self

@property
def width(self):
return max(0, self.x1 - self.x0)

__div__ = __truediv__

bl = bottom_left
br = bottom_right
height = property(lambda self: abs(self.y1 - self.y0))
irect = property(round)
tl = top_left
tr = top_right
width = property(lambda self: abs(self.x1 - self.x0))


class Shape:
Expand Down

0 comments on commit 2e2c2ab

Please sign in to comment.