[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Fw: rect.center.. confusion over result.. or bad result?



On Thu, Dec 4, 2008 at 6:44 PM, Lin Parkh <lparkh@xxxxxxxxxxx> wrote:
> #I define a rectangle:
> tes =pygame.Rect(0,44,200,85)


Double-check the Constructor for a Rect:
http://www.pygame.org/docs/ref/rect.html
pygame.Rect(left, top, width, height): return Rect


>
> #now i would expect the center of this rectangle to be be
> ((200+0)/2),(44+85)/2)) in other words (100, 64) instead I get:
>
> tes.center
>
> (100, 86)
>
> Where did the 86 come from????
> Please advise. Thanks for any help!

Also look at the following attributes (top, left, right, bottom,
topleft... etc).

your rectangle's height is 85, and the top is at 44.
Half the height of the rect is 85 / 2 = 42, but that point must be
shifted 44 units in the horizontal:

42 + 44 = 86


-- 
brad [bradmontgomery.net]