Rect::colliderect bug

Issue #215 closed
Anonymous created an issue

colliderect() sometimes returns 0 where it should clearly return 1. A few tests suggest that this is due to careless rounding down.

Example of intersecting rectangles for which colliderect() returns 0:

>>> r1 = Rect((0.1,0),(10,10))
>>> r2 = Rect((10,0),(10,10))
>>> r1.colliderect(r2)
>>> r2.colliderect(r1)

And similarly in the y direction.

Comments (8)

  1. Jason Marshall

    The most common use cases for the Rect class involve use with (non-OpenGL) 2D raster graphics, for which float values would not make sense. That's why Rect coerces floats to integers.

  2. Denis B

    Agree, did not read Rect documentation carefully. Though I think such a central remark could have been made more visible in the class documentation.

  3. Log in to comment