MCPcopy Index your code
hub / github.com/pymupdf/PyMuPDF / Rect

Class Rect

src/__init__.py:14541–14829  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14539
14540
14541class Rect:
14542
14543 def __abs__(self):
14544 if self.is_empty or self.is_infinite:
14545 return 0.0
14546 return (self.x1 - self.x0) * (self.y1 - self.y0)
14547
14548 def __add__(self, p):
14549 if hasattr(p, "__float__"):
14550 return Rect(self.x0 + p, self.y0 + p, self.x1 + p, self.y1 + p)
14551 if len(p) != 4:
14552 raise ValueError("Rect: bad seq len")
14553 return Rect(self.x0 + p[0], self.y0 + p[1], self.x1 + p[2], self.y1 + p[3])
14554
14555 def __and__(self, x):
14556 if not hasattr(x, "__len__"):
14557 raise ValueError("bad operand 2")
14558
14559 r1 = Rect(x)
14560 r = Rect(self)
14561 return r.intersect(r1)
14562
14563 def __bool__(self):
14564 return not (max(self) == min(self) == 0)
14565
14566 def __contains__(self, x):
14567 if hasattr(x, "__float__"):
14568 return x in tuple(self)
14569 l = len(x)
14570 if l == 2:
14571 return util_is_point_in_rect(x, self)
14572 if l == 4:
14573 r = INFINITE_RECT()
14574 try:
14575 r = Rect(x)
14576 except Exception:
14577 if g_exceptions_verbose > 1: exception_info()
14578 r = Quad(x).rect
14579 return (self.x0 <= r.x0 <= r.x1 <= self.x1 and
14580 self.y0 <= r.y0 <= r.y1 <= self.y1)
14581 return False
14582
14583 def __eq__(self, rect):
14584 if not hasattr(rect, "__len__"):
14585 return False
14586 return len(rect) == 4 and not (self - rect)
14587
14588 def __getitem__(self, i):
14589 return (self.x0, self.y0, self.x1, self.y1)[i]
14590
14591 def __hash__(self):
14592 return hash(tuple(self))
14593
14594 def __init__(self, *args, p0=None, p1=None, x0=None, y0=None, x1=None, y1=None):
14595 """
14596 Rect() - all zeros
14597 Rect(x0, y0, x1, y1)
14598 Rect(top-left, x1, y1)

Callers 15

apn_bboxMethod · 0.85
popup_rectMethod · 0.85
rectMethod · 0.85
rectMethod · 0.85
page_cropboxMethod · 0.85
glyph_bboxMethod · 0.85
rectMethod · 0.85
_add_stamp_annotMethod · 0.85
_set_pageboxMethod · 0.85
clip_to_rectMethod · 0.85
artboxMethod · 0.85
bleedboxMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…