本文整理匯總了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
示例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
示例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)
示例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)