All pastes #2110018 Raw Edit

rect.inflate_ip()

public python v1 · immutable
#2110018 ·published 2012-02-05 22:38 UTC
rendered paste body
import pygamepygame.init()class Box(pygame.sprite.Sprite):                 def __init__(self):        pygame.sprite.Sprite.__init__(self)        self.image = pygame.Surface((10, 10))        self.rect = self.image.get_rect() b = Box()  print "initial b.rect : %s     b.rect.center : %s" % (b.rect, b.rect.center)b.rect.inflate_ip(5, 5)print "inflated b.rect : %s     b.rect.center : %s\n" % (b.rect, b.rect.center)c = Box()  print "initial c.rect : %s     c.rect.center : %s" % (c.rect, c.rect.center)c.rect.inflate_ip(-5, -5)print "inflated c.rect : %s     c.rect.center : %s" % (c.rect, c.rect.center)# outputs :## initial b.rect : <rect(0, 0, 10, 10)>     b.rect.center : (5, 5)# inflated b.rect : <rect(-2, -2, 15, 15)>     b.rect.center : (5, 5)## initial c.rect : <rect(0, 0, 10, 10)>     c.rect.center : (5, 5)# inflated c.rect : <rect(2, 2, 5, 5)>     c.rect.center : (4, 4)