arc static method
Implementation
static OpSet arc(PointD center, double width, double height, double start,
double stop, bool closed, bool roughClosure, DrawConfig config) {
final List<Op> ops = [];
final double cx = center.x;
final double cy = center.y;
double rx = (width / 2).abs();
double ry = (height / 2).abs();
rx += config.offsetSymmetric(rx * 0.01);
ry += config.offsetSymmetric(ry * 0.01);
double strt = start;
double stp = stop;
while (strt < 0) {
strt += pi * 2;
stp += pi * 2;
}
if ((stp - strt) > (pi * 2)) {
strt = 0;
stp = pi * 2;
}
final double ellipseInc = pi * 2 / config.curveStepCount!;
final double arcIn = min(ellipseInc / 2, (stp - strt) / 2);
ops
..addAll(OpsGenerator.arc(arcIn, cx, cy, rx, ry, strt, stp, 1, config))
..addAll(OpsGenerator.arc(arcIn, cx, cy, rx, ry, strt, stp, 1.5, config));
if (closed) {
if (roughClosure) {
ops
..addAll(OpsGenerator.doubleLine(
cx, cy, cx + rx * cos(strt), cy + ry * sin(strt), config))
..addAll(OpsGenerator.doubleLine(
cx, cy, cx + rx * cos(stp), cy + ry * sin(stp), config));
} else {
ops
..add(Op.lineTo(PointD(cx, cy)))
..add(Op.lineTo(PointD(cx + rx * cos(strt), cy + ry * sin(strt))));
}
}
return OpSet(type: OpSetType.path, ops: ops);
}