-
Hello, I have a question regarding the intersect operation of the
My question would be, why it is important that the intersection replaces the current, as sometimes it might be handy to have both objects as well as the intersection after the calculation. Adding a deep copy of my first object seems unnecessarily complex as the resulting intersection will always be given by the Exampleimport fitz
rect1 = fitz.Rect(0,0,1,1)
rect2 = fitz.Rect(2,0,3,1)
print(f"Rect1: {rect1}")
print(f"Rect2: {rect2}")
inter = rect1.intersect(rect2)
print(f"Itersection: {inter}")
print(f"Rect1: {rect1}")
print(f"Rect2: {rect2}") Rect1: Rect(0.0, 0.0, 1.0, 1.0)
Rect2: Rect(2.0, 0.0, 3.0, 1.0)
Itersection: Rect(2.0, 0.0, 1.0, 1.0)
Rect1: Rect(2.0, 0.0, 1.0, 1.0)
Rect2: Rect(2.0, 0.0, 3.0, 1.0) You can see in the output, that System Info (for reproduction purposes, if needed):3.11.4 (main, Jun 7 2023, 10:13:09) [GCC 12.2.0] PyMuPDF 1.22.5: Python bindings for the MuPDF 1.22.2 library. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You in fact have all freedom you need - just use the notation that suits you best.
|
Beta Was this translation helpful? Give feedback.
You in fact have all freedom you need - just use the notation that suits you best.
r1.intersect(r2)
logic is the same as implemented in the base library.r = r1 & r2
. Here, the two original rectangles remain unchanged.r1 = r1 & r2
which obviously replaces r1 with result and is exactly the same asr1 &= r2
and corresponds tor1.intersect(r2)
.