def test_unionall_ip(self): r1 = Rect(0, 0, 1, 1) r2 = Rect(-2, -2, 1, 1) r3 = Rect(2, 2, 1, 1) r1.unionall_ip([r2, r3]) self.assertEqual(Rect(-2, -2, 5, 5), r1)
def test_unionall_ip( self ): r1 = Rect( 0, 0, 1, 1 ) r2 = Rect( -2, -2, 1, 1 ) r3 = Rect( 2, 2, 1, 1 ) r1.unionall_ip( [r2,r3] ) self.assertEqual( Rect(-2, -2, 5, 5), r1 )
def set_screen_background(self): """ Update the background """ logger.log( 9, 'set_screen_background()') if not self.background: self.background = osd.get_singleton().getsurface(rect=self.rect) self.updates = [] elif len(self.updates) > 0: # find the topleft corner x = self.rect.right y = self.rect.bottom for i in self.updates: x = min(x, i.left) y = min(y, i.top) # find the total rect of the collisions upd = Rect(x, y, 0, 0) upd.unionall_ip(self.updates) self.updates = [] x = upd[0] - self.rect.left y = upd[1] - self.rect.top bg_tmp = osd.get_singleton().getsurface(rect=upd) self.background.blit(bg_tmp, (x, y)) self.surface.blit(self.background, (0,0))
def test_unionall_ip(self): r1 = Rect(0, 0, 1, 1) r2 = Rect(-2, -2, 1, 1) r3 = Rect(2, 2, 1, 1) r1.unionall_ip([r2, r3]) self.assertEqual(Rect(-2, -2, 5, 5), r1) # Bug for an empty list. Would return a Rect instead of None. self.assertTrue(r1.unionall_ip([]) is None)
def test_unionall_ip( self ): r1 = Rect( 0, 0, 1, 1 ) r2 = Rect( -2, -2, 1, 1 ) r3 = Rect( 2, 2, 1, 1 ) r1.unionall_ip( [r2,r3] ) self.assertEqual( Rect(-2, -2, 5, 5), r1 ) # Bug for an empty list. Would return a Rect instead of None. self.assertTrue(r1.unionall_ip( [] ) is None)