-
-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add warning when using negative rect dimensions in draw module #3158
base: main
Are you sure you want to change the base?
Conversation
Added warning in docs Added test for this warning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems fair to me, LGTM !
while thinking about this, I realised that some other draw API also takes in rect style arguments. How are negative dims handled everywhere else. Whatever fix we do, we should try to be consistent with the approach everywhere |
I added same warning, docs and tests to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make all the 2.5.2 -> 2.5.3 in this PR?
Sure, here it comes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for the PR 🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not convinced this is the thing to do.
If it's a problem have the algorithm normalize the rect first?
Did some testing,
I still think the most straightforward way to fix this is normalize the rect arguments when they come in. (https://pyga.me/docs/ref/rect.html#pygame.Rect.normalize) |
Why is normalizing input rects bad:
So I will remove warning and only disable drawing if rect width/height is negative. |
Using negative rect dimension values have some undesirable results as shown in #2727.
This PR adds deprecation warning to these draw functions:
draw.rect
,draw.ellipse
,draw.arc
when using negative value for rect width and height.And prevents anything from being drawn at wrong position.
Warnings are also added to docs and tests.
This warning will also be added to
draw.aaellipse
in #3016Closes #2727
Sample code