def aa_rect_overlaps_circle(aa_rect, circle):
    d = circle.center - aa_rect.center
    # Point in the rect nearest to circle center.
    d_clamped = eu.Vector2(clamp(d.x, -aa_rect.rx, aa_rect.rx),
                           clamp(d.y, -aa_rect.ry, aa_rect.ry))

    return (d - d_clamped).magnitude_squared() < circle.r ** 2
Tells if an axis aligned rectangle and a circle overlap.
dataset/ETHPy150Open los-cocos/cocos/cocos/collision_model.py/aa_rect_overlaps_circle