(center_x, center_y, source_x, source_y, width, height=None)
Determines where the rectangle centered at (center_x, center_y)
        having the given width and height intersects with a line drawn from
        (source_x, source_y) to (center_x, center_y).

        @see: ShapeDrawer.intersection_point
Determines where the rectangle centered at (center_x, center_y)
        having the given width and height intersects with a line drawn from
        (source_x, source_y) to (center_x, center_y).
Determines where the rectangle centered at ( center_x center_y ) having the given width and height intersects with a line drawn from ( source_x source_y ) to ( center_x center_y ) .
def intersection_point(center_x, center_y, source_x, source_y, width, height=None):
        """Determines where the rectangle centered at (center_x, center_y)
        having the given width and height intersects with a line drawn from
        (source_x, source_y) to (center_x, center_y).

        @see: ShapeDrawer.intersection_point"""
        height = height or width
        delta_x, delta_y = center_x - source_x, center_y - source_y

        if delta_x == 0 and delta_y == 0:
            return center_x, center_y

        if delta_y > 0 and delta_x <= delta_y and delta_x >= -delta_y:
            # this is the top edge
            ry = center_y - height / 2
            ratio = (height / 2) / delta_y
            return center_x - ratio * delta_x, ry

        if delta_y < 0 and delta_x <= -delta_y and delta_x >= delta_y:
            # this is the bottom edge
            ry = center_y + height / 2
            ratio = (height / 2) / -delta_y
            return center_x - ratio * delta_x, ry

        if delta_x > 0 and delta_y <= delta_x and delta_y >= -delta_x:
            # this is the left edge
            rx = center_x - width / 2
            ratio = (width / 2) / delta_x
            return rx, center_y - ratio * delta_y

        if delta_x < 0 and delta_y <= -delta_x and delta_y >= delta_x:
            # this is the right edge
            rx = center_x + width / 2
            ratio = (width / 2) / -delta_x
            return rx, center_y - ratio * delta_y

        if delta_x == 0:
            if delta_y > 0:
                return center_x, center_y - height / 2
            return center_x, center_y + height / 2

        if delta_y == 0:
            if delta_x > 0:
                return center_x - width / 2, center_y
            return center_x + width / 2, center_y
def intersection_point ( center_x , center_y , source_x , source_y , width , height = None ) : height = height or width delta_x , delta_y = center_x - source_x , center_y - source_y if delta_x == 0 and delta_y == 0 : return center_x , center_y if delta_y > 0 and delta_x <= delta_y and delta_x >= - delta_y : # this is the top edge ry = center_y - height / 2 ratio = ( height / 2 ) / delta_y return center_x - ratio * delta_x , ry if delta_y < 0 and delta_x <= - delta_y and delta_x >= delta_y : # this is the bottom edge ry = center_y + height / 2 ratio = ( height / 2 ) / - delta_y return center_x - ratio * delta_x , ry if delta_x > 0 and delta_y <= delta_x and delta_y >= - delta_x : # this is the left edge rx = center_x - width / 2 ratio = ( width / 2 ) / delta_x return rx , center_y - ratio * delta_y if delta_x < 0 and delta_y <= - delta_x and delta_y >= delta_x : # this is the right edge rx = center_x + width / 2 ratio = ( width / 2 ) / - delta_x return rx , center_y - ratio * delta_y if delta_x == 0 : if delta_y > 0 : return center_x , center_y - height / 2 return center_x , center_y + height / 2 if delta_y == 0 : if delta_x > 0 : return center_x - width / 2 , center_y return center_x + width / 2 , center_y