pygame-community / pygame-ce

🐍🎮 pygame - Community Edition is a FOSS Python library for multimedia applications (like games). Built on top of the excellent SDL library.
https://pyga.me
849 stars 140 forks source link

Using blur on a surface with either width or height equal to 0 won't raise a ValueError #2852

Closed damusss closed 4 months ago

damusss commented 4 months ago

I tried to fix issue https://github.com/pygame-community/pygame-ce/issues/2849 and I tested locally that surfaces with either width == 0 or height == 0 won't raise a misleading error message. I also moved the comparison between dst and src sizes as if src is (30, 50) and dst is (0, 20), without moving the check, the function would have passed returning a (0, 20) sized surface which would probably cause bugs, both src and dst must have the same zero sizes for it to return gracefully. Why not an exception? Like the issue creator said, all transform functions handle zero sized surfaces which are even returned some times (pygame.Font.render) so this one should be consistent. If you find anything wrong with my changes let me know. I also modified the docs and added a test.