parsePolylineNode method

ShapePath parsePolylineNode(
  1. XmlElement node
)

Implementation

ShapePath parsePolylineNode(XmlElement node) {
  console.info("SVGLoader: parsePolylineNode todo.");

  // final regex = /(-?[\d\.?]+)[,|\s](-?[\d\.?]+)/g;
  final regex = RegExp(r"(-?[\d\.?]+)[,|\s](-?[\d\.?]+)");

  final path = ShapePath();

  int index = 0;

  String iterator(Match m) {
    String a = m.group(1)!;
    String b = m.group(2)!;

    final x = parseFloatWithUnits(a);
    final y = parseFloatWithUnits(b);

    if (index == 0) {
      path.moveTo(x, y);
    } else {
      path.lineTo(x, y);
    }

    index++;
    return '';
  }

  node.getAttribute('points')?.replaceAllMapped(regex, iterator);//.replaceAll(regex, iterator);


  path.currentPath.autoClose = false;

  return path;
}