MCPcopy Create free account
hub / github.com/pymupdf/PyMuPDF / intersect

Method intersect

src/__init__.py:14716–14731  ·  view source on GitHub ↗

Restrict to common rect with rect-like r.

(self, r)

Source from the content-addressed store, hash-verified

14714 return self
14715
14716 def intersect(self, r):
14717 """Restrict to common rect with rect-like r."""
14718 if not len(r) == 4:
14719 raise ValueError("Rect: bad seq len")
14720 r = Rect(r)
14721 if r.is_infinite:
14722 return self
14723 elif self.is_infinite:
14724 self.x0, self.y0, self.x1, self.y1 = r.x0, r.y0, r.x1, r.y1
14725 elif r.is_empty:
14726 self.x0, self.y0, self.x1, self.y1 = r.x0, r.y0, r.x1, r.y1
14727 elif self.is_empty:
14728 return self
14729 else:
14730 self.x0, self.y0, self.x1, self.y1 = util_intersect_rect(self, r)
14731 return self
14732
14733 def intersects(self, x):
14734 """Check if intersection with rectangle x is not empty."""

Callers 2

__and__Method · 0.95
intersectMethod · 0.45

Calls 2

RectClass · 0.85
util_intersect_rectFunction · 0.85

Tested by

no test coverage detected