def swapBlock(self,cells,d,tlx1,tly1,tlx2,tly2,cols,rows,width,height):
if max(tlx1,tlx2)+cols < width and max(tly1,tly2)+rows < height and (max(tlx1,tlx2) - min(tlx1,tlx2) >= cols or max(tly1,tly2) - min(tly1,tly2) >= rows):
temp = []
for row in range( rows):
for col in range( cols):
temp.append(d[cells[tlx1+col][tly1+row]])
d[cells[tlx1+col][tly1+row]] = d[cells[tlx2+col][tly2+row]]
i = 0
for row in range( rows):
for col in range( cols):
d[cells[tlx2+col][tly2+row]] = temp[i]
i+=1
return True
else:
return False
评论列表
文章目录