[pygame] Rect.contains - bug or feature?
import pygame r1 = pygame.Rect(0, 0, 100, 100) r2 = pygame.Rect(50, 50, 0, 0) r1.contains(r2) 1 r3 = pygame.Rect(50, 50, 50, 50) r1.contains(r3) 1 r4 = pygame.Rect(100, 100, 0, 0) r1.contains(r4) 0 I would expect a 1 in the last line as well. Julian
Re: [pygame] Rect.contains - bug or feature?
Hi Julian jug wrote: import pygame r1 = pygame.Rect(0, 0, 100, 100) r2 = pygame.Rect(50, 50, 0, 0) r1.contains(r2) 1 r3 = pygame.Rect(50, 50, 50, 50) r1.contains(r3) 1 r4 = pygame.Rect(100, 100, 0, 0) r1.contains(r4) 0 I would expect a 1 in the last line as well. I wouldn't. r1 starts at position (0,0) and has a width and height of 100 each meaning is goes from 0,0 to 99, 99 which amounts to 100 pixels in each direction. r4 lies just outside of that. Note that the arguments to Rect aren't start and end position but rather x,y,w,h yours //Lorenz
Re: [pygame] Rect.contains - bug or feature?
Hm, but than, r1.bottomright should be (99, 99) and not (100, 100)!? Or is topleft inside and bottomright outside the rect? Julian Lorenz Quack wrote: Hi Julian jug wrote: import pygame r1 = pygame.Rect(0, 0, 100, 100) r2 = pygame.Rect(50, 50, 0, 0) r1.contains(r2) 1 r3 = pygame.Rect(50, 50, 50, 50) r1.contains(r3) 1 r4 = pygame.Rect(100, 100, 0, 0) r1.contains(r4) 0 I would expect a 1 in the last line as well. I wouldn't. r1 starts at position (0,0) and has a width and height of 100 each meaning is goes from 0,0 to 99, 99 which amounts to 100 pixels in each direction. r4 lies just outside of that. Note that the arguments to Rect aren't start and end position but rather x,y,w,h yours //Lorenz
Re: [pygame] Rect.contains - bug or feature?
On Thu, Oct 22, 2009 at 4:44 PM, jug j...@fantasymail.de wrote: Hm, but than, r1.bottomright should be (99, 99) and not (100, 100)!? Or is topleft inside and bottomright outside the rect? Yep, I think it says this in the docs.
Re: [pygame] Rect.contains - bug or feature?
Luke Paireepinart wrote: On Thu, Oct 22, 2009 at 4:44 PM, jug j...@fantasymail.de mailto:j...@fantasymail.de wrote: Hm, but than, r1.bottomright should be (99, 99) and not (100, 100)!? Or is topleft inside and bottomright outside the rect? Yep, I think it says this in the docs. Agreed. Thanks for the resolution. Julian