parsePolylineNode method

ShapePath parsePolylineNode(
  1. dynamic node
)

Implementation

ShapePath parsePolylineNode(node) {
  print("SVGLoader.parsePolylineNode todo  ");

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

  var path = ShapePath();

  var index = 0;

  iterator(match, a, b) {
    var x = parseFloatWithUnits(a);
    var y = parseFloatWithUnits(b);

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

    index++;
  }

  node.getAttribute('points').replace(regex, iterator);

  path.currentPath.autoClose = false;

  return path;
}