svg-path-commander 2.2.4 → 2.3.0
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/AGENTS.md +5 -9
- package/CHANGELOG.md +11 -0
- package/README.md +30 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +290 -37
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/dist/util.d.ts +1 -1
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +289 -36
- package/dist/util.js.map +1 -1
- package/package.json +3 -2
package/dist/util.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* SVGPathCommander v2.
|
|
2
|
+
* SVGPathCommander v2.3.0 (http://thednp.github.io/svg-path-commander)
|
|
3
3
|
* Copyright 2026 © thednp
|
|
4
4
|
* Licensed under MIT (https://github.com/thednp/svg-path-commander/blob/master/LICENSE)
|
|
5
5
|
*/
|
package/dist/util.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","names":[],"sources":["../src/interface.ts","../src/types.ts","../src/math/arcTools.ts","../src/math/bezier.ts","../src/math/cubicTools.ts","../src/math/lineTools.ts","../src/math/quadTools.ts","../src/math/polygonTools.ts","../src/math/distanceSquareRoot.ts","../src/math/midPoint.ts","../src/math/rotateVector.ts","../src/math/roundTo.ts","../src/convert/pathToAbsolute.ts","../src/convert/pathToRelative.ts","../src/convert/pathToCurve.ts","../src/convert/pathToString.ts","../src/parser/parsePathString.ts","../src/parser/pathParser.ts","../src/parser/finalizeSegment.ts","../src/parser/invalidPathValue.ts","../src/parser/isArcCommand.ts","../src/parser/isDigit.ts","../src/parser/isDigitStart.ts","../src/parser/isMoveCommand.ts","../src/parser/isPathCommand.ts","../src/parser/isSpace.ts","../src/parser/paramsCount.ts","../src/parser/paramsParser.ts","../src/parser/scanFlag.ts","../src/parser/scanParam.ts","../src/parser/scanSegment.ts","../src/parser/skipSpaces.ts","../src/util/getPathBBox.ts","../src/util/getTotalLength.ts","../src/util/distanceEpsilon.ts","../src/util/getClosestPoint.ts","../src/util/getDrawDirection.ts","../src/util/getPathArea.ts","../src/util/getPointAtLength.ts","../src/util/getPropertiesAtLength.ts","../src/util/getPropertiesAtPoint.ts","../src/util/getSegmentAtLength.ts","../src/util/getSegmentOfPoint.ts","../src/util/isAbsoluteArray.ts","../src/util/isCurveArray.ts","../src/util/isNormalizedArray.ts","../src/util/isPathArray.ts","../src/util/isPointInStroke.ts","../src/util/isPolygonArray.ts","../src/util/isPolylineArray.ts","../src/util/isRelativeArray.ts","../src/util/isValidPath.ts","../src/util/isMultiPath.ts","../src/util/isClosedPath.ts","../src/util/shapeParams.ts","../src/util/shapeToPath.ts","../src/util/shapeToPathArray.ts","../src/process/normalizePath.ts","../src/process/optimizePath.ts","../src/process/reversePath.ts","../src/process/splitPath.ts","../src/process/transformPath.ts","../src/process/absolutizeSegment.ts","../src/process/arcToCubic.ts","../src/process/getSVGMatrix.ts","../src/process/iterate.ts","../src/process/lineToCubic.ts","../src/process/normalizeSegment.ts","../src/process/projection2d.ts","../src/process/quadToCubic.ts","../src/process/relativizeSegment.ts","../src/process/reverseCurve.ts","../src/process/roundPath.ts","../src/process/roundSegment.ts","../src/process/segmentToCubic.ts","../src/process/shortenSegment.ts","../src/morph/fixPath.ts","../src/morph/splitCubicSegment.ts","../src/morph/equalizeSegments.ts","../src/morph/equalizePaths.ts","../src/intersect/pathIntersection.ts","../src/intersect/boundingBoxIntersect.ts","../src/intersect/isPointInsideBBox.ts"],"mappings":";;;;;;;;KAGY;;EAEV,SAAS;;EAET;;EAEA;;EAEA;;;KAIU;;EAEV;;IAEE;;IAEA;;;EAGF;;EAEA,UAAU;;;KAIA;;EAEV;;EAEA;;EAEA;;EAEA;;EAEA;GACC;;;KAGS;;EAEV;;EAEA;GACC;;;KAGS;;EAEV;;EAEA;;E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A,YACA;EAEP;EAAW;;;;;;;;;;;cA2BV,cAAW,YACL,YACA,YACA;;cAcN;;;;;;;;;;;;;;;;;;;;;;cC/DA,+BAA2B,IAAA,IAAA,IAAA,IAAA,IAAA,KACL,iBAAe;EAEtC;EAAW;;;;;;;;;;;;;cAmBV,gBAAa,YACP,YACA,YACA,YACA,YACA;;;;;;;;;;;;;cAkBN,uBAAoB,YACd,YACA,YACA,YACA,YACA,YACA;EAEP;EAAW;;;;;;;;;;;;;;cAgCV,cAAW,YACL,YACA,YACA,YACA,YACA;;cAaN;;;;;;;;;;;;;;;;;cC7GA,cAAW,SAAa;;;;;;;;;;cAyBxB,gBAAa,SAAa;;;;;;;;cAgB1B,kBAAe,SAAa,iBAAe;;cAgB3C;;;;;;;;;;;;;;;cC3DO,qBAAkB,GAAO,YAAU,GAAK;;;;;;;;;;;;cCCxC,YAAQ,IAAA,KACT,aAAU,IAAA,KACV,YAAU,cAEnB;;;;;;;;;;;;cCNU,eAAY,WACd,WACA;EAEN;EAAW;;;;;;;;;;;cCNH,UAAO,WAAa;;;;;;;;;;;;;;;;cCWpB,iBAAkB,UAAU,WAAS,oBAC5B,MACnB;;;;;;;;;;;;;;;;cCFU,iBAAkB,UAAU,WAAS,oBAC5B,MACnB;;;;;;;;;;;;;;;;cCKU,cAAe,UAAU,WAAS,oBACzB,MACnB;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"util.d.ts","names":[],"sources":["../src/interface.ts","../src/types.ts","../src/math/arcTools.ts","../src/math/bezier.ts","../src/math/cubicTools.ts","../src/math/lineTools.ts","../src/math/quadTools.ts","../src/math/polygonTools.ts","../src/math/distanceSquareRoot.ts","../src/math/midPoint.ts","../src/math/rotateVector.ts","../src/math/roundTo.ts","../src/convert/pathToAbsolute.ts","../src/convert/pathToRelative.ts","../src/convert/pathToCurve.ts","../src/convert/pathToString.ts","../src/parser/parsePathString.ts","../src/parser/pathParser.ts","../src/parser/finalizeSegment.ts","../src/parser/invalidPathValue.ts","../src/parser/isArcCommand.ts","../src/parser/isDigit.ts","../src/parser/isDigitStart.ts","../src/parser/isMoveCommand.ts","../src/parser/isPathCommand.ts","../src/parser/isSpace.ts","../src/parser/paramsCount.ts","../src/parser/paramsParser.ts","../src/parser/scanFlag.ts","../src/parser/scanParam.ts","../src/parser/scanSegment.ts","../src/parser/skipSpaces.ts","../src/util/getPathBBox.ts","../src/util/getTotalLength.ts","../src/util/distanceEpsilon.ts","../src/util/getClosestPoint.ts","../src/util/getDrawDirection.ts","../src/util/getPathArea.ts","../src/util/getPointAtLength.ts","../src/util/getPropertiesAtLength.ts","../src/util/getPropertiesAtPoint.ts","../src/util/getSegmentAtLength.ts","../src/util/getSegmentOfPoint.ts","../src/util/isAbsoluteArray.ts","../src/util/isCurveArray.ts","../src/util/isNormalizedArray.ts","../src/util/isPathArray.ts","../src/util/isPointInStroke.ts","../src/util/isPolygonArray.ts","../src/util/isPolylineArray.ts","../src/util/isRelativeArray.ts","../src/util/isValidPath.ts","../src/util/isMultiPath.ts","../src/util/isClosedPath.ts","../src/util/shapeParams.ts","../src/util/shapeToPath.ts","../src/util/shapeToPathArray.ts","../src/process/normalizePath.ts","../src/process/optimizePath.ts","../src/process/reversePath.ts","../src/process/splitPath.ts","../src/process/transformPath.ts","../src/process/absolutizeSegment.ts","../src/process/arcToCubic.ts","../src/process/getSVGMatrix.ts","../src/process/iterate.ts","../src/process/lineToCubic.ts","../src/process/normalizeSegment.ts","../src/process/projection2d.ts","../src/process/quadToCubic.ts","../src/process/relativizeSegment.ts","../src/process/reverseCurve.ts","../src/process/roundPath.ts","../src/process/roundSegment.ts","../src/process/segmentToCubic.ts","../src/process/shortenSegment.ts","../src/morph/fixPath.ts","../src/morph/splitCubicSegment.ts","../src/morph/equalizeSegments.ts","../src/morph/equalizePaths.ts","../src/intersect/pathIntersection.ts","../src/intersect/boundingBoxIntersect.ts","../src/intersect/isPointInsideBBox.ts"],"mappings":";;;;;;;;KAGY;;EAEV,SAAS;;EAET;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YACA,YACA,YACA;;;;;;;;;;;;cCQC,oBAAiB,SACnB,aAAW,eACP,eACA,kBAEZ,WAAW;;;;;;;;;;cCpBD,eAAY,MAAU,eAAa;;;;;;;;;;;cCInC,YAAa,UAAU,WAAS,MACrC,GAAC,iCAEN;;;;;;;;;;cCNU,eAAgB,UAAU,aAAW,SACvC,GAAC,wBAET;;;;;;;;;;cCAU,iBAAc,SAChB,aAAW,QACZ,iBACP,WAAW;;;;;;;;;;;;cCKD,iBAAc,SAChB,iBAAe,eACT,eAAa,QACpB,cAAY,aACP,gBACZ;;;;;;;;;;;;;;;;;cCNU,UAAW,UAAU,WAAS,WAAa;;;;;;;;;;;;;;;;;iBCDxC,kBACd,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,aACE,kBAAkB;;;;;;;;;;;;;;;;;;cCkBT,mBAAgB,OACpB,oBAAkB,OAClB,oBAAkB,aACb,yBACV,gBAAgB;;;;;;;;;;;;;;;;;;cCdP,gBAAa,qBACH,WAAS,qBACT,WAAS,qBAE5B,gBAAgB;;;;;;;;;;;;;;;;;;;cCjBP,oBAAqB,mBAAmB,WAAS,YAChD,GAAC,YACD,GAAC,iCAEH;;;;;;;;;;cCjBC,uBAAoB,GAAO,YAAU,GAAK;;;;;;;;;;cCF1C,oBAAiB,MACtB,aAAU,GAAA,IACR"}
|
package/dist/util.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* SVGPathCommander v2.
|
|
2
|
+
* SVGPathCommander v2.3.0 (http://thednp.github.io/svg-path-commander)
|
|
3
3
|
* Copyright 2026 © thednp
|
|
4
4
|
* Licensed under MIT (https://github.com/thednp/svg-path-commander/blob/master/LICENSE)
|
|
5
5
|
*/
|
|
@@ -1106,12 +1106,25 @@ const finalizeSegment = (path) => {
|
|
|
1106
1106
|
let pathCommand = path.pathValue[path.segmentStart];
|
|
1107
1107
|
let relativeCommand = pathCommand.toLowerCase();
|
|
1108
1108
|
const { data } = path;
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1109
|
+
let index = 0;
|
|
1110
|
+
while (data.length - index >= paramsCounts[relativeCommand]) {
|
|
1111
|
+
if (relativeCommand === "m" && data.length - index > 2) {
|
|
1112
|
+
const segment = new Array(3);
|
|
1113
|
+
segment[0] = pathCommand;
|
|
1114
|
+
segment[1] = data[index];
|
|
1115
|
+
segment[2] = data[index + 1];
|
|
1116
|
+
path.segments.push(segment);
|
|
1117
|
+
index += 2;
|
|
1112
1118
|
relativeCommand = "l";
|
|
1113
1119
|
pathCommand = pathCommand === "m" ? "l" : "L";
|
|
1114
|
-
} else
|
|
1120
|
+
} else {
|
|
1121
|
+
const paramCount = paramsCounts[relativeCommand];
|
|
1122
|
+
const segment = new Array(paramCount + 1);
|
|
1123
|
+
segment[0] = pathCommand;
|
|
1124
|
+
for (let i = 0; i < paramCount; i += 1) segment[i + 1] = data[index + i];
|
|
1125
|
+
path.segments.push(segment);
|
|
1126
|
+
index += paramCount;
|
|
1127
|
+
}
|
|
1115
1128
|
if (!paramsCounts[relativeCommand]) break;
|
|
1116
1129
|
}
|
|
1117
1130
|
};
|
|
@@ -1226,7 +1239,60 @@ const scanParam = (path) => {
|
|
|
1226
1239
|
}
|
|
1227
1240
|
}
|
|
1228
1241
|
path.index = index;
|
|
1229
|
-
path.param =
|
|
1242
|
+
path.param = scanNumber(pathValue, start, index);
|
|
1243
|
+
};
|
|
1244
|
+
/**
|
|
1245
|
+
* Converts a validated number substring to a Number without
|
|
1246
|
+
* allocating a new string, matching `+str.slice(start, end)`.
|
|
1247
|
+
*
|
|
1248
|
+
* Falls back to the native conversion when the value cannot be
|
|
1249
|
+
* represented exactly with plain double arithmetic (more than 15
|
|
1250
|
+
* significant digits or an exponent beyond +-22).
|
|
1251
|
+
*
|
|
1252
|
+
* @param str - the path string
|
|
1253
|
+
* @param start - the index of the first char of the number
|
|
1254
|
+
* @param end - the index after the last char of the number
|
|
1255
|
+
* @returns the parsed number
|
|
1256
|
+
*/
|
|
1257
|
+
const scanNumber = (str, start, end) => {
|
|
1258
|
+
let i = start;
|
|
1259
|
+
let sign = 1;
|
|
1260
|
+
let param = 0;
|
|
1261
|
+
let decimals = 0;
|
|
1262
|
+
let sigDigits = 0;
|
|
1263
|
+
let inFraction = false;
|
|
1264
|
+
let expSign = 1;
|
|
1265
|
+
let exp = 0;
|
|
1266
|
+
const ch = str.charCodeAt(i);
|
|
1267
|
+
if (ch === 43) i += 1;
|
|
1268
|
+
else if (ch === 45) {
|
|
1269
|
+
sign = -1;
|
|
1270
|
+
i += 1;
|
|
1271
|
+
}
|
|
1272
|
+
for (; i < end; i += 1) {
|
|
1273
|
+
const code = str.charCodeAt(i);
|
|
1274
|
+
if (code === 46) inFraction = true;
|
|
1275
|
+
else if (code === 101 || code === 69) {
|
|
1276
|
+
i += 1;
|
|
1277
|
+
const expCode = str.charCodeAt(i);
|
|
1278
|
+
if (expCode === 43) i += 1;
|
|
1279
|
+
else if (expCode === 45) {
|
|
1280
|
+
expSign = -1;
|
|
1281
|
+
i += 1;
|
|
1282
|
+
}
|
|
1283
|
+
for (; i < end; i += 1) exp = exp * 10 + (str.charCodeAt(i) - 48);
|
|
1284
|
+
} else {
|
|
1285
|
+
const digit = code - 48;
|
|
1286
|
+
if (digit !== 0 || param !== 0) sigDigits += 1;
|
|
1287
|
+
param = param * 10 + digit;
|
|
1288
|
+
if (inFraction) decimals += 1;
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
if (sigDigits > 15 || sigDigits === 0) return +str.slice(start, end);
|
|
1292
|
+
const scale = expSign * exp - decimals;
|
|
1293
|
+
if (scale > 22 || scale < -22) return +str.slice(start, end);
|
|
1294
|
+
if (scale >= 0) return sign * param * 10 ** scale;
|
|
1295
|
+
return sign * param / 10 ** -scale;
|
|
1230
1296
|
};
|
|
1231
1297
|
//#endregion
|
|
1232
1298
|
//#region src/parser/isSpace.ts
|
|
@@ -1470,6 +1536,15 @@ const absolutizeSegment = (segment, index, lastX, lastY) => {
|
|
|
1470
1536
|
segment[1] + lastX,
|
|
1471
1537
|
segment[2] + lastY
|
|
1472
1538
|
];
|
|
1539
|
+
else if (absCommand === "C") return [
|
|
1540
|
+
absCommand,
|
|
1541
|
+
segment[1] + lastX,
|
|
1542
|
+
segment[2] + lastY,
|
|
1543
|
+
segment[3] + lastX,
|
|
1544
|
+
segment[4] + lastY,
|
|
1545
|
+
segment[5] + lastX,
|
|
1546
|
+
segment[6] + lastY
|
|
1547
|
+
];
|
|
1473
1548
|
else {
|
|
1474
1549
|
const absValues = [];
|
|
1475
1550
|
const seglen = segment.length;
|
|
@@ -1515,8 +1590,9 @@ const iterate = (path, iterator) => {
|
|
|
1515
1590
|
while (i < path.length) {
|
|
1516
1591
|
const segment = path[i];
|
|
1517
1592
|
const [pathCommand] = segment;
|
|
1518
|
-
const
|
|
1519
|
-
const isRelative =
|
|
1593
|
+
const commandCode = pathCommand.charCodeAt(0);
|
|
1594
|
+
const isRelative = commandCode >= 97;
|
|
1595
|
+
const absCommand = isRelative ? String.fromCharCode(commandCode - 32) : pathCommand;
|
|
1520
1596
|
const iteratorResult = iterator(segment, i, x, y);
|
|
1521
1597
|
if (iteratorResult === false) break;
|
|
1522
1598
|
if (absCommand === "Z") {
|
|
@@ -1971,20 +2047,19 @@ const pathToString = (path, roundOption) => {
|
|
|
1971
2047
|
let segment = path[0];
|
|
1972
2048
|
let result = "";
|
|
1973
2049
|
round = roundOption === "off" ? roundOption : typeof roundOption === "number" && roundOption >= 0 ? roundOption : typeof round === "number" && round >= 0 ? round : "off";
|
|
2050
|
+
const pow = round === "off" ? 0 : 10 ** round;
|
|
1974
2051
|
for (let i = 0; i < pathLen; i += 1) {
|
|
1975
2052
|
segment = path[i];
|
|
1976
|
-
const
|
|
1977
|
-
const
|
|
2053
|
+
const pathCommand = segment[0];
|
|
2054
|
+
const segLen = segment.length;
|
|
1978
2055
|
result += pathCommand;
|
|
1979
|
-
if (round === "off")
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
j += 1;
|
|
1987
|
-
}
|
|
2056
|
+
if (round === "off") for (let j = 1; j < segLen; j += 1) {
|
|
2057
|
+
result += segment[j];
|
|
2058
|
+
if (j !== segLen - 1) result += " ";
|
|
2059
|
+
}
|
|
2060
|
+
else for (let j = 1; j < segLen; j += 1) {
|
|
2061
|
+
result += Math.round(segment[j] * pow) / pow;
|
|
2062
|
+
if (j !== segLen - 1) result += " ";
|
|
1988
2063
|
}
|
|
1989
2064
|
}
|
|
1990
2065
|
return result;
|
|
@@ -2036,8 +2111,10 @@ const getPathBBox = (pathInput) => {
|
|
|
2036
2111
|
let paramQY = 0;
|
|
2037
2112
|
iterate(path, (seg, index, lastX, lastY) => {
|
|
2038
2113
|
[pathCommand] = seg;
|
|
2039
|
-
const
|
|
2040
|
-
const
|
|
2114
|
+
const commandCode = pathCommand.charCodeAt(0);
|
|
2115
|
+
const isRelative = commandCode >= 97;
|
|
2116
|
+
const absCommand = isRelative ? String.fromCharCode(commandCode - 32) : pathCommand;
|
|
2117
|
+
const absoluteSegment = isRelative ? absolutizeSegment(seg, index, lastX, lastY) : seg;
|
|
2041
2118
|
const normalSegment = absCommand === "V" ? [
|
|
2042
2119
|
"L",
|
|
2043
2120
|
lastX,
|
|
@@ -2048,7 +2125,7 @@ const getPathBBox = (pathInput) => {
|
|
|
2048
2125
|
lastY
|
|
2049
2126
|
] : absoluteSegment;
|
|
2050
2127
|
[pathCommand] = normalSegment;
|
|
2051
|
-
if (
|
|
2128
|
+
if (absCommand !== "T" && absCommand !== "Q") {
|
|
2052
2129
|
paramQX = 0;
|
|
2053
2130
|
paramQY = 0;
|
|
2054
2131
|
}
|
|
@@ -2078,8 +2155,24 @@ const getPathBBox = (pathInput) => {
|
|
|
2078
2155
|
yMin = min(minY, yMin);
|
|
2079
2156
|
xMax = max(maxX, xMax);
|
|
2080
2157
|
yMax = max(maxY, yMax);
|
|
2081
|
-
|
|
2082
|
-
|
|
2158
|
+
if (pathCommand === "Z") {
|
|
2159
|
+
paramX1 = mx;
|
|
2160
|
+
paramY1 = my;
|
|
2161
|
+
} else {
|
|
2162
|
+
const segLen = normalSegment.length;
|
|
2163
|
+
paramX1 = normalSegment[segLen - 2];
|
|
2164
|
+
paramY1 = normalSegment[segLen - 1];
|
|
2165
|
+
}
|
|
2166
|
+
if (pathCommand === "C") {
|
|
2167
|
+
paramX2 = normalSegment[3];
|
|
2168
|
+
paramY2 = normalSegment[4];
|
|
2169
|
+
} else if (pathCommand === "S") {
|
|
2170
|
+
paramX2 = normalSegment[1];
|
|
2171
|
+
paramY2 = normalSegment[2];
|
|
2172
|
+
} else {
|
|
2173
|
+
paramX2 = paramX1;
|
|
2174
|
+
paramY2 = paramY1;
|
|
2175
|
+
}
|
|
2083
2176
|
});
|
|
2084
2177
|
const width = xMax - xMin;
|
|
2085
2178
|
const height = yMax - yMin;
|
|
@@ -3365,6 +3458,12 @@ const getSVGMatrix = (transform) => {
|
|
|
3365
3458
|
* @returns the resulting Tuple
|
|
3366
3459
|
*/
|
|
3367
3460
|
const translatePoint = (cssm, v) => {
|
|
3461
|
+
if (cssm.is2D) return [
|
|
3462
|
+
cssm.a * v[0] + cssm.c * v[1] + cssm.e * v[3],
|
|
3463
|
+
cssm.b * v[0] + cssm.d * v[1] + cssm.f * v[3],
|
|
3464
|
+
0,
|
|
3465
|
+
1
|
|
3466
|
+
];
|
|
3368
3467
|
let m = CSSMatrix.Translate(v[0], v[1], v[2]);
|
|
3369
3468
|
[, , , m.m44] = v;
|
|
3370
3469
|
m = cssm.multiply(m);
|
|
@@ -3405,6 +3504,161 @@ const projection2d = (m, point2D, origin) => {
|
|
|
3405
3504
|
//#endregion
|
|
3406
3505
|
//#region src/process/transformPath.ts
|
|
3407
3506
|
/**
|
|
3507
|
+
* Applies a 2D transformation to a `PathArray` in a single pass, without
|
|
3508
|
+
* absolutizing or copying each segment, returning a new absolute `PathArray`.
|
|
3509
|
+
*
|
|
3510
|
+
* @param path the parsed path value
|
|
3511
|
+
* @param a the `a` value of the matrix
|
|
3512
|
+
* @param b the `b` value of the matrix
|
|
3513
|
+
* @param c the `c` value of the matrix
|
|
3514
|
+
* @param d the `d` value of the matrix
|
|
3515
|
+
* @param e the `e` value of the matrix
|
|
3516
|
+
* @param f the `f` value of the matrix
|
|
3517
|
+
* @param originX the transform origin `x` value
|
|
3518
|
+
* @param originY the transform origin `y` value
|
|
3519
|
+
* @returns the transformed absolute path
|
|
3520
|
+
*/
|
|
3521
|
+
const transform2D = (path, a, b, c, d, e, f, originX, originY) => {
|
|
3522
|
+
const result = [];
|
|
3523
|
+
let x = 0;
|
|
3524
|
+
let y = 0;
|
|
3525
|
+
let lx = 0;
|
|
3526
|
+
let ly = 0;
|
|
3527
|
+
let ox = 0;
|
|
3528
|
+
let oy = 0;
|
|
3529
|
+
let omx = 0;
|
|
3530
|
+
let omy = 0;
|
|
3531
|
+
for (let i = 0, len = path.length; i < len; i += 1) {
|
|
3532
|
+
const seg = path[i];
|
|
3533
|
+
const pathCommand = seg[0];
|
|
3534
|
+
const commandCode = pathCommand.charCodeAt(0);
|
|
3535
|
+
const isRelative = commandCode >= 97;
|
|
3536
|
+
const absCommand = isRelative ? String.fromCharCode(commandCode - 32) : pathCommand;
|
|
3537
|
+
const outCommand = i === 0 && isRelative ? pathCommand : absCommand;
|
|
3538
|
+
if (absCommand === "Z") {
|
|
3539
|
+
result.push(["Z"]);
|
|
3540
|
+
ox = omx;
|
|
3541
|
+
oy = omy;
|
|
3542
|
+
continue;
|
|
3543
|
+
}
|
|
3544
|
+
if (absCommand === "V") {
|
|
3545
|
+
const absY = seg[1] + (isRelative ? oy : 0);
|
|
3546
|
+
lx = a * ox + c * absY + e - originX + originX;
|
|
3547
|
+
ly = b * ox + d * absY + f - originY + originY;
|
|
3548
|
+
if (x !== lx && y !== ly) result.push([
|
|
3549
|
+
"L",
|
|
3550
|
+
lx,
|
|
3551
|
+
ly
|
|
3552
|
+
]);
|
|
3553
|
+
else if (y === ly) result.push(["H", lx]);
|
|
3554
|
+
else if (x === lx) result.push(["V", ly]);
|
|
3555
|
+
else result.push([
|
|
3556
|
+
"L",
|
|
3557
|
+
ox,
|
|
3558
|
+
absY
|
|
3559
|
+
]);
|
|
3560
|
+
oy = absY;
|
|
3561
|
+
x = lx;
|
|
3562
|
+
y = ly;
|
|
3563
|
+
continue;
|
|
3564
|
+
}
|
|
3565
|
+
if (absCommand === "H") {
|
|
3566
|
+
const absX = seg[1] + (isRelative ? ox : 0);
|
|
3567
|
+
lx = a * absX + c * oy + e - originX + originX;
|
|
3568
|
+
ly = b * absX + d * oy + f - originY + originY;
|
|
3569
|
+
if (x !== lx && y !== ly) result.push([
|
|
3570
|
+
"L",
|
|
3571
|
+
lx,
|
|
3572
|
+
ly
|
|
3573
|
+
]);
|
|
3574
|
+
else if (y === ly) result.push(["H", lx]);
|
|
3575
|
+
else if (x === lx) result.push(["V", ly]);
|
|
3576
|
+
else result.push([
|
|
3577
|
+
"L",
|
|
3578
|
+
absX,
|
|
3579
|
+
oy
|
|
3580
|
+
]);
|
|
3581
|
+
ox = absX;
|
|
3582
|
+
x = lx;
|
|
3583
|
+
y = ly;
|
|
3584
|
+
continue;
|
|
3585
|
+
}
|
|
3586
|
+
if (absCommand === "A") {
|
|
3587
|
+
const absX = seg[6] + (isRelative ? ox : 0);
|
|
3588
|
+
const absY = seg[7] + (isRelative ? oy : 0);
|
|
3589
|
+
const cubics = arcToCubic(ox, oy, seg[1], seg[2], seg[3], seg[4], seg[5], absX, absY);
|
|
3590
|
+
const cubicsLen = cubics.length;
|
|
3591
|
+
let k = 0;
|
|
3592
|
+
if (cubicsLen > 0) do {
|
|
3593
|
+
const piece = ["C"];
|
|
3594
|
+
const end = k + 6;
|
|
3595
|
+
for (let j = k; j < end; j += 2) {
|
|
3596
|
+
lx = a * cubics[j] + c * cubics[j + 1] + e - originX + originX;
|
|
3597
|
+
ly = b * cubics[j] + d * cubics[j + 1] + f - originY + originY;
|
|
3598
|
+
piece.push(lx, ly);
|
|
3599
|
+
}
|
|
3600
|
+
result.push(piece);
|
|
3601
|
+
k = end;
|
|
3602
|
+
} while (k < cubicsLen);
|
|
3603
|
+
else result.push(["C"]);
|
|
3604
|
+
if (cubicsLen > 0) {
|
|
3605
|
+
ox = cubics[cubicsLen - 2];
|
|
3606
|
+
oy = cubics[cubicsLen - 1];
|
|
3607
|
+
} else {
|
|
3608
|
+
ox = absX;
|
|
3609
|
+
oy = absY;
|
|
3610
|
+
}
|
|
3611
|
+
x = lx;
|
|
3612
|
+
y = ly;
|
|
3613
|
+
continue;
|
|
3614
|
+
}
|
|
3615
|
+
if (absCommand === "L") {
|
|
3616
|
+
const absX = seg[1] + (isRelative ? ox : 0);
|
|
3617
|
+
const absY = seg[2] + (isRelative ? oy : 0);
|
|
3618
|
+
lx = a * absX + c * absY + e - originX + originX;
|
|
3619
|
+
ly = b * absX + d * absY + f - originY + originY;
|
|
3620
|
+
if (x !== lx && y !== ly) result.push([
|
|
3621
|
+
"L",
|
|
3622
|
+
lx,
|
|
3623
|
+
ly
|
|
3624
|
+
]);
|
|
3625
|
+
else if (y === ly) result.push(["H", lx]);
|
|
3626
|
+
else if (x === lx) result.push(["V", ly]);
|
|
3627
|
+
else result.push([
|
|
3628
|
+
"L",
|
|
3629
|
+
absX,
|
|
3630
|
+
absY
|
|
3631
|
+
]);
|
|
3632
|
+
ox = absX;
|
|
3633
|
+
oy = absY;
|
|
3634
|
+
x = lx;
|
|
3635
|
+
y = ly;
|
|
3636
|
+
continue;
|
|
3637
|
+
}
|
|
3638
|
+
{
|
|
3639
|
+
const piece = [outCommand];
|
|
3640
|
+
const segLen = seg.length;
|
|
3641
|
+
for (let j = 1; j < segLen; j += 2) {
|
|
3642
|
+
const absX = seg[j] + (isRelative ? ox : 0);
|
|
3643
|
+
const absY = seg[j + 1] + (isRelative ? oy : 0);
|
|
3644
|
+
lx = a * absX + c * absY + e - originX + originX;
|
|
3645
|
+
ly = b * absX + d * absY + f - originY + originY;
|
|
3646
|
+
piece.push(lx, ly);
|
|
3647
|
+
}
|
|
3648
|
+
result.push(piece);
|
|
3649
|
+
ox = seg[segLen - 2] + (isRelative ? ox : 0);
|
|
3650
|
+
oy = seg[segLen - 1] + (isRelative ? oy : 0);
|
|
3651
|
+
if (absCommand === "M") {
|
|
3652
|
+
omx = ox;
|
|
3653
|
+
omy = oy;
|
|
3654
|
+
}
|
|
3655
|
+
x = lx;
|
|
3656
|
+
y = ly;
|
|
3657
|
+
}
|
|
3658
|
+
}
|
|
3659
|
+
return result;
|
|
3660
|
+
};
|
|
3661
|
+
/**
|
|
3408
3662
|
* Apply a 2D / 3D transformation to a PathArray.
|
|
3409
3663
|
*
|
|
3410
3664
|
* Since SVGElement doesn't support 3D transformation, this function
|
|
@@ -3421,12 +3675,6 @@ const projection2d = (m, point2D, origin) => {
|
|
|
3421
3675
|
* ```
|
|
3422
3676
|
*/
|
|
3423
3677
|
const transformPath = (pathInput, transform) => {
|
|
3424
|
-
let x = 0;
|
|
3425
|
-
let y = 0;
|
|
3426
|
-
let lx = 0;
|
|
3427
|
-
let ly = 0;
|
|
3428
|
-
let j = 0;
|
|
3429
|
-
let jj = 0;
|
|
3430
3678
|
const path = parsePathString(pathInput);
|
|
3431
3679
|
const transformProps = transform && Object.keys(transform);
|
|
3432
3680
|
if (!transform || transformProps && !transformProps.length) return path.slice(0);
|
|
@@ -3434,8 +3682,15 @@ const transformPath = (pathInput, transform) => {
|
|
|
3434
3682
|
const origin = transform.origin;
|
|
3435
3683
|
const matrixInstance = getSVGMatrix(transform);
|
|
3436
3684
|
if (matrixInstance.isIdentity) return path.slice(0);
|
|
3685
|
+
if (matrixInstance.is2D) return transform2D(path, matrixInstance.a, matrixInstance.b, matrixInstance.c, matrixInstance.d, matrixInstance.e, matrixInstance.f, origin[0], origin[1]);
|
|
3686
|
+
let x = 0;
|
|
3687
|
+
let y = 0;
|
|
3688
|
+
let lx = 0;
|
|
3689
|
+
let ly = 0;
|
|
3690
|
+
let j = 0;
|
|
3691
|
+
let jj = 0;
|
|
3437
3692
|
return iterate(path, (seg, index, lastX, lastY) => {
|
|
3438
|
-
|
|
3693
|
+
const [pathCommand] = seg;
|
|
3439
3694
|
const absCommand = pathCommand.toUpperCase();
|
|
3440
3695
|
const absoluteSegment = absCommand !== pathCommand ? absolutizeSegment(seg, index, lastX, lastY) : seg.slice(0);
|
|
3441
3696
|
let result = absCommand === "A" ? ["C"].concat(arcToCubic(lastX, lastY, absoluteSegment[1], absoluteSegment[2], absoluteSegment[3], absoluteSegment[4], absoluteSegment[5], absoluteSegment[6], absoluteSegment[7])) : absCommand === "V" ? [
|
|
@@ -3447,14 +3702,12 @@ const transformPath = (pathInput, transform) => {
|
|
|
3447
3702
|
absoluteSegment[1],
|
|
3448
3703
|
lastY
|
|
3449
3704
|
] : absoluteSegment;
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
const tempSegment = isLongArc ? result.slice(0, 7) : result.slice(0);
|
|
3453
|
-
if (isLongArc) {
|
|
3705
|
+
if (result[0] === "C" && result.length > 7) {
|
|
3706
|
+
const tempSegment = result.slice(0, 7);
|
|
3454
3707
|
path.splice(index + 1, 0, ["C"].concat(result.slice(7)));
|
|
3455
3708
|
result = tempSegment;
|
|
3456
3709
|
}
|
|
3457
|
-
if (
|
|
3710
|
+
if (result[0] === "L") {
|
|
3458
3711
|
[lx, ly] = projection2d(matrixInstance, [result[1], result[2]], origin);
|
|
3459
3712
|
if (x !== lx && y !== ly) result = [
|
|
3460
3713
|
"L",
|