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

Method prerotate

src/__init__.py:8795–8836  ·  view source on GitHub ↗

Calculate pre rotation and replace current matrix.

(self, theta)

Source from the content-addressed store, hash-verified

8793 (abs(self.a) < EPSILON and abs(self.d) < EPSILON)
8794
8795 def prerotate(self, theta):
8796 """Calculate pre rotation and replace current matrix."""
8797 theta = float(theta)
8798 while theta < 0: theta += 360
8799 while theta >= 360: theta -= 360
8800 if abs(0 - theta) < EPSILON:
8801 pass
8802
8803 elif abs(90.0 - theta) < EPSILON:
8804 a = self.a
8805 b = self.b
8806 self.a = self.c
8807 self.b = self.d
8808 self.c = -a
8809 self.d = -b
8810
8811 elif abs(180.0 - theta) < EPSILON:
8812 self.a = -self.a
8813 self.b = -self.b
8814 self.c = -self.c
8815 self.d = -self.d
8816
8817 elif abs(270.0 - theta) < EPSILON:
8818 a = self.a
8819 b = self.b
8820 self.a = -self.c
8821 self.b = -self.d
8822 self.c = a
8823 self.d = b
8824
8825 else:
8826 rad = math.radians(theta)
8827 s = math.sin(rad)
8828 c = math.cos(rad)
8829 a = self.a
8830 b = self.b
8831 self.a = c * a + s * self.c
8832 self.b = c * b + s * self.d
8833 self.c =-s * a + c * self.c
8834 self.d =-s * b + c * self.d
8835
8836 return self
8837
8838 def prescale(self, sx, sy):
8839 """Calculate pre scaling and replace current matrix."""

Callers 1

test_matrixFunction · 0.80

Calls

no outgoing calls

Tested by 1

test_matrixFunction · 0.64