[transform] Add __eq__ / __ne__ to DecomposedTransform

This commit is contained in:
Behdad Esfahbod 2023-12-14 16:13:01 -07:00
parent ef6903e097
commit c3175b271a

View File

@ -422,6 +422,26 @@ class DecomposedTransform:
tCenterX: float = 0
tCenterY: float = 0
def __eq__(self, other):
if not isinstance(other, DecomposedTransform):
return NotImplemented
return (
self.translateX == other.translateX
and self.translateY == other.translateY
and self.rotation == other.rotation
and self.scaleX == other.scaleX
and self.scaleY == other.scaleY
and self.skewX == other.skewX
and self.skewY == other.skewY
and self.tCenterX == other.tCenterX
and self.tCenterY == other.tCenterY
)
def __ne__(self, other):
if not isinstance(other, DecomposedTransform):
return NotImplemented
return not self == other
@classmethod
def fromTransform(self, transform):
# Adapted from an answer on