def intersection(line1, line2):
    """
    Return the coordinates of a point of intersection given two lines.
    Return None if the lines are parallel, but non-colli_near.
    Return an arbitrary point of intersection if the lines are colli_near.

    Parameters:
    line1 and line2: lines given by 4 points (x0,y0,x1,y1).
    """
    x1, y1, x2, y2 = line1
    u1, v1, u2, v2 = line2
    (a, b), (c, d) = (x2 - x1, u1 - u2), (y2 - y1, v1 - v2)
    e, f = u1 - x1, v1 - y1
    # Solve ((a,b), (c,d)) * (t,s) = (e,f)
    denom = float(a * d - b * c)
    if _near(denom, 0):
        # parallel
        # If colli_near, the equation is solvable with t = 0.
        # When t=0, s would have to equal e/b and f/d
        if b == 0 or d == 0:
            return None
        if _near(e / b, f / d):
            # colli_near
            px = x1
            py = y1
        else:
            return None
    else:
        t = (e * d - b * f) / denom
        # s = (a*f - e*c)/denom
        px = x1 + t * (x2 - x1)
        py = y1 + t * (y2 - y1)
    return px, py
Return the coordinates of a point of intersection given two lines.
    Return None if the lines are parallel, but non-colli_near.
    Return an arbitrary point of intersection if the lines are colli_near.

    Parameters:
    line1 and line2: lines given by 4 points (x0,y0,x1,y1).