當前位置: 首頁>>代碼示例>>Python>>正文


Python QPolygonF.intersected方法代碼示例

本文整理匯總了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() )
開發者ID:benignvulcan,項目名稱:starship,代碼行數:26,代碼來源:qtmath.py


注:本文中的PyQt4.QtGui.QPolygonF.intersected方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。