# bezierArc method Null safety

void bezierArc(
1. double x1,
2. double y1,
3. double rx,
4. double ry,
5. double x2,
6. double y2,
7. {bool large = false,
8. bool sweep = false,
9. double phi = 0.0}
)

Draws an elliptical arc from (x1, y1) to (x2, y2). The size and orientation of the ellipse are defined by two radii (rx, ry) The center (cx, cy) of the ellipse is calculated automatically to satisfy the constraints imposed by the other parameters. large and sweep flags contribute to the automatic calculations and help determine how the arc is drawn.

## Implementation

``````void bezierArc(
double x1, double y1, double rx, double ry, double x2, double y2,
{bool large = false, bool sweep = false, double phi = 0.0}) {
if (x1 == x2 && y1 == y2) {
// From https://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes:
// If the endpoints (x1, y1) and (x2, y2) are identical, then this is
// equivalent to omitting the elliptical arc segment entirely.
return;
}

if (rx.abs() <= 1e-10 || ry.abs() <= 1e-10) {
lineTo(x2, y2);
return;
}

if (phi != 0.0) {
// Our box bézier arcs can't handle rotations directly
// move to a well known point, eliminate phi and transform the other point
final mat = Matrix4.identity();
mat.translate(-x1, -y1);
mat.rotateZ(-phi);
final tr = mat.transform3(Vector3(x2, y2, 0));
_endToCenterParameters(0, 0, tr, tr, large, sweep, rx, ry);
} else {
_endToCenterParameters(x1, y1, x2, y2, large, sweep, rx, ry);
}
}``````