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


Python Rect.intersects方法代碼示例

本文整理匯總了Python中rect.Rect.intersects方法的典型用法代碼示例。如果您正苦於以下問題:Python Rect.intersects方法的具體用法?Python Rect.intersects怎麽用?Python Rect.intersects使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rect.Rect的用法示例。


在下文中一共展示了Rect.intersects方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: generate_background

# 需要導入模塊: from rect import Rect [as 別名]
# 或者: from rect.Rect import intersects [as 別名]
def generate_background(pict, bbxes, min_height, min_width):
    for i in xrange(N_TRIALS):
        rand_bbx = Rect(pict.shape[0], pict.shape[1])
        intersects = True
        if rand_bbx.height < min_height or rand_bbx.width < min_width:
            continue
        intersects = False
        for bbx in bbxes:
            intersects = intersects or rand_bbx.intersects(bbx)
        if not intersects:
            break
    if not intersects: 
        return pict[rand_bbx.ymin:rand_bbx.ymax,rand_bbx.xmin:rand_bbx.xmax]
    else:
        return None
開發者ID:bellettif,項目名稱:smartCams,代碼行數:17,代碼來源:back_ground.py

示例2: rectOverlaps

# 需要導入模塊: from rect import Rect [as 別名]
# 或者: from rect.Rect import intersects [as 別名]
    def rectOverlaps(self, rect):
        minX,minY,maxX,maxY = self.getTileBoundsInclusive(rect)
        tw = self.tileWidth
        th = self.tileHeight

        for layer in self.collideLayers:

            for y in range(minY,maxY+1):
                for x in range(minX,maxX+1):
                    idx = x + y*layer.width
                    if layer.tileGIDs[idx] != 0:
                        r = Rect(x*tw, y*th, tw,th)
                        if r.intersects(rect):
                            return True
        return False
開發者ID:shilrobot,項目名稱:ld28,代碼行數:17,代碼來源:tilemap.py

示例3: rectOverlaps

# 需要導入模塊: from rect import Rect [as 別名]
# 或者: from rect.Rect import intersects [as 別名]
 def rectOverlaps(self, rect):
     # player collision test
     r = Rect(self.x,self.y,32,64)
     return r.intersects(rect)
開發者ID:shilrobot,項目名稱:ld28,代碼行數:6,代碼來源:busteddoor.py

示例4: Rect

# 需要導入模塊: from rect import Rect [as 別名]
# 或者: from rect.Rect import intersects [as 別名]
from rect import Rect

a_points = [(0, 0), (-1, 0), (-1, -1), (0, -1)]
b_points = [(0, 0), (-1, 0), (-1, -1), (0, -1)]

a_rect = Rect(0, 0, a_points)
b_rect = Rect(1, 0ls
    , b_points)

print a_rect.intersects(b_rect)
開發者ID:kkevinchou,項目名稱:Cheetah,代碼行數:12,代碼來源:test.py


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