forked from michael-donat/tf-mapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
60 lines (35 loc) · 1.19 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import sys
from PyQt4 import QtGui, QtCore
class Example(QtGui.QWidget):
def __init__(self):
super(Example, self).__init__()
self.initUI()
def initUI(self):
self.setGeometry(300, 300, 355, 280)
self.setWindowTitle('Brushes')
self.show()
def paintEvent(self, e):
import math
qp = QtGui.QPainter()
qp.begin(self)
qp.setBrush(QtGui.QColor('#000000'))
line = QtCore.QLineF(100,200,200,200)
theta = math.pi / 8
qp.drawLine(line)
d = 5
lineAngle = math.atan2(line.dy(), line.dx())
h = math.fabs(d/math.cos(lineAngle))
angle1 = math.pi + lineAngle + theta
angle2 = math.pi + lineAngle - theta
P1 = QtCore.QPointF(line.x2()+math.cos(angle1)*h,line.y2()+math.sin(angle1)*h)
P2 = QtCore.QPointF(line.x2()+math.cos(angle2)*h,line.y2()+math.sin(angle2)*h)
qp.drawPolygon(line.p2(), P1, P2)
qp.end()
def main():
app = QtGui.QApplication(sys.argv)
ex = Example()
ex.show()
ex.raise_()
sys.exit(app.exec_())
if __name__ == '__main__':
main()