-1

I'm currently working on a paint program using python 2.7.5 and pygame. I came across an error with the ellipse tool and asked a classmate for some help and he said I was missing a .normalize(). I added it in and my tool was fixed. I'm currently just wondering what that function does. Here's the code it is used in:

        if mb[0] == 1 and canvas.collidepoint(mx,my):
        screen.set_clip(canvas)
        if tool == "ellipse":
            screen.blit(copy,(0,0))
            radius = Rect(startx,starty,mx-startx,my-starty)    #Area Ellipse is being drawn
            radius.normalize()
        if radius.height<sz2*2 or radius.width<sz2*2:
            draw.ellipse(screen,(c),(radius))
        else:
            draw.ellipse(screen,(c),(radius), sz2)
        screen.set_clip(None)
user2950875
  • 89
  • 3
  • 13
  • 1
    Read the docs: http://www.pygame.org/docs/ref/rect.html#pygame.Rect.normalize – jonrsharpe Jan 23 '14 at 22:46
  • 3
    This question appears to be off-topic because it is just asking for the documentation for a function, and any reasonable answer will just be [this link](http://www.pygame.org/docs/ref/rect.html#pygame.Rect.normalize). – abarnert Jan 23 '14 at 22:49

1 Answers1

3

First result googling "PyGame Rect Normalize":

PyGame Rect Docs

normalize()
correct negative sizes
normalize() -> None

This will flip the width or height of a rectangle if it has a negative size. The rectangle will remain in the same place, with only the sides swapped.

So in essence it ensures the width and height are positive, not negative.

mhlester
  • 22,781
  • 10
  • 52
  • 75