def bezier_arc(x1, y1, x2, y2, start_angle=<NUM_LIT:0>, extent=<NUM_LIT>):
x1,y1, x2,y2 = min(x1,x2), max(y1,y2), max(x1,x2), min(y1,y2)<EOL>if abs(extent) <= <NUM_LIT>:<EOL><INDENT>frag_angle = float(extent)<EOL>nfrag = <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>nfrag = int(ceil(abs(extent)/<NUM_LIT>))<EOL>if nfrag == <NUM_LIT:0>:<EOL><INDENT>warnings.warn('<STR_LIT>' % extent)<EOL>return []<EOL><DEDENT>frag_angle = float(extent) / nfrag<EOL><DEDENT>x_cen = (x1+x2)/<NUM_LIT><EOL>y_cen = (y1+y2)/<NUM_LIT><EOL>rx = (x2-x1)/<NUM_LIT><EOL>ry = (y2-y1)/<NUM_LIT><EOL>half_angle = radians(frag_angle) / <NUM_LIT:2><EOL>kappa = abs(<NUM_LIT> / <NUM_LIT> * (<NUM_LIT:1.> - cos(half_angle)) / sin(half_angle))<EOL>if frag_angle < <NUM_LIT:0>:<EOL><INDENT>sign = -<NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>sign = <NUM_LIT:1><EOL><DEDENT>point_list = []<EOL>for i in range(nfrag):<EOL><INDENT>theta0 = radians(start_angle + i*frag_angle)<EOL>theta1 = radians(start_angle + (i+<NUM_LIT:1>)*frag_angle)<EOL>c0 = cos(theta0)<EOL>c1 = cos(theta1)<EOL>s0 = sin(theta0)<EOL>s1 = sin(theta1)<EOL>if frag_angle > <NUM_LIT:0>:<EOL><INDENT>signed_kappa = -kappa<EOL><DEDENT>else:<EOL><INDENT>signed_kappa = kappa<EOL><DEDENT>point_list.append((x_cen + rx * c0,<EOL>y_cen - ry * s0,<EOL>x_cen + rx * (c0 + signed_kappa * s0),<EOL>y_cen - ry * (s0 - signed_kappa * c0),<EOL>x_cen + rx * (c1 - signed_kappa * s1),<EOL>y_cen - ry * (s1 + signed_kappa * c1),<EOL>x_cen + rx * c1,<EOL>y_cen - ry * s1))<EOL><DEDENT>return point_list<EOL>
Compute a cubic Bezier approximation of an elliptical arc.

    (x1, y1) and (x2, y2) are the corners of the enclosing rectangle.
    The coordinate system has coordinates that increase to the right and down.
    Angles, measured in degress, start with 0 to the right (the positive X axis) 
    and increase counter-clockwise.
    The arc extends from start_angle to start_angle+extent.
    I.e. start_angle=0 and extent=180 yields an openside-down semi-circle.

    The resulting coordinates are of the form (x1,y1, x2,y2, x3,y3, x4,y4)
    such that the curve goes from (x1, y1) to (x4, y4) with (x2, y2) and
    (x3, y3) as their respective Bezier control points.