parsePolygonNode method
dynamic
parsePolygonNode(
- dynamic node
Implementation
parsePolygonNode(node) {
print("SVGLoader.parsePolygonNode todo test ");
// var regex = /(-?[\d\.?]+)[,|\s](-?[\d\.?]+)/g;
var regex = RegExp(r"(-?[\d\.?]+)[,|\s](-?[\d\.?]+)");
var path = ShapePath();
var index = 0;
// Function 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);
String points = node.getAttribute('points');
var matches = regex.allMatches(points);
// print(" _points: ${_points} ");
for (var match in matches) {
var a = match.group(1);
var b = match.group(2);
// print("index: ${index} a: ${a} b: ${b} ");
var x = parseFloatWithUnits(a);
var y = parseFloatWithUnits(b);
if (index == 0) {
path.moveTo(x, y);
} else {
path.lineTo(x, y);
}
index++;
}
path.currentPath.autoClose = true;
return path;
}