本文整理汇总了Python中PyQt4.QtGui.QPolygonF.intersected方法的典型用法代码示例。如果您正苦于以下问题:Python QPolygonF.intersected方法的具体用法?Python QPolygonF.intersected怎么用?Python QPolygonF.intersected使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QPolygonF
的用法示例。
在下文中一共展示了QPolygonF.intersected方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_QPolygon_intersection
# 需要导入模块: from PyQt4.QtGui import QPolygonF [as 别名]
# 或者: from PyQt4.QtGui.QPolygonF import intersected [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() )