Revert "move rotate to top"
This reverts commit 9d0f2392caaa70d285d7e071fe97d3b7ef1ef77a.
This commit is contained in:
parent
899d04ce03
commit
f2b5a32b35
44
point.py
Normal file
44
point.py
Normal file
@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
from consts import CLOCKWISE
|
||||
from qt5 import QtCore
|
||||
|
||||
class Point(QtCore.QPoint):
|
||||
"""
|
||||
Point of coordinates (x, y)
|
||||
"""
|
||||
|
||||
def __add__(self, o):
|
||||
return Point(self.x() + o.x(), self.y() + o.y())
|
||||
|
||||
def __sub__(self, o):
|
||||
return Point(self.x() - o.x(), self.y() - o.y())
|
||||
|
||||
def __mul__(self, k):
|
||||
return Point(k * self.x(), k * self.y())
|
||||
|
||||
def __truediv__(self, k):
|
||||
return Point(self.x() / k, self.y() / k)
|
||||
|
||||
__radd__ = __add__
|
||||
__rsub__ = __sub__
|
||||
__rmul__ = __mul__
|
||||
__rtruediv__ = __truediv__
|
||||
|
||||
def rotate(self, center, direction=CLOCKWISE):
|
||||
""" Returns the Point image of the rotation of self
|
||||
through 90° CLOKWISE or COUNTERCLOCKWISE around center"""
|
||||
if self == center:
|
||||
return self
|
||||
|
||||
p = self - center
|
||||
p = Point(-direction * p.y(), direction * p.x())
|
||||
p += center
|
||||
return p
|
||||
|
||||
def __repr__(self):
|
||||
return "Point({}, {})".format(self.x(), self.y())
|
||||
|
||||
__str__ = __repr__
|
Loading…
x
Reference in New Issue
Block a user