Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6686,6 +6686,7 @@ def uri(self):


class Matrix:
__slots__ = ("a", "b", "c", "d", "e", "f", )

def __abs__(self):
return math.sqrt(sum([c*c for c in self]))
Expand Down Expand Up @@ -6929,6 +6930,7 @@ def pretranslate(self, tx, ty):

class IdentityMatrix(Matrix):
"""Identity matrix [1, 0, 0, 1, 0, 0]"""
__slots__ = ("a", "b", "c", "d", "e", "f", )

def __hash__(self):
return hash((1,0,0,1,0,0))
Expand All @@ -6939,13 +6941,13 @@ def __init__(self):
def __repr__(self):
return "IdentityMatrix(1.0, 0.0, 0.0, 1.0, 0.0, 0.0)"

def __setattr__(self, name, value):
def __setattr__(self, name: str, value: float):
if name in "ad":
self.__dict__[name] = 1.0
object.__setattr__(self, name, 1.0)
elif name in "bcef":
self.__dict__[name] = 0.0
object.__setattr__(self, name, 0.0)
else:
self.__dict__[name] = value
raise ValueError(f"Expected one of 'abcdef', got {name} = {value}")

def checkargs(*args):
raise NotImplementedError("Identity is readonly")
Expand Down Expand Up @@ -10785,6 +10787,7 @@ def __del__(self):

del Point
class Point:
__slots__ = ("x", "y")

def __abs__(self):
return math.sqrt(self.x * self.x + self.y * self.y)
Expand Down Expand Up @@ -10972,6 +10975,7 @@ def unit(self):


class Quad:
__slots__ = ("ul", "ur", "ll", "lr")

def __abs__(self):
if self.is_empty:
Expand Down Expand Up @@ -11036,6 +11040,7 @@ def __init__(self, *args, ul=None, ur=None, ll=None, lr=None):
None.

'''

if not args:
self.ul = self.ur = self.ll = self.lr = Point()
elif len(args) > 4:
Expand Down Expand Up @@ -11204,7 +11209,8 @@ def transform(self, m):


class Rect:

__slots__ = ("x0", "y0", "x1", "y1")

def __abs__(self):
if self.is_empty or self.is_infinite:
return 0.0
Expand Down Expand Up @@ -12647,6 +12653,7 @@ class IRect:
IRect(top-left, bottom-right) - 2 points
IRect(sequ) - new from sequence or rect-like
"""
__slots__ = ("x0", "y0", "x1", "y1")

def __add__(self, p):
return Rect.__add__(self, p).round()
Expand Down
Loading