It seems to consider left and top just fine to me and seems to be a proper union exactly like I'd expect. Have you had problems with it?
attached is a quick test I used. On 12/1/06, Lenard Lindstrom <[EMAIL PROTECTED]> wrote:
Does Rect.union ignore rectangle positions? That is, does it only return a rectangle whose width and height is the maximum of the widths and heights of the two compared rectangles rather than a rectangle that will actually cover the two rectangles as they are positioned? Lenard Lindstrom <[EMAIL PROTECTED]>
import pygame import sys import random def main(): pygame.init() screen = pygame.display.set_mode((640, 480)) rect1 = pygame.Rect(200,190,40,40) rect2 = pygame.Rect(320,330,40,10) while 1: for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() elif event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: sys.exit() screen.fill((0,0,0)) pygame.draw.rect(screen, (255,0,255), rect1) pygame.draw.rect(screen, (255,255,0), rect2) union_rect = rect1.union(rect2) pygame.draw.rect(screen, (255,255,255), union_rect, 1) pygame.display.flip() if __name__ == '__main__': main()