Use nuitka for compiling, reorganize py files
This commit is contained in:
48
source/point.py
Normal file
48
source/point.py
Normal file
@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
from .consts import CLOCKWISE
|
||||
from .qt5 import QtCore
|
||||
from .propertize import propertize, rename_attributes, snake_case
|
||||
|
||||
|
||||
@propertize("", "set_")
|
||||
@rename_attributes(snake_case)
|
||||
class Point(QtCore.QPoint):
|
||||
"""
|
||||
Point of coordinates (x, y)
|
||||
"""
|
||||
|
||||
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 __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 __repr__(self):
|
||||
return "Point({}, {})".format(self.x, self.y)
|
||||
|
||||
__str__ = __repr__
|
Reference in New Issue
Block a user