svg-path-commander 2.2.4 → 2.3.1

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 CHANGED
@@ -2,18 +2,18 @@
2
2
 
3
3
  ## Project Overview
4
4
 
5
- SVGPathCommander v2.2.2 — TypeScript library for manipulating SVG `<path>` `d` attributes. Works in browser and Node.js.
5
+ SVGPathCommander v2.3.1 — TypeScript library for manipulating SVG `<path>` `d` attributes. Works in browser and Node.js.
6
6
 
7
7
  ## Commands
8
8
 
9
9
  ```bash
10
10
  pnpm install # Install dependencies
11
11
  pnpm dev # Serve docs on localhost:3000
12
- pnpm test # Run all tests (vitest + happy-dom)
13
- pnpm test:browser # Run browser tests (vitest + playwright chromium)
12
+ pnpm test # Run all tests (vitest + Istanbul coverage)
14
13
  pnpm test-ui # Run tests with UI
15
14
  pnpm test -- -t "Test name" # Run a single test by name
16
15
  pnpm test -- class.test.ts # Run a single test file
16
+ pnpm bench # Benchmark vs svgpath (results embedded in README)
17
17
  pnpm lint # Deno lint + tsc type check
18
18
  pnpm lint:ts # Deno lint only
19
19
  pnpm fix:ts # Deno lint --fix
@@ -37,11 +37,10 @@ deno publish # JSR dry run: deno publish --dry-run --allow-dirty
37
37
  - **Language:** TypeScript (strict, ES2020 target, `allowImportingTsExtensions`)
38
38
  - **Package manager:** pnpm (v11.x)
39
39
  - **Build:** tsdown (ESM + UMD outputs)
40
- - **Test:** Vitest + happy-dom (Istanbul coverage)
41
- - **Browser Test:** Vitest + Playwright (real Chromium, `test/browser/`)
40
+ - **Test:** Vitest + Istanbul coverage (`test/class.test.ts`, `test/static.test.ts`)
42
41
  - **Lint/Format:** Deno (`deno lint`, `deno fmt`)
43
42
  - **JSR:** `deno.json` publishes as `@thednp/svg-path-commander` — `deno check src`, `deno lint src` and `deno publish --dry-run --allow-dirty` must all pass
44
- - **Dependency:** `@thednp/dommatrix` (DOMMatrix shim)
43
+ - **Dependency:** `@thednp/dommatrix` `^3.1.1` (DOMMatrix shim)
45
44
 
46
45
  ## Source Structure (`src/`)
47
46
 
@@ -101,12 +100,9 @@ deno publish # JSR dry run: deno publish --dry-run --allow-dirty
101
100
  - Instance options validated in constructor with fallback to `defaultOptions`
102
101
 
103
102
  ### Testing
104
- - Tests run with happy-dom (headless browser simulation) via `pnpm test`
105
- - Browser tests run with real Chromium (Playwright) via `pnpm test:browser`
103
+ - Tests run with Vitest + Istanbul coverage via `pnpm test`
104
+ - Test files: `test/class.test.ts` (instance API), `test/static.test.ts` (static methods)
106
105
  - Fixtures in `test/fixtures/`
107
- - Test files: `test/class.test.ts` (instance API), `test/static.test.ts` (static methods), `test/browser/` (native browser APIs)
108
- - Tests render actual SVG and verify `d` attribute output
109
- - Use `vi.waitFor()` for async DOM queries (timeout: 200ms)
110
106
  - Use `expect().to.deep.equal()` for object comparison, `expect().to.equal()` for primitives
111
107
  - Coverage provider: Istanbul
112
108
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.3.1] - 2026-08-05
4
+
5
+ ### Changed
6
+ - Updated `@thednp/dommatrix` to `^3.1.1` — the 3.1.x line carries the shim's matrix-math rework (specialized `translate` / `scale` / `skew` / `multiply` and constructor fast paths), which directly accelerates the 3D transform path through `getSVGMatrix()` and `projection2d()`; 3.1.1 makes `setMatrixValue()` mutate the instance in place and return `this`, matching native `DOMMatrix` (SVGPathCommander does not use `setMatrixValue()`, so output is byte-identical and the 2D single-pass fast path is untouched)
7
+ - Rebuilt `dist` and `docs` bundles
8
+
9
+ ## [2.3.0] - 2026-08-04
10
+
11
+ ### Added
12
+ - `pnpm bench` — head-to-head benchmark against the [SvgPath](https://github.com/fontello/svgpath) library (vendored reference in `scripts/svgpath/`), comparing parse / bbox / transform / string output, with results embedded in the README
13
+
14
+ ### Changed
15
+ - **Performance**: allocation-free parsing — `scanParam()` converts validated number substrings without allocating new strings, `finalizeSegment()` builds segments with pre-sized arrays and index-based slicing instead of `splice()`
16
+ - **Performance**: single-pass 2D transforms — `transformPath()` now uses a dedicated `transform2D()` fast path that transforms segments in place (no per-segment absolutize / copy / DOMMatrix projection), falling back to the 3D-capable `iterate()` path for 3D matrices; output is byte-identical to the previous implementation (~2.8x faster 2D transforms)
17
+ - **Performance**: fast 2D branch in `projection2d()`, char-code based command detection in `iterate()` / `getPathBBox()`, allocation-free rounding in `pathToString()`, and a dedicated `C` case in `absolutizeSegment()`
18
+ - Rebuilt `dist` and `docs` bundles
19
+
3
20
  ## [2.2.4] - 2026-08-04
4
21
  ### Fixed
5
22
  - Build warnings: UMD bundle now uses a dedicated `src/browser.ts` entry so the `SVGPathCommander` global remains the class itself (no mixed-exports namespace), and the `output.dir`/`output.file` conflict is resolved — tree-shaking, named exports and type declarations are unaffected
package/README.md CHANGED
@@ -35,6 +35,36 @@ There are a couple of good reasons for this implementation:
35
35
 
36
36
  This library is available on [CDN](https://www.jsdelivr.com/package/npm/svg-path-commander), [npm](https://www.npmjs.com/package/svg-path-commander) and [JSR](https://jsr.io/@thednp/svg-path-commander).
37
37
 
38
+ <!-- BENCH:start -->
39
+ # Performance
40
+
41
+ A comparison of **SVGPathCommander** with the [SvgPath](https://github.com/fontello/svgpath) library v2.6.0 and its [svg-path-bbox](https://github.com/fontello/svg-path-bbox) helper v2.1.0, run with `pnpm bench` against a sample path with `11650` path segments. All values are in **milliseconds**, reported as `avg / best` over 10 runs after 3 warmups; lower is better. The `vs svgpath` column is the `avg` ratio of SVGPathCommander to svgpath.
42
+
43
+ `transform2d` uses `{ scale: 0.8 }`, `transform3d` uses `{ rotate: [15, 15, 30] }`. [SvgPath](https://github.com/fontello/svgpath) only supports 2D transforms, so `transform3d` is marked `n/a` for it.
44
+
45
+ ## Static methods
46
+
47
+ | Operation | SVGPathCommander (static) | svgpath | vs svgpath |
48
+ | --- | --- | --- | --- |
49
+ | parse | **7.4 / 7** | 9.7 / 9 | **0.8x** |
50
+ | bbox | **5.2 / 4** | 6.8 / 6 | **0.8x** |
51
+ | transform2d | 1.7 / 1 | 1.2 / 1 | 1.4x |
52
+ | transform3d | **14.3 / 11** | n/a | n/a |
53
+ | string | 6.2 / 5 | 5 / 5 | 1.2x |
54
+
55
+ ## Instance methods
56
+
57
+ | Operation | SVGPathCommander (instance) | svgpath | vs svgpath |
58
+ | --- | --- | --- | --- |
59
+ | parse | **7.3 / 7** | 9.7 / 9 | **0.8x** |
60
+ | bbox | **5 / 4** | 6.8 / 6 | **0.7x** |
61
+ | transform2d | 1.3 / 0 | 1.2 / 1 | 1.1x |
62
+ | transform3d | **8.4 / 7** | n/a | n/a |
63
+ | string | 5.9 / 5 | 5 / 5 | 1.2x |
64
+
65
+ Last benchmark run on `2026-08-05`. Generated by [`scripts/bench.js`](scripts/bench.js); update with `pnpm bench`.
66
+ <!-- BENCH:end -->
67
+
38
68
 
39
69
  # Install
40
70
 
@@ -47,7 +77,7 @@ npm install svg-path-commander
47
77
  # or npx jsr add @thednp/svg-path-commander
48
78
  ```
49
79
 
50
- Install from [JSR](https://jsr.io/@thednp/svg-path-commander) and import the raw TypeScript source:
80
+ In a Deno project, install from [JSR](https://jsr.io/@thednp/svg-path-commander) and import the raw TypeScript source directly:
51
81
 
52
82
  ```ts
53
83
  import SVGPathCommander from "jsr:@thednp/svg-path-commander";
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * SVGPathCommander v2.2.4 (http://thednp.github.io/svg-path-commander)
2
+ * SVGPathCommander v2.3.1 (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
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/interface.ts","../src/types.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/isArcCommand.ts","../src/parser/isDigit.ts","../src/parser/isDigitStart.ts","../src/parser/isMoveCommand.ts","../src/parser/isPathCommand.ts","../src/parser/isSpace.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/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/isPolygonArray.ts","../src/util/isCurveArray.ts","../src/util/isNormalizedArray.ts","../src/util/isPathArray.ts","../src/util/isPointInStroke.ts","../src/util/isRelativeArray.ts","../src/util/isValidPath.ts","../src/morph/samplePolygon.ts","../src/util/shapeToPath.ts","../src/util/shapeToPathArray.ts","../src/util/isMultiPath.ts","../src/util/isPolylineArray.ts","../src/util/isClosedPath.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","../src/main.ts"],"mappings":";;;;;;;;K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anceSquareRoot.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/isArcCommand.ts","../src/parser/isDigit.ts","../src/parser/isDigitStart.ts","../src/parser/isMoveCommand.ts","../src/parser/isPathCommand.ts","../src/parser/isSpace.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/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/isPolygonArray.ts","../src/util/isCurveArray.ts","../src/util/isNormalizedArray.ts","../src/util/isPathArray.ts","../src/util/isPointInStroke.ts","../src/util/isRelativeArray.ts","../src/util/isValidPath.ts","../src/morph/samplePolygon.ts","../src/util/shapeToPath.ts","../src/util/shapeToPathArray.ts","../src/util/isMultiPath.ts","../src/util/isPolylineArray.ts","../src/util/isClosedPath.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","../src/main.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;;EAEA;;EAEA;GACC;;;KAGS;;EAEV;;EAEA;;EAEA;;EAEA;;EAEA;GACC;;;KAGS;;EAEV;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;GACC;;;KAGS;;EAEV;;EAEA;GACC;;;KAIS;;EAEV;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;KAIU;;EAEV;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;KAGU;;EAEV;;IAEE;;IAEA;;;EAGF;;IAEE;;IAEA;;;;KAKQ;;EAEV;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;KAIU;;EAEV;;EAEA;;IAEE;;IAEA;;;EAGF;;IAEE;;IAEA;;;EAGF;;IAEE;;IAEA;;;;KAKQ;;EAEV;;EAEA;;;KAIU;;EAEV,GAAG;;EAEH;;EAEA;;EAEA;;;KAIU;;EAEV;;EAEA;;EAEA;;EAEA;;EAEA;;;KAIU,uBAAuB;;KAEvB,oBACV,gBACA,gBAAgB;;;;KC/ON;;KA8BA;;KAaA;;KAcA;;KAEA;;KAGA;;KAEA;;KAGA;;KAEA;;KAGA;;KAEA;;KAGA;;KAEA;;KAGA;;KAEA;;KAGA;;KAEA;;KAGA;;KAEA;;KAGA;;KAEA;;KAGA;;KAEA;;KAGA,kBACR,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA;;KAGQ,kBACR,WACA,WACA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AAoB;;SAEpB,oBAAW;;SAEX,qBAAY;;SAEZ,wBAAe;;SAEf"}
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  /*!
2
- * SVGPathCommander v2.2.4 (http://thednp.github.io/svg-path-commander)
2
+ * SVGPathCommander v2.3.1 (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
  */
6
6
  import CSSMatrix from "@thednp/dommatrix";
7
7
  //#region package.json
8
- var version = "2.2.4";
8
+ var version = "2.3.1";
9
9
  //#endregion
10
10
  //#region src/math/midPoint.ts
11
11
  /**
@@ -1120,12 +1120,25 @@ const finalizeSegment = (path) => {
1120
1120
  let pathCommand = path.pathValue[path.segmentStart];
1121
1121
  let relativeCommand = pathCommand.toLowerCase();
1122
1122
  const { data } = path;
1123
- while (data.length >= paramsCounts[relativeCommand]) {
1124
- if (relativeCommand === "m" && data.length > 2) {
1125
- path.segments.push([pathCommand].concat(data.splice(0, 2)));
1123
+ let index = 0;
1124
+ while (data.length - index >= paramsCounts[relativeCommand]) {
1125
+ if (relativeCommand === "m" && data.length - index > 2) {
1126
+ const segment = new Array(3);
1127
+ segment[0] = pathCommand;
1128
+ segment[1] = data[index];
1129
+ segment[2] = data[index + 1];
1130
+ path.segments.push(segment);
1131
+ index += 2;
1126
1132
  relativeCommand = "l";
1127
1133
  pathCommand = pathCommand === "m" ? "l" : "L";
1128
- } else path.segments.push([pathCommand].concat(data.splice(0, paramsCounts[relativeCommand])));
1134
+ } else {
1135
+ const paramCount = paramsCounts[relativeCommand];
1136
+ const segment = new Array(paramCount + 1);
1137
+ segment[0] = pathCommand;
1138
+ for (let i = 0; i < paramCount; i += 1) segment[i + 1] = data[index + i];
1139
+ path.segments.push(segment);
1140
+ index += paramCount;
1141
+ }
1129
1142
  if (!paramsCounts[relativeCommand]) break;
1130
1143
  }
1131
1144
  };
@@ -1240,7 +1253,60 @@ const scanParam = (path) => {
1240
1253
  }
1241
1254
  }
1242
1255
  path.index = index;
1243
- path.param = +path.pathValue.slice(start, index);
1256
+ path.param = scanNumber(pathValue, start, index);
1257
+ };
1258
+ /**
1259
+ * Converts a validated number substring to a Number without
1260
+ * allocating a new string, matching `+str.slice(start, end)`.
1261
+ *
1262
+ * Falls back to the native conversion when the value cannot be
1263
+ * represented exactly with plain double arithmetic (more than 15
1264
+ * significant digits or an exponent beyond +-22).
1265
+ *
1266
+ * @param str - the path string
1267
+ * @param start - the index of the first char of the number
1268
+ * @param end - the index after the last char of the number
1269
+ * @returns the parsed number
1270
+ */
1271
+ const scanNumber = (str, start, end) => {
1272
+ let i = start;
1273
+ let sign = 1;
1274
+ let param = 0;
1275
+ let decimals = 0;
1276
+ let sigDigits = 0;
1277
+ let inFraction = false;
1278
+ let expSign = 1;
1279
+ let exp = 0;
1280
+ const ch = str.charCodeAt(i);
1281
+ if (ch === 43) i += 1;
1282
+ else if (ch === 45) {
1283
+ sign = -1;
1284
+ i += 1;
1285
+ }
1286
+ for (; i < end; i += 1) {
1287
+ const code = str.charCodeAt(i);
1288
+ if (code === 46) inFraction = true;
1289
+ else if (code === 101 || code === 69) {
1290
+ i += 1;
1291
+ const expCode = str.charCodeAt(i);
1292
+ if (expCode === 43) i += 1;
1293
+ else if (expCode === 45) {
1294
+ expSign = -1;
1295
+ i += 1;
1296
+ }
1297
+ for (; i < end; i += 1) exp = exp * 10 + (str.charCodeAt(i) - 48);
1298
+ } else {
1299
+ const digit = code - 48;
1300
+ if (digit !== 0 || param !== 0) sigDigits += 1;
1301
+ param = param * 10 + digit;
1302
+ if (inFraction) decimals += 1;
1303
+ }
1304
+ }
1305
+ if (sigDigits > 15 || sigDigits === 0) return +str.slice(start, end);
1306
+ const scale = expSign * exp - decimals;
1307
+ if (scale > 22 || scale < -22) return +str.slice(start, end);
1308
+ if (scale >= 0) return sign * param * 10 ** scale;
1309
+ return sign * param / 10 ** -scale;
1244
1310
  };
1245
1311
  //#endregion
1246
1312
  //#region src/parser/isSpace.ts
@@ -1484,6 +1550,15 @@ const absolutizeSegment = (segment, index, lastX, lastY) => {
1484
1550
  segment[1] + lastX,
1485
1551
  segment[2] + lastY
1486
1552
  ];
1553
+ else if (absCommand === "C") return [
1554
+ absCommand,
1555
+ segment[1] + lastX,
1556
+ segment[2] + lastY,
1557
+ segment[3] + lastX,
1558
+ segment[4] + lastY,
1559
+ segment[5] + lastX,
1560
+ segment[6] + lastY
1561
+ ];
1487
1562
  else {
1488
1563
  const absValues = [];
1489
1564
  const seglen = segment.length;
@@ -1529,8 +1604,9 @@ const iterate = (path, iterator) => {
1529
1604
  while (i < path.length) {
1530
1605
  const segment = path[i];
1531
1606
  const [pathCommand] = segment;
1532
- const absCommand = pathCommand.toUpperCase();
1533
- const isRelative = absCommand !== pathCommand;
1607
+ const commandCode = pathCommand.charCodeAt(0);
1608
+ const isRelative = commandCode >= 97;
1609
+ const absCommand = isRelative ? String.fromCharCode(commandCode - 32) : pathCommand;
1534
1610
  const iteratorResult = iterator(segment, i, x, y);
1535
1611
  if (iteratorResult === false) break;
1536
1612
  if (absCommand === "Z") {
@@ -1974,20 +2050,19 @@ const pathToString = (path, roundOption) => {
1974
2050
  let segment = path[0];
1975
2051
  let result = "";
1976
2052
  round = roundOption === "off" ? roundOption : typeof roundOption === "number" && roundOption >= 0 ? roundOption : typeof round === "number" && round >= 0 ? round : "off";
2053
+ const pow = round === "off" ? 0 : 10 ** round;
1977
2054
  for (let i = 0; i < pathLen; i += 1) {
1978
2055
  segment = path[i];
1979
- const [pathCommand] = segment;
1980
- const values = segment.slice(1);
2056
+ const pathCommand = segment[0];
2057
+ const segLen = segment.length;
1981
2058
  result += pathCommand;
1982
- if (round === "off") result += values.join(" ");
1983
- else {
1984
- let j = 0;
1985
- const valLen = values.length;
1986
- while (j < valLen) {
1987
- result += roundTo(values[j], round);
1988
- if (j !== valLen - 1) result += " ";
1989
- j += 1;
1990
- }
2059
+ if (round === "off") for (let j = 1; j < segLen; j += 1) {
2060
+ result += segment[j];
2061
+ if (j !== segLen - 1) result += " ";
2062
+ }
2063
+ else for (let j = 1; j < segLen; j += 1) {
2064
+ result += Math.round(segment[j] * pow) / pow;
2065
+ if (j !== segLen - 1) result += " ";
1991
2066
  }
1992
2067
  }
1993
2068
  return result;
@@ -2039,8 +2114,10 @@ const getPathBBox = (pathInput) => {
2039
2114
  let paramQY = 0;
2040
2115
  iterate(path, (seg, index, lastX, lastY) => {
2041
2116
  [pathCommand] = seg;
2042
- const absCommand = pathCommand.toUpperCase();
2043
- const absoluteSegment = absCommand !== pathCommand ? absolutizeSegment(seg, index, lastX, lastY) : seg.slice(0);
2117
+ const commandCode = pathCommand.charCodeAt(0);
2118
+ const isRelative = commandCode >= 97;
2119
+ const absCommand = isRelative ? String.fromCharCode(commandCode - 32) : pathCommand;
2120
+ const absoluteSegment = isRelative ? absolutizeSegment(seg, index, lastX, lastY) : seg;
2044
2121
  const normalSegment = absCommand === "V" ? [
2045
2122
  "L",
2046
2123
  lastX,
@@ -2051,7 +2128,7 @@ const getPathBBox = (pathInput) => {
2051
2128
  lastY
2052
2129
  ] : absoluteSegment;
2053
2130
  [pathCommand] = normalSegment;
2054
- if (!"TQ".includes(absCommand)) {
2131
+ if (absCommand !== "T" && absCommand !== "Q") {
2055
2132
  paramQX = 0;
2056
2133
  paramQY = 0;
2057
2134
  }
@@ -2081,8 +2158,24 @@ const getPathBBox = (pathInput) => {
2081
2158
  yMin = min(minY, yMin);
2082
2159
  xMax = max(maxX, xMax);
2083
2160
  yMax = max(maxY, yMax);
2084
- [paramX1, paramY1] = pathCommand === "Z" ? [mx, my] : normalSegment.slice(-2);
2085
- [paramX2, paramY2] = pathCommand === "C" ? [normalSegment[3], normalSegment[4]] : pathCommand === "S" ? [normalSegment[1], normalSegment[2]] : [paramX1, paramY1];
2161
+ if (pathCommand === "Z") {
2162
+ paramX1 = mx;
2163
+ paramY1 = my;
2164
+ } else {
2165
+ const segLen = normalSegment.length;
2166
+ paramX1 = normalSegment[segLen - 2];
2167
+ paramY1 = normalSegment[segLen - 1];
2168
+ }
2169
+ if (pathCommand === "C") {
2170
+ paramX2 = normalSegment[3];
2171
+ paramY2 = normalSegment[4];
2172
+ } else if (pathCommand === "S") {
2173
+ paramX2 = normalSegment[1];
2174
+ paramY2 = normalSegment[2];
2175
+ } else {
2176
+ paramX2 = paramX1;
2177
+ paramY2 = paramY1;
2178
+ }
2086
2179
  });
2087
2180
  const width = xMax - xMin;
2088
2181
  const height = yMax - yMin;
@@ -3395,6 +3488,12 @@ const getSVGMatrix = (transform) => {
3395
3488
  * @returns the resulting Tuple
3396
3489
  */
3397
3490
  const translatePoint = (cssm, v) => {
3491
+ if (cssm.is2D) return [
3492
+ cssm.a * v[0] + cssm.c * v[1] + cssm.e * v[3],
3493
+ cssm.b * v[0] + cssm.d * v[1] + cssm.f * v[3],
3494
+ 0,
3495
+ 1
3496
+ ];
3398
3497
  let m = CSSMatrix.Translate(v[0], v[1], v[2]);
3399
3498
  [, , , m.m44] = v;
3400
3499
  m = cssm.multiply(m);
@@ -3435,6 +3534,161 @@ const projection2d = (m, point2D, origin) => {
3435
3534
  //#endregion
3436
3535
  //#region src/process/transformPath.ts
3437
3536
  /**
3537
+ * Applies a 2D transformation to a `PathArray` in a single pass, without
3538
+ * absolutizing or copying each segment, returning a new absolute `PathArray`.
3539
+ *
3540
+ * @param path the parsed path value
3541
+ * @param a the `a` value of the matrix
3542
+ * @param b the `b` value of the matrix
3543
+ * @param c the `c` value of the matrix
3544
+ * @param d the `d` value of the matrix
3545
+ * @param e the `e` value of the matrix
3546
+ * @param f the `f` value of the matrix
3547
+ * @param originX the transform origin `x` value
3548
+ * @param originY the transform origin `y` value
3549
+ * @returns the transformed absolute path
3550
+ */
3551
+ const transform2D = (path, a, b, c, d, e, f, originX, originY) => {
3552
+ const result = [];
3553
+ let x = 0;
3554
+ let y = 0;
3555
+ let lx = 0;
3556
+ let ly = 0;
3557
+ let ox = 0;
3558
+ let oy = 0;
3559
+ let omx = 0;
3560
+ let omy = 0;
3561
+ for (let i = 0, len = path.length; i < len; i += 1) {
3562
+ const seg = path[i];
3563
+ const pathCommand = seg[0];
3564
+ const commandCode = pathCommand.charCodeAt(0);
3565
+ const isRelative = commandCode >= 97;
3566
+ const absCommand = isRelative ? String.fromCharCode(commandCode - 32) : pathCommand;
3567
+ const outCommand = i === 0 && isRelative ? pathCommand : absCommand;
3568
+ if (absCommand === "Z") {
3569
+ result.push(["Z"]);
3570
+ ox = omx;
3571
+ oy = omy;
3572
+ continue;
3573
+ }
3574
+ if (absCommand === "V") {
3575
+ const absY = seg[1] + (isRelative ? oy : 0);
3576
+ lx = a * ox + c * absY + e - originX + originX;
3577
+ ly = b * ox + d * absY + f - originY + originY;
3578
+ if (x !== lx && y !== ly) result.push([
3579
+ "L",
3580
+ lx,
3581
+ ly
3582
+ ]);
3583
+ else if (y === ly) result.push(["H", lx]);
3584
+ else if (x === lx) result.push(["V", ly]);
3585
+ else result.push([
3586
+ "L",
3587
+ ox,
3588
+ absY
3589
+ ]);
3590
+ oy = absY;
3591
+ x = lx;
3592
+ y = ly;
3593
+ continue;
3594
+ }
3595
+ if (absCommand === "H") {
3596
+ const absX = seg[1] + (isRelative ? ox : 0);
3597
+ lx = a * absX + c * oy + e - originX + originX;
3598
+ ly = b * absX + d * oy + f - originY + originY;
3599
+ if (x !== lx && y !== ly) result.push([
3600
+ "L",
3601
+ lx,
3602
+ ly
3603
+ ]);
3604
+ else if (y === ly) result.push(["H", lx]);
3605
+ else if (x === lx) result.push(["V", ly]);
3606
+ else result.push([
3607
+ "L",
3608
+ absX,
3609
+ oy
3610
+ ]);
3611
+ ox = absX;
3612
+ x = lx;
3613
+ y = ly;
3614
+ continue;
3615
+ }
3616
+ if (absCommand === "A") {
3617
+ const absX = seg[6] + (isRelative ? ox : 0);
3618
+ const absY = seg[7] + (isRelative ? oy : 0);
3619
+ const cubics = arcToCubic(ox, oy, seg[1], seg[2], seg[3], seg[4], seg[5], absX, absY);
3620
+ const cubicsLen = cubics.length;
3621
+ let k = 0;
3622
+ if (cubicsLen > 0) do {
3623
+ const piece = ["C"];
3624
+ const end = k + 6;
3625
+ for (let j = k; j < end; j += 2) {
3626
+ lx = a * cubics[j] + c * cubics[j + 1] + e - originX + originX;
3627
+ ly = b * cubics[j] + d * cubics[j + 1] + f - originY + originY;
3628
+ piece.push(lx, ly);
3629
+ }
3630
+ result.push(piece);
3631
+ k = end;
3632
+ } while (k < cubicsLen);
3633
+ else result.push(["C"]);
3634
+ if (cubicsLen > 0) {
3635
+ ox = cubics[cubicsLen - 2];
3636
+ oy = cubics[cubicsLen - 1];
3637
+ } else {
3638
+ ox = absX;
3639
+ oy = absY;
3640
+ }
3641
+ x = lx;
3642
+ y = ly;
3643
+ continue;
3644
+ }
3645
+ if (absCommand === "L") {
3646
+ const absX = seg[1] + (isRelative ? ox : 0);
3647
+ const absY = seg[2] + (isRelative ? oy : 0);
3648
+ lx = a * absX + c * absY + e - originX + originX;
3649
+ ly = b * absX + d * absY + f - originY + originY;
3650
+ if (x !== lx && y !== ly) result.push([
3651
+ "L",
3652
+ lx,
3653
+ ly
3654
+ ]);
3655
+ else if (y === ly) result.push(["H", lx]);
3656
+ else if (x === lx) result.push(["V", ly]);
3657
+ else result.push([
3658
+ "L",
3659
+ absX,
3660
+ absY
3661
+ ]);
3662
+ ox = absX;
3663
+ oy = absY;
3664
+ x = lx;
3665
+ y = ly;
3666
+ continue;
3667
+ }
3668
+ {
3669
+ const piece = [outCommand];
3670
+ const segLen = seg.length;
3671
+ for (let j = 1; j < segLen; j += 2) {
3672
+ const absX = seg[j] + (isRelative ? ox : 0);
3673
+ const absY = seg[j + 1] + (isRelative ? oy : 0);
3674
+ lx = a * absX + c * absY + e - originX + originX;
3675
+ ly = b * absX + d * absY + f - originY + originY;
3676
+ piece.push(lx, ly);
3677
+ }
3678
+ result.push(piece);
3679
+ ox = seg[segLen - 2] + (isRelative ? ox : 0);
3680
+ oy = seg[segLen - 1] + (isRelative ? oy : 0);
3681
+ if (absCommand === "M") {
3682
+ omx = ox;
3683
+ omy = oy;
3684
+ }
3685
+ x = lx;
3686
+ y = ly;
3687
+ }
3688
+ }
3689
+ return result;
3690
+ };
3691
+ /**
3438
3692
  * Apply a 2D / 3D transformation to a PathArray.
3439
3693
  *
3440
3694
  * Since SVGElement doesn't support 3D transformation, this function
@@ -3451,12 +3705,6 @@ const projection2d = (m, point2D, origin) => {
3451
3705
  * ```
3452
3706
  */
3453
3707
  const transformPath = (pathInput, transform) => {
3454
- let x = 0;
3455
- let y = 0;
3456
- let lx = 0;
3457
- let ly = 0;
3458
- let j = 0;
3459
- let jj = 0;
3460
3708
  const path = parsePathString(pathInput);
3461
3709
  const transformProps = transform && Object.keys(transform);
3462
3710
  if (!transform || transformProps && !transformProps.length) return path.slice(0);
@@ -3464,8 +3712,15 @@ const transformPath = (pathInput, transform) => {
3464
3712
  const origin = transform.origin;
3465
3713
  const matrixInstance = getSVGMatrix(transform);
3466
3714
  if (matrixInstance.isIdentity) return path.slice(0);
3715
+ if (matrixInstance.is2D) return transform2D(path, matrixInstance.a, matrixInstance.b, matrixInstance.c, matrixInstance.d, matrixInstance.e, matrixInstance.f, origin[0], origin[1]);
3716
+ let x = 0;
3717
+ let y = 0;
3718
+ let lx = 0;
3719
+ let ly = 0;
3720
+ let j = 0;
3721
+ let jj = 0;
3467
3722
  return iterate(path, (seg, index, lastX, lastY) => {
3468
- let [pathCommand] = seg;
3723
+ const [pathCommand] = seg;
3469
3724
  const absCommand = pathCommand.toUpperCase();
3470
3725
  const absoluteSegment = absCommand !== pathCommand ? absolutizeSegment(seg, index, lastX, lastY) : seg.slice(0);
3471
3726
  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" ? [
@@ -3477,14 +3732,12 @@ const transformPath = (pathInput, transform) => {
3477
3732
  absoluteSegment[1],
3478
3733
  lastY
3479
3734
  ] : absoluteSegment;
3480
- pathCommand = result[0];
3481
- const isLongArc = pathCommand === "C" && result.length > 7;
3482
- const tempSegment = isLongArc ? result.slice(0, 7) : result.slice(0);
3483
- if (isLongArc) {
3735
+ if (result[0] === "C" && result.length > 7) {
3736
+ const tempSegment = result.slice(0, 7);
3484
3737
  path.splice(index + 1, 0, ["C"].concat(result.slice(7)));
3485
3738
  result = tempSegment;
3486
3739
  }
3487
- if (pathCommand === "L") {
3740
+ if (result[0] === "L") {
3488
3741
  [lx, ly] = projection2d(matrixInstance, [result[1], result[2]], origin);
3489
3742
  if (x !== lx && y !== ly) result = [
3490
3743
  "L",