Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gui): add Vector4D / Matrix4x4 classes
- Loading branch information
Showing
4 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from qtpy import QtGui | ||
|
||
|
||
class Matrix4x4(QtGui.QMatrix4x4): | ||
# def __repr__(self): | ||
# return f"{type(self).__name__}()" | ||
pass | ||
|
||
|
||
if __name__ == "__main__": | ||
matrix = Matrix4x4([1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]) | ||
print(matrix) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from qtpy import QtGui | ||
|
||
from prettyqt import core | ||
|
||
|
||
class Vector4D(QtGui.QVector4D): | ||
# def __repr__(self): | ||
# return f"{type(self).__name__}()" | ||
pass | ||
|
||
def __bool__(self): | ||
return not self.isNull() | ||
|
||
def __abs__(self) -> float: | ||
return self.length() | ||
|
||
def to_point(self) -> core.Point: | ||
return core.Point(self.toPoint()) | ||
|
||
def to_pointf(self) -> core.PointF: | ||
return core.PointF(self.toPointF()) | ||
|
||
|
||
if __name__ == "__main__": | ||
vector = Vector4D(0, 0, 0, 1) | ||
print(abs(vector)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters