Skip to content

Commit 1ddb6fd

Browse files
src/: class IRect: moved method get_area() from utils.py to __init__.py.
1 parent a7e81ec commit 1ddb6fd

2 files changed

Lines changed: 10 additions & 16 deletions

File tree

src/__init__.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14642,6 +14642,16 @@ def contains(self, x):
1464214642
"""Check if x is in the rectangle."""
1464314643
return self.__contains__(x)
1464414644

14645+
def get_area(self, *args) -> float:
14646+
"""Calculate area of rectangle.\nparameter is one of 'px' (default), 'in', 'cm', or 'mm'."""
14647+
if args:
14648+
unit = args[0]
14649+
else:
14650+
unit = "px"
14651+
u = {"px": (1, 1), "in": (1.0, 72.0), "cm": (2.54, 72.0), "mm": (25.4, 72.0)}
14652+
f = (u[unit][0] / u[unit][1]) ** 2
14653+
return f * self.width * self.height
14654+
1464514655
def include_point(self, p):
1464614656
"""Extend rectangle to include point p."""
1464714657
rect = self.rect.include_point(p)
@@ -22845,8 +22855,6 @@ def colors_wx_list():
2284522855
recover_quad = utils.recover_quad
2284622856
recover_span_quad = utils.recover_span_quad
2284722857

22848-
IRect.get_area = utils.get_area
22849-
2285022858
Page.apply_redactions = utils.apply_redactions
2285122859
Page.delete_image = utils.delete_image
2285222860
Page.delete_widget = utils.delete_widget
@@ -22888,8 +22896,6 @@ def colors_wx_list():
2288822896

2288922897
Page.find_tables = find_tables
2289022898

22891-
Rect.get_area = utils.get_area
22892-
2289322899
TextWriter.fill_textbox = utils.fill_textbox
2289422900

2289522901

src/utils.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,18 +1098,6 @@ def get_links(page: pymupdf.Page) -> list:
10981098
return links
10991099

11001100

1101-
def get_area(*args) -> float:
1102-
"""Calculate area of rectangle.\nparameter is one of 'px' (default), 'in', 'cm', or 'mm'."""
1103-
rect = args[0]
1104-
if len(args) > 1:
1105-
unit = args[1]
1106-
else:
1107-
unit = "px"
1108-
u = {"px": (1, 1), "in": (1.0, 72.0), "cm": (2.54, 72.0), "mm": (25.4, 72.0)}
1109-
f = (u[unit][0] / u[unit][1]) ** 2
1110-
return f * rect.width * rect.height
1111-
1112-
11131101
def getDestStr(xref: int, ddict: dict) -> str:
11141102
"""Calculate the PDF action string.
11151103

0 commit comments

Comments
 (0)