本文整理匯總了Python中PyQt4.QtGui.QPolygonF.translated方法的典型用法代碼示例。如果您正苦於以下問題:Python QPolygonF.translated方法的具體用法?Python QPolygonF.translated怎麽用?Python QPolygonF.translated使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt4.QtGui.QPolygonF
的用法示例。
在下文中一共展示了QPolygonF.translated方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_QPolygon_intersection
# 需要導入模塊: from PyQt4.QtGui import QPolygonF [as 別名]
# 或者: from PyQt4.QtGui.QPolygonF import translated [as 別名]
def test_QPolygon_intersection(self):
tri1 = QVectorF([(0,0),(0,1),(1,0)])
tri2 = QVectorF([(1,0),(0,0),(1,1)])
tri3 = QVectorF([(.5,.5),(1,0),(0,0),(.5,.5)])
tri3i = QVector([(1,1),(1,0),(0,0),(1,1)])
sq1 = QVectorF([(0,0),(0,1),(1,1),(1,0)])
# Intersect two triangles
p1 = QPolygonF(tri1)
p2 = QPolygonF(tri2)
p3 = p1.intersected(p2)
self.assertTrue( p1 == p1 )
self.assertTrue( p1 == QPolygonF(tri1) )
self.assertTrue( p3 == QPolygonF(tri3) )
# Intersect two integer triangles
p1 = QtGui.QPolygon(map(lambda (x,y): QtCore.QPoint(x,y), [(0,0),(0,1),(1,0)]))
p2 = QtGui.QPolygon(map(lambda (x,y): QtCore.QPoint(x,y), [(1,0),(0,0),(1,1)]))
p3 = p1.intersected(p2)
self.assertTrue( p3 == QtGui.QPolygon(tri3i) )
# Test containment/overlapping
p1 = QtGui.QPolygonF(sq1)
for v1 in sq1: self.assertTrue( p1.contains(v1) ) # vertices are contained
self.assertTrue( p1.translated(2,0).intersected(p1).isEmpty() )
self.assertTrue( p1.translated(1,0).intersected(p1).isEmpty() ) # common edges do not overlap
self.assertFalse( p1.translated(.5,0).intersected(p1).isEmpty() )