@antv/g-lite 1.2.11 → 1.2.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4254,6 +4254,33 @@ function getOrCalculatePathTotalLength(path) {
4254
4254
  }
4255
4255
  return path.parsedStyle.path.totalLength;
4256
4256
  }
4257
+ function removeRedundantMCommand(path) {
4258
+ for (var i = 0; i < path.length; i++) {
4259
+ var prevSegment = path[i - 1];
4260
+ var segment = path[i];
4261
+ var cmd = segment[0];
4262
+ if (cmd === 'M') {
4263
+ if (prevSegment) {
4264
+ var prevCmd = prevSegment[0];
4265
+ var srcPoint = [segment[1], segment[2]];
4266
+ var destPoint = void 0;
4267
+ if (prevCmd === 'L' || prevCmd === 'M') {
4268
+ destPoint = [prevSegment[1], prevSegment[2]];
4269
+ }
4270
+ else if (prevCmd === 'C' || prevCmd === 'A' || prevCmd === 'Q') {
4271
+ destPoint = [
4272
+ prevSegment[prevSegment.length - 2],
4273
+ prevSegment[prevSegment.length - 1],
4274
+ ];
4275
+ }
4276
+ if (destPoint && isSamePoint(srcPoint, destPoint)) {
4277
+ path.splice(i, 1);
4278
+ i--;
4279
+ }
4280
+ }
4281
+ }
4282
+ }
4283
+ }
4257
4284
  function hasArcOrBezier(path) {
4258
4285
  var hasArc = false;
4259
4286
  var count = path.length;
@@ -5024,6 +5051,7 @@ var internalParsePath = function (path) {
5024
5051
  absolutePath = util.normalizePath('');
5025
5052
  console.error("[g]: Invalid SVG Path definition: ".concat(path));
5026
5053
  }
5054
+ removeRedundantMCommand(absolutePath);
5027
5055
  var hasArc = hasArcOrBezier(absolutePath);
5028
5056
  var _a = extractPolygons(absolutePath), polygons = _a.polygons, polylines = _a.polylines;
5029
5057
  // for later use