cubicsToPathD function

String cubicsToPathD(
  1. List<CubicPath> paths
)

Cubic subpaths → canonical d, quantized to 4 decimals.

Implementation

String cubicsToPathD(List<CubicPath> paths) {
  final d = StringBuffer();
  for (final path in paths) {
    final pts = path.pts;
    d.write('M${_fmtCanon(pts[0])} ${_fmtCanon(pts[1])}');
    for (var i = 2; i < pts.length; i += 6) {
      d.write(
        'C${_fmtCanon(pts[i])} ${_fmtCanon(pts[i + 1])} '
        '${_fmtCanon(pts[i + 2])} ${_fmtCanon(pts[i + 3])} '
        '${_fmtCanon(pts[i + 4])} ${_fmtCanon(pts[i + 5])}',
      );
    }
    if (path.closed) d.write('Z');
  }
  return d.toString();
}