svg-path-commander 2.0.10 → 2.1.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.
Files changed (75) hide show
  1. package/.eslintrc.cjs +1 -0
  2. package/README.md +64 -8
  3. package/dist/svg-path-commander.cjs +1 -1
  4. package/dist/svg-path-commander.cjs.map +1 -1
  5. package/dist/svg-path-commander.d.ts +236 -43
  6. package/dist/svg-path-commander.js +1 -1
  7. package/dist/svg-path-commander.js.map +1 -1
  8. package/dist/svg-path-commander.mjs +790 -650
  9. package/dist/svg-path-commander.mjs.map +1 -1
  10. package/package.json +20 -22
  11. package/src/convert/pathToAbsolute.ts +16 -70
  12. package/src/convert/pathToCurve.ts +36 -28
  13. package/src/convert/pathToRelative.ts +33 -62
  14. package/src/index.ts +37 -39
  15. package/src/interface.ts +33 -33
  16. package/src/math/arcTools.ts +394 -0
  17. package/src/math/bezier.ts +253 -0
  18. package/src/math/cubicTools.ts +122 -0
  19. package/src/math/distanceSquareRoot.ts +3 -1
  20. package/src/math/lineTools.ts +67 -0
  21. package/src/math/midPoint.ts +3 -1
  22. package/src/math/polygonArea.ts +3 -1
  23. package/src/math/polygonLength.ts +2 -1
  24. package/src/math/quadTools.ts +98 -0
  25. package/src/parser/isMoveCommand.ts +17 -0
  26. package/src/parser/parsePathString.ts +5 -5
  27. package/src/parser/scanSegment.ts +12 -3
  28. package/src/process/absolutizeSegment.ts +58 -0
  29. package/src/process/iterate.ts +33 -0
  30. package/src/process/normalizePath.ts +34 -28
  31. package/src/process/normalizeSegment.ts +8 -9
  32. package/src/process/projection2d.ts +2 -1
  33. package/src/process/relativizeSegment.ts +61 -0
  34. package/src/process/reversePath.ts +1 -1
  35. package/src/process/roundPath.ts +8 -10
  36. package/src/process/segmentToCubic.ts +1 -1
  37. package/src/process/shortenSegment.ts +3 -3
  38. package/src/process/splitCubic.ts +8 -7
  39. package/src/process/splitPath.ts +39 -5
  40. package/src/process/transformPath.ts +81 -94
  41. package/src/types.ts +40 -1
  42. package/src/util/distanceEpsilon.ts +3 -0
  43. package/src/util/getClosestPoint.ts +1 -1
  44. package/src/util/getPathArea.ts +3 -3
  45. package/src/util/getPathBBox.ts +86 -18
  46. package/src/util/getPointAtLength.ts +98 -4
  47. package/src/util/getPropertiesAtLength.ts +4 -3
  48. package/src/util/getPropertiesAtPoint.ts +4 -1
  49. package/src/util/getTotalLength.ts +71 -4
  50. package/src/util/isPointInStroke.ts +2 -1
  51. package/src/util/shapeToPathArray.ts +8 -4
  52. package/test/class.test.ts +502 -0
  53. package/test/fixtures/getMarkup.ts +17 -0
  54. package/{cypress → test}/fixtures/shapes.js +39 -39
  55. package/test/fixtures/simpleShapes.js +75 -0
  56. package/test/static.test.ts +324 -0
  57. package/tsconfig.json +9 -4
  58. package/{vite.config.ts → vite.config.mts} +10 -1
  59. package/vitest.config-ui.mts +26 -0
  60. package/vitest.config.mts +26 -0
  61. package/cypress/e2e/svg-path-commander.spec.ts +0 -868
  62. package/cypress/fixtures/simpleShapes.js +0 -75
  63. package/cypress/plugins/esbuild-istanbul.ts +0 -50
  64. package/cypress/plugins/tsCompile.ts +0 -34
  65. package/cypress/support/commands.ts +0 -37
  66. package/cypress/support/e2e.ts +0 -21
  67. package/cypress/test.html +0 -36
  68. package/cypress.config.ts +0 -29
  69. package/src/process/fixArc.ts +0 -23
  70. package/src/util/pathLengthFactory.ts +0 -114
  71. package/src/util/segmentArcFactory.ts +0 -219
  72. package/src/util/segmentCubicFactory.ts +0 -114
  73. package/src/util/segmentLineFactory.ts +0 -45
  74. package/src/util/segmentQuadFactory.ts +0 -109
  75. /package/{cypress/fixtures/shapeObjects.js → test/fixtures/shapeObjects.ts} +0 -0
@@ -20,24 +20,24 @@ const shapes = {
20
20
  "M8.66 8.66L8.66 4.66L7.34 4.66L7.34 8.66L8.65 8.66ZM8.66 11.34L8.66 10L7.34 10L7.34 11.34L8.65 11.34ZM8 1.34Q10.75 1.34 12.7 3.29Q14.65 5.24 14.66 8Q14.67 10.76 12.71 12.7Q10.75 14.64 8 14.66Q5.25 14.68 3.3 12.7Q1.35 10.72 1.34 8Q1.33 5.28 3.3 3.3Q5.27 1.32 8 1.34Z"
21
21
  ],
22
22
  optimized: [
23
- "M16 8C16 4.13 12.42 1 8 1S0 4.13 0 8c0 1.76 0.74 3.37 1.97 4.6c-0.1 1.02 -0.42 2.13 -0.77 2.97c-0.08 0.19 0.07 0.39 0.27 0.36c2.26 -0.37 3.6 -0.94 4.18 -1.23A9.06 9.06 0 0 0 8 15c4.42 0 8 -3.13 8 -7zM7.19 6.77c0.09 0.12 0.16 0.26 0.23 0.4c0.43 0.95 0.39 2.38 -0.94 3.71a0.45 0.45 0 0 1 -0.61 0.01A0.41 0.41 0 0 1 5.86 10.29C6.27 9.88 6.53 9.46 6.67 9.07C6.4 9.24 6.08 9.33 5.74 9.33C4.78 9.33 4 8.59 4 7.67S4.78 6 5.73 6c0.27 0 0.53 0.06 0.76 0.17l0.01 0c0.17 0.07 0.33 0.18 0.47 0.32c0.08 0.08 0.16 0.17 0.23 0.27zM11 9.07c-0.27 0.16 -0.59 0.26 -0.93 0.26C9.11 9.33 8.34 8.59 8.34 7.67S9.11 6 10.07 6c0.27 0 0.53 0.06 0.76 0.17l0.01 0C11 6.24 11.16 6.35 11.3 6.49c0.09 0.08 0.16 0.17 0.23 0.27c0.09 0.12 0.16 0.26 0.23 0.4c0.43 0.95 0.39 2.38 -0.94 3.71a0.45 0.45 0 0 1 -0.61 0.01a0.41 0.41 0 0 1 -0.01 -0.59C10.61 9.87 10.86 9.46 11 9.07z",
24
- "M16 14V5H0v9a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2zM2.56 12.33H1.85L3.75 7h0.7l1.9 5.33H5.62l-0.54 -1.6H3.1l-0.54 1.6zM4.1 7.81H4.08l-0.8 2.38H4.9L4.1 7.81zM9.85 8.23v4.11H9.18v-0.54H9.16C9.01 12.12 8.62 12.4 7.97 12.4c-0.85 0 -1.45 -0.48 -1.45 -1.43V8.23h0.68v2.55c0 0.77 0.44 1.01 0.98 1.01c0.59 0 1 -0.37 1 -1.02V8.23h0.68zM11.12 12.64c0.07 0.33 0.42 0.64 0.98 0.64c0.65 0 1.07 -0.38 1.07 -1.02v-0.61h-0.02C13 12 12.55 12.29 11.99 12.29c-0.96 0 -1.64 -0.67 -1.64 -1.9v-0.34c0 -1.21 0.68 -1.89 1.64 -1.89c0.56 0 1 0.29 1.2 0.64h0.02V8.23h0.65v4.03c0 1.05 -0.82 1.58 -1.75 1.58c-1.04 0 -1.57 -0.52 -1.67 -1.2h0.69zM13.18 10.1c0 -0.83 -0.41 -1.36 -1.06 -1.36c-0.69 0 -1.1 0.49 -1.1 1.36v0.25c0 0.85 0.41 1.36 1.1 1.36c0.67 0 1.06 -0.52 1.06 -1.36V10.1zM4 0.5a0.5 0.5 0 0 0 -1 0V1H2A2 2 0 0 0 0 3v1h16V3A2 2 0 0 0 14 1h-1V0.5a0.5 0.5 0 0 0 -1 0V1H4V0.5z",
25
- "M5.5 0.5A0.5 0.5 0 0 1 6 0h4a0.5 0.5 0 0 1 0 1H9v1.07a7 7 0 0 1 3.54 12.26l0.82 0.82a0.5 0.5 0 0 1 -0.71 0.71l-0.92 -0.93A6.97 6.97 0 0 1 8 16A6.97 6.97 0 0 1 4.28 14.93l-0.92 0.92A0.5 0.5 0 0 1 2.65 15.15l0.82 -0.82A7 7 0 0 1 7 2.07V1H6A0.5 0.5 0 0 1 5.5 0.5zM0.86 5.39A2.5 2.5 0 1 1 4.39 1.86A8.04 8.04 0 0 0 0.86 5.39zM13.5 1c-0.75 0 -1.43 0.33 -1.89 0.86a8.04 8.04 0 0 1 3.53 3.53A2.5 2.5 0 0 0 13.5 1zM8.5 5a0.5 0.5 0 0 0 -1 0v3.88l-1.45 2.89a0.5 0.5 0 1 0 0.89 0.45l1.5 -3A0.5 0.5 0 0 0 8.5 9V5z",
26
- "M2 0h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2H2A2 2 0 0 1 0 14V2A2 2 0 0 1 2 0zM5.35 4.65A0.5 0.5 0 1 0 4.65 5.35L7.29 8l-2.65 2.65a0.5 0.5 0 0 0 0.71 0.71L8 8.71l2.65 2.65a0.5 0.5 0 0 0 0.71 -0.71L8.71 8l2.65 -2.65A0.5 0.5 0 0 0 10.65 4.65L8 7.29L5.35 4.65z",
27
- "M2 4A2 2 0 0 0 0 6v6a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2V6A2 2 0 0 0 14 4h-1.17A2 2 0 0 1 11.41 3.41L10.59 2.59A2 2 0 0 0 9.17 2H6.83A2 2 0 0 0 5.41 2.59L4.59 3.41A2 2 0 0 1 3.17 4H2zM10.5 8.5a2.5 2.5 0 0 0 -5 0a2.5 2.5 0 1 0 5 0zM2.5 6a0.5 0.5 0 0 1 0 -1a0.5 0.5 0 1 1 0 1zM11.5 8.5a3.5 3.5 0 1 1 -7 0a3.5 3.5 0 0 1 7 0z",
28
- "M2 0A2 2 0 0 0 0 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2V2A2 2 0 0 0 14 0H2zM9.5 11h-4A0.5 0.5 0 0 1 5 10.5v-4a0.5 0.5 0 0 1 1 0v2.79l4.15 -4.15a0.5 0.5 0 0 1 0.71 0.71L6.71 10H9.5a0.5 0.5 0 0 1 0 1z",
23
+ "M16 8C16 4.13 12.42 1 8 1S0 4.13 0 8c0 1.76 0.74 3.37 1.97 4.6c-0.1 1.02 -0.42 2.13 -0.77 2.97c-0.08 0.18 0.07 0.39 0.27 0.36c2.26 -0.37 3.6 -0.94 4.18 -1.24A9.06 9.06 0 0 0 8 15c4.42 0 8 -3.13 8 -7zM7.19 6.77c0.09 0.12 0.17 0.26 0.23 0.4c0.43 0.94 0.39 2.37 -0.94 3.7a0.45 0.45 0 0 1 -0.61 0.01A0.41 0.41 0 0 1 5.86 10.29C6.27 9.88 6.53 9.46 6.67 9.07C6.4 9.24 6.08 9.33 5.74 9.33C4.78 9.33 4 8.59 4 7.67S4.78 6 5.73 6c0.28 0 0.53 0.06 0.76 0.17l0.01 0c0.17 0.07 0.32 0.18 0.47 0.32c0.08 0.09 0.16 0.18 0.22 0.28zM11 9.07c-0.27 0.17 -0.59 0.26 -0.93 0.26C9.11 9.33 8.34 8.59 8.34 7.67S9.11 6 10.07 6c0.27 0 0.53 0.06 0.75 0.17l0.01 0C11 6.24 11.16 6.35 11.3 6.49c0.09 0.09 0.16 0.18 0.23 0.27c0.08 0.13 0.16 0.26 0.22 0.4c0.43 0.95 0.4 2.38 -0.94 3.71a0.45 0.45 0 0 1 -0.61 0.01a0.41 0.41 0 0 1 -0.01 -0.59C10.61 9.87 10.86 9.46 11 9.07z",
24
+ "M16 14V5H0v9a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2zM2.56 12.33H1.85L3.75 7h0.69l1.9 5.33H5.62l-0.54 -1.6H3.1l-0.54 1.6zM4.1 7.81H4.08l-0.8 2.37H4.9L4.1 7.81zm5.75 0.42v4.1H9.18v-0.54H9.16C9.01 12.12 8.62 12.4 7.97 12.4c-0.85 0 -1.46 -0.49 -1.46 -1.43V8.23h0.68v2.55c0 0.77 0.44 1.01 0.98 1.01c0.59 0 1 -0.37 1 -1.02V8.23h0.68zm1.27 4.41c0.08 0.33 0.43 0.63 0.99 0.63c0.65 0 1.07 -0.37 1.07 -1.02v-0.6h-0.02C13 12 12.55 12.29 11.99 12.29c-0.96 0 -1.64 -0.67 -1.64 -1.9v-0.34c0 -1.21 0.67 -1.89 1.64 -1.89c0.56 0 1 0.3 1.19 0.64h0.02V8.23h0.65v4.03c0 1.05 -0.82 1.58 -1.75 1.58c-1.04 0 -1.57 -0.52 -1.66 -1.2h0.68zm2.06 -2.54c0 -0.83 -0.42 -1.36 -1.06 -1.36c-0.7 0 -1.1 0.49 -1.1 1.36v0.26c0 0.85 0.4 1.36 1.1 1.36c0.67 0 1.06 -0.52 1.06 -1.36V10.1zM4 0.5a0.5 0.5 0 0 0 -1 0V1H2A2 2 0 0 0 0 3v1h16V3A2 2 0 0 0 14 1h-1V0.5a0.5 0.5 0 0 0 -1 0V1H4V0.5z",
25
+ "M5.5 0.5A0.5 0.5 0 0 1 6 0h4a0.5 0.5 0 0 1 0 1H9v1.07a7 7 0 0 1 3.54 12.26l0.81 0.82a0.5 0.5 0 0 1 -0.7 0.7l-0.93 -0.92A6.97 6.97 0 0 1 8 16A6.97 6.97 0 0 1 4.28 14.93l-0.93 0.92a0.5 0.5 0 0 1 -0.7 -0.7l0.81 -0.82A7 7 0 0 1 7 2.07V1H6A0.5 0.5 0 0 1 5.5 0.5zM0.86 5.39A2.5 2.5 0 1 1 4.39 1.86A8.04 8.04 0 0 0 0.86 5.39zM13.5 1c-0.75 0 -1.43 0.33 -1.89 0.86a8.04 8.04 0 0 1 3.53 3.53A2.5 2.5 0 0 0 13.5 1zm-5 4a0.5 0.5 0 0 0 -1 0v3.88l-1.45 2.9a0.5 0.5 0 1 0 0.9 0.44l1.5 -3A0.5 0.5 0 0 0 8.5 9V5z",
26
+ "M2 0h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2H2A2 2 0 0 1 0 14V2A2 2 0 0 1 2 0zm3.35 4.65a0.5 0.5 0 1 0 -0.7 0.7L7.29 8l-2.64 2.65a0.5 0.5 0 0 0 0.7 0.7L8 8.71l2.65 2.64a0.5 0.5 0 0 0 0.7 -0.7L8.71 8l2.64 -2.65a0.5 0.5 0 0 0 -0.7 -0.7L8 7.29L5.35 4.65z",
27
+ "M2 4A2 2 0 0 0 0 6v6a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2V6A2 2 0 0 0 14 4h-1.17A2 2 0 0 1 11.41 3.41L10.59 2.59A2 2 0 0 0 9.17 2H6.83A2 2 0 0 0 5.41 2.59L4.59 3.41A2 2 0 0 1 3.17 4H2zm8.5 4.5a2.5 2.5 0 0 0 -5 0a2.5 2.5 0 1 0 5 0zM2.5 6a0.5 0.5 0 0 1 0 -1a0.5 0.5 0 1 1 0 1zm9 2.5a3.5 3.5 0 1 1 -7 0a3.5 3.5 0 0 1 7 0z",
28
+ "M2 0A2 2 0 0 0 0 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2V2A2 2 0 0 0 14 0H2zm7.5 11h-4A0.5 0.5 0 0 1 5 10.5v-4a0.5 0.5 0 0 1 1 0v2.79l4.15 -4.14a0.5 0.5 0 0 1 0.7 0.7L6.71 10H9.5a0.5 0.5 0 0 1 0 1z",
29
29
  "M15.98 8.51c-0.38 6.15 -7.27 9.57 -12.4 6.17C3.27 14.47 2.98 14.25 2.71 14.01l5.5 -5.5h7.78zM2 13.3L7.5 7.8V0.03C1.35 0.41 -2.07 7.3 1.33 12.43c0.2 0.3 0.42 0.59 0.67 0.87zM8.5 0.03c4.02 0.25 7.23 3.46 7.49 7.49H8.5V0.03z",
30
- "M8.66 8.66v-4H7.34v4h1.31zM8.66 11.34V10H7.34v1.34h1.31zM8 1.34q2.75 0 4.7 1.95T14.66 8t-1.95 4.7T8 14.66T3.3 12.7T1.34 8T3.3 3.3T8 1.34z"
30
+ "M8.66 8.66v-4H7.34v4h1.31zm0 2.68V10H7.34v1.34h1.31zM8 1.34q2.75 0 4.7 1.95T14.66 8t-1.95 4.7T8 14.66T3.3 12.7T1.34 8T3.3 3.3T8 1.34z"
31
31
  ],
32
32
  relative: [
33
- "M16 8c0 -3.87 -3.58 -7 -8 -7s-8 3.13 -8 7c0 1.76 0.74 3.37 1.97 4.6c-0.1 1.02 -0.42 2.13 -0.77 2.97c-0.08 0.19 0.07 0.39 0.27 0.36c2.26 -0.37 3.6 -0.94 4.18 -1.23a9.06 9.06 0 0 0 2.35 0.31c4.42 0 8 -3.13 8 -7zM7.19 6.77c0.09 0.12 0.16 0.26 0.23 0.4c0.43 0.95 0.39 2.38 -0.94 3.71a0.45 0.45 0 0 1 -0.61 0.01a0.41 0.41 0 0 1 -0.01 -0.59c0.42 -0.42 0.67 -0.83 0.81 -1.22c-0.27 0.17 -0.59 0.26 -0.93 0.26c-0.96 0 -1.74 -0.75 -1.74 -1.67c0 -0.92 0.78 -1.67 1.73 -1.67c0.27 0 0.53 0.06 0.76 0.17l0.01 0c0.17 0.07 0.33 0.18 0.47 0.32c0.08 0.08 0.16 0.17 0.23 0.27zM11 9.07c-0.27 0.16 -0.59 0.26 -0.93 0.26c-0.96 0 -1.73 -0.75 -1.73 -1.67c0 -0.92 0.78 -1.67 1.73 -1.67c0.27 0 0.53 0.06 0.76 0.17l0.01 0c0.17 0.07 0.33 0.18 0.47 0.32c0.09 0.08 0.16 0.17 0.23 0.27c0.09 0.12 0.16 0.26 0.23 0.4c0.43 0.95 0.39 2.38 -0.94 3.71a0.45 0.45 0 0 1 -0.61 0.01a0.41 0.41 0 0 1 -0.01 -0.59c0.42 -0.42 0.67 -0.83 0.81 -1.22z",
34
- "M16 14v-9h-16v9a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2zM2.56 12.33h-0.71l1.9 -5.33h0.7l1.9 5.33h-0.72l-0.54 -1.6h-1.98l-0.54 1.6zM4.1 7.81h-0.02l-0.8 2.38h1.62l-0.8 -2.37zM9.85 8.23v4.11h-0.67v-0.54h-0.03c-0.14 0.33 -0.53 0.61 -1.19 0.61c-0.85 0 -1.45 -0.48 -1.45 -1.42v-2.75h0.68v2.55c0 0.77 0.44 1.01 0.98 1.01c0.59 0 1 -0.37 1 -1.02v-2.54h0.68zM11.12 12.64c0.08 0.33 0.42 0.64 0.99 0.64c0.65 0 1.07 -0.38 1.07 -1.02v-0.6h-0.02c-0.16 0.36 -0.61 0.65 -1.17 0.65c-0.96 0 -1.64 -0.67 -1.64 -1.9v-0.34c0 -1.21 0.68 -1.89 1.64 -1.89c0.56 0 1 0.29 1.2 0.64h0.02v-0.58h0.65v4.03c0 1.05 -0.82 1.58 -1.75 1.58c-1.04 0 -1.57 -0.52 -1.67 -1.2h0.69zM13.18 10.1c0 -0.83 -0.41 -1.36 -1.06 -1.36c-0.69 0 -1.1 0.49 -1.1 1.36v0.25c0 0.85 0.41 1.36 1.1 1.36c0.67 0 1.06 -0.52 1.06 -1.36v-0.25zM4 0.5a0.5 0.5 0 0 0 -1 0v0.5h-1a2 2 0 0 0 -2 2v1h16v-1a2 2 0 0 0 -2 -2h-1v-0.5a0.5 0.5 0 0 0 -1 0v0.5h-8v-0.5z",
35
- "M5.5 0.5a0.5 0.5 0 0 1 0.5 -0.5h4a0.5 0.5 0 0 1 0 1h-1v1.07a7 7 0 0 1 3.54 12.26l0.82 0.82a0.5 0.5 0 0 1 -0.71 0.71l-0.92 -0.92a6.97 6.97 0 0 1 -3.72 1.07a6.97 6.97 0 0 1 -3.72 -1.07l-0.92 0.92a0.5 0.5 0 0 1 -0.71 -0.71l0.82 -0.82a7 7 0 0 1 3.54 -12.26v-1.07h-1a0.5 0.5 0 0 1 -0.5 -0.5zM0.86 5.39a2.5 2.5 0 1 1 3.53 -3.53a8.04 8.04 0 0 0 -3.53 3.53zM13.5 1c-0.75 0 -1.43 0.33 -1.89 0.86a8.04 8.04 0 0 1 3.53 3.53a2.5 2.5 0 0 0 -1.64 -4.39zm-5 4a0.5 0.5 0 0 0 -1 0v3.88l-1.45 2.89a0.5 0.5 0 1 0 0.89 0.45l1.5 -3a0.5 0.5 0 0 0 0.05 -0.22v-4z",
33
+ "M16 8c0 -3.87 -3.58 -7 -8 -7s-8 3.13 -8 7c0 1.76 0.74 3.37 1.97 4.6c-0.1 1.02 -0.42 2.13 -0.77 2.97c-0.08 0.19 0.07 0.39 0.27 0.36c2.26 -0.37 3.6 -0.94 4.18 -1.23a9.06 9.06 0 0 0 2.35 0.31c4.42 0 8 -3.13 8 -7zm-8.81 -1.23c0.09 0.12 0.16 0.26 0.23 0.4c0.43 0.95 0.39 2.38 -0.94 3.71a0.45 0.45 0 0 1 -0.61 0.01a0.41 0.41 0 0 1 -0.01 -0.59c0.42 -0.42 0.67 -0.83 0.81 -1.22c-0.27 0.17 -0.59 0.26 -0.93 0.26c-0.96 0 -1.74 -0.75 -1.74 -1.67c0 -0.92 0.78 -1.67 1.73 -1.67c0.27 0 0.53 0.06 0.76 0.17l0.01 0c0.17 0.07 0.33 0.18 0.47 0.32c0.08 0.08 0.16 0.17 0.23 0.27zm3.81 2.31c-0.27 0.16 -0.59 0.26 -0.93 0.26c-0.96 0 -1.73 -0.75 -1.73 -1.67c0 -0.92 0.78 -1.67 1.73 -1.67c0.27 0 0.53 0.06 0.76 0.17l0.01 0c0.17 0.07 0.33 0.18 0.47 0.32c0.09 0.08 0.16 0.17 0.23 0.27c0.09 0.12 0.16 0.26 0.23 0.4c0.43 0.95 0.39 2.38 -0.94 3.71a0.45 0.45 0 0 1 -0.61 0.01a0.41 0.41 0 0 1 -0.01 -0.59c0.42 -0.42 0.67 -0.83 0.81 -1.22z",
34
+ "M16 14v-9h-16v9a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2zm-13.44 -1.67h-0.71l1.9 -5.33h0.7l1.9 5.33h-0.72l-0.54 -1.6h-1.98l-0.54 1.6zm1.54 -4.53h-0.02l-0.8 2.38h1.62l-0.8 -2.37zm5.75 0.42v4.11h-0.67v-0.54h-0.03c-0.14 0.33 -0.53 0.61 -1.19 0.61c-0.85 0 -1.45 -0.48 -1.45 -1.42v-2.75h0.68v2.55c0 0.77 0.44 1.01 0.98 1.01c0.59 0 1 -0.37 1 -1.02v-2.54h0.68zm1.27 4.41c0.08 0.33 0.42 0.64 0.99 0.64c0.65 0 1.07 -0.38 1.07 -1.02v-0.6h-0.02c-0.16 0.36 -0.61 0.65 -1.17 0.65c-0.96 0 -1.64 -0.67 -1.64 -1.9v-0.34c0 -1.21 0.68 -1.89 1.64 -1.89c0.56 0 1 0.29 1.2 0.64h0.02v-0.58h0.65v4.03c0 1.05 -0.82 1.58 -1.75 1.58c-1.04 0 -1.57 -0.52 -1.67 -1.2h0.69zm2.06 -2.53c0 -0.83 -0.41 -1.36 -1.06 -1.36c-0.69 0 -1.1 0.49 -1.1 1.36v0.25c0 0.85 0.41 1.36 1.1 1.36c0.67 0 1.06 -0.52 1.06 -1.36v-0.25zm-9.18 -9.6a0.5 0.5 0 0 0 -1 0v0.5h-1a2 2 0 0 0 -2 2v1h16v-1a2 2 0 0 0 -2 -2h-1v-0.5a0.5 0.5 0 0 0 -1 0v0.5h-8v-0.5z",
35
+ "M5.5 0.5a0.5 0.5 0 0 1 0.5 -0.5h4a0.5 0.5 0 0 1 0 1h-1v1.07a7 7 0 0 1 3.54 12.26l0.82 0.82a0.5 0.5 0 0 1 -0.71 0.71l-0.92 -0.92a6.97 6.97 0 0 1 -3.72 1.07a6.97 6.97 0 0 1 -3.72 -1.07l-0.92 0.92a0.5 0.5 0 0 1 -0.71 -0.71l0.82 -0.82a7 7 0 0 1 3.54 -12.26v-1.07h-1a0.5 0.5 0 0 1 -0.5 -0.5zm-4.64 4.89a2.5 2.5 0 1 1 3.53 -3.53a8.04 8.04 0 0 0 -3.53 3.53zm12.64 -4.39c-0.75 0 -1.43 0.33 -1.89 0.86a8.04 8.04 0 0 1 3.53 3.53a2.5 2.5 0 0 0 -1.64 -4.39zm-5 4a0.5 0.5 0 0 0 -1 0v3.88l-1.45 2.89a0.5 0.5 0 1 0 0.89 0.45l1.5 -3a0.5 0.5 0 0 0 0.05 -0.22v-4z",
36
36
  "M2 0h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2zm3.35 4.65a0.5 0.5 0 1 0 -0.71 0.71l2.65 2.65l-2.65 2.65a0.5 0.5 0 0 0 0.71 0.71l2.65 -2.65l2.65 2.65a0.5 0.5 0 0 0 0.71 -0.71l-2.65 -2.65l2.65 -2.65a0.5 0.5 0 0 0 -0.71 -0.71l-2.65 2.65l-2.65 -2.65z",
37
- "M2 4a2 2 0 0 0 -2 2v6a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-6a2 2 0 0 0 -2 -2h-1.17a2 2 0 0 1 -1.41 -0.59l-0.83 -0.83a2 2 0 0 0 -1.41 -0.59h-2.34a2 2 0 0 0 -1.41 0.59l-0.83 0.83a2 2 0 0 1 -1.41 0.59h-1.17zM10.5 8.5a2.5 2.5 0 0 0 -5 0a2.5 2.5 0 1 0 5 0zM2.5 6a0.5 0.5 0 0 1 0 -1a0.5 0.5 0 1 1 0 1zM11.5 8.5a3.5 3.5 0 1 1 -7 0a3.5 3.5 0 0 1 7 0z",
37
+ "M2 4a2 2 0 0 0 -2 2v6a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-6a2 2 0 0 0 -2 -2h-1.17a2 2 0 0 1 -1.41 -0.59l-0.83 -0.83a2 2 0 0 0 -1.41 -0.59h-2.34a2 2 0 0 0 -1.41 0.59l-0.83 0.83a2 2 0 0 1 -1.41 0.59h-1.17zm8.5 4.5a2.5 2.5 0 0 0 -5 0a2.5 2.5 0 1 0 5 0zm-8 -2.5a0.5 0.5 0 0 1 0 -1a0.5 0.5 0 1 1 0 1zm9 2.5a3.5 3.5 0 1 1 -7 0a3.5 3.5 0 0 1 7 0z",
38
38
  "M2 0a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-12a2 2 0 0 0 -2 -2h-12zm7.5 11h-4a0.5 0.5 0 0 1 -0.5 -0.5v-4a0.5 0.5 0 0 1 1 0v2.79l4.15 -4.15a0.5 0.5 0 0 1 0.71 0.71l-4.15 4.15h2.79a0.5 0.5 0 0 1 0 1z",
39
- "M15.98 8.51c-0.38 6.15 -7.27 9.57 -12.4 6.17c-0.31 -0.21 -0.6 -0.43 -0.87 -0.67l5.5 -5.5h7.78zM2 13.3l5.5 -5.5v-7.77c-6.15 0.38 -9.57 7.27 -6.17 12.4c0.2 0.3 0.42 0.59 0.67 0.87zM8.5 0.03c4.02 0.25 7.23 3.46 7.49 7.49h-7.49v-7.49z",
40
- "M8.66 8.66v-4h-1.32v4h1.31zM8.66 11.34v-1.34h-1.32v1.34h1.31zM8 1.34q2.75 0 4.7 1.95t1.96 4.71t-1.95 4.7t-4.71 1.96t-4.7 -1.96t-1.96 -4.7t1.96 -4.7t4.7 -1.96z"
39
+ "M15.98 8.51c-0.38 6.15 -7.27 9.57 -12.4 6.17c-0.31 -0.21 -0.6 -0.43 -0.87 -0.67l5.5 -5.5h7.78zm-13.98 4.79l5.5 -5.5v-7.77c-6.15 0.38 -9.57 7.27 -6.17 12.4c0.2 0.3 0.42 0.59 0.67 0.87zm6.5 -13.27c4.02 0.25 7.23 3.46 7.49 7.49h-7.49v-7.49z",
40
+ "M8.66 8.66v-4h-1.32v4h1.31zm0 2.68v-1.34h-1.32v1.34h1.31zm-0.66 -10q2.75 0 4.7 1.95t1.96 4.71t-1.95 4.7t-4.71 1.96t-4.7 -1.96t-1.96 -4.7t1.96 -4.7t4.7 -1.96z"
41
41
  ],
42
42
  absolute: [
43
43
  "M16 8C16 4.13 12.42 1 8 1S0 4.13 0 8C0 9.76 0.74 11.37 1.97 12.6C1.87 13.62 1.55 14.73 1.2 15.57C1.12 15.75 1.27 15.96 1.47 15.93C3.73 15.56 5.07 14.99 5.65 14.69A9.06 9.06 0 0 0 8 15C12.42 15 16 11.87 16 8ZM7.19 6.77C7.28 6.89 7.36 7.03 7.42 7.17C7.85 8.11 7.81 9.54 6.48 10.87A0.45 0.45 0 0 1 5.87 10.88A0.41 0.41 0 0 1 5.86 10.29C6.27 9.88 6.53 9.46 6.67 9.07C6.4 9.24 6.08 9.33 5.74 9.33C4.78 9.33 4 8.59 4 7.67C4 6.75 4.78 6 5.73 6C6.01 6 6.26 6.06 6.49 6.17L6.5 6.17C6.67 6.24 6.82 6.35 6.97 6.49C7.05 6.58 7.13 6.67 7.19 6.77ZM11 9.07C10.73 9.24 10.41 9.33 10.07 9.33C9.11 9.33 8.34 8.59 8.34 7.67C8.34 6.75 9.11 6 10.07 6C10.34 6 10.6 6.06 10.82 6.17L10.83 6.17C11 6.24 11.16 6.35 11.3 6.49C11.39 6.58 11.46 6.67 11.53 6.76C11.61 6.89 11.69 7.02 11.75 7.16C12.18 8.11 12.15 9.54 10.81 10.87A0.45 0.45 0 0 1 10.2 10.88A0.41 0.41 0 0 1 10.19 10.29C10.61 9.87 10.86 9.46 11 9.07Z",
@@ -56,18 +56,18 @@ const shapes = {
56
56
  "M2 0C6 0 10 0 14 0C15.1 0 16 0.9 16 2C16 6 16 10 16 14C16 15.1 15.1 16 14 16C10 16 6 16 2 16C0.9 16 0 15.1 0 14C0 10 0 6 0 2C0 0.9 0.9 0 2 0C2 0 2 0 2 0M5.35 4.65C5.08 4.37 4.62 4.5 4.52 4.87C4.47 5.04 4.52 5.23 4.65 5.35C5.53 6.24 6.41 7.12 7.29 8C6.41 8.88 5.53 9.76 4.65 10.65C4.37 10.92 4.5 11.38 4.87 11.48C5.04 11.53 5.23 11.48 5.35 11.35C6.24 10.47 7.12 9.59 8 8.71C8.88 9.59 9.76 10.47 10.65 11.35C10.92 11.63 11.38 11.5 11.48 11.13C11.53 10.96 11.48 10.77 11.35 10.65C10.47 9.76 9.59 8.88 8.71 8C9.59 7.12 10.47 6.24 11.35 5.35C11.63 5.08 11.5 4.62 11.13 4.52C10.96 4.47 10.77 4.52 10.65 4.65C9.76 5.53 8.88 6.41 8 7.29C7.12 6.41 6.24 5.53 5.35 4.65C5.35 4.65 5.35 4.65 5.35 4.65",
57
57
  "M2 4C0.9 4 0 4.9 0 6C0 8 0 10 0 12C0 13.1 0.9 14 2 14C6 14 10 14 14 14C15.1 14 16 13.1 16 12C16 10 16 8 16 6C16 4.9 15.1 4 14 4C13.61 4 13.22 4 12.83 4C12.3 4 11.79 3.79 11.41 3.41C11.14 3.14 10.86 2.86 10.59 2.59C10.21 2.21 9.7 2 9.17 2C8.39 2 7.61 2 6.83 2C6.3 2 5.79 2.21 5.41 2.59C5.14 2.86 4.86 3.14 4.59 3.41C4.21 3.79 3.7 4 3.17 4C2.78 4 2.39 4 2 4C2 4 2 4 2 4M10.5 8.5C10.5 6.58 8.42 5.37 6.75 6.33C5.98 6.78 5.5 7.61 5.5 8.5C5.5 10.42 7.58 11.63 9.25 10.67C10.02 10.22 10.5 9.39 10.5 8.5C10.5 8.5 10.5 8.5 10.5 8.5M2.5 6C2.12 6 1.87 5.58 2.07 5.25C2.16 5.1 2.32 5 2.5 5C2.88 5 3.13 5.42 2.93 5.75C2.84 5.9 2.68 6 2.5 6C2.5 6 2.5 6 2.5 6M11.5 8.5C11.5 11.19 8.58 12.88 6.25 11.53C5.17 10.91 4.5 9.75 4.5 8.5C4.5 5.81 7.42 4.12 9.75 5.47C10.83 6.09 11.5 7.25 11.5 8.5C11.5 8.5 11.5 8.5 11.5 8.5",
58
58
  "M2 0C0.9 0 0 0.9 0 2C0 6 0 10 0 14C0 15.1 0.9 16 2 16C6 16 10 16 14 16C15.1 16 16 15.1 16 14C16 10 16 6 16 2C16 0.9 15.1 0 14 0C10 0 6 0 2 0C2 0 2 0 2 0M9.5 11C8.17 11 6.83 11 5.5 11C5.22 11 5 10.78 5 10.5C5 9.17 5 7.83 5 6.5C5 6.12 5.42 5.87 5.75 6.07C5.9 6.16 6 6.32 6 6.5C6 7.43 6 8.36 6 9.29C7.38 7.91 8.76 6.53 10.15 5.15C10.42 4.87 10.88 5 10.98 5.37C11.03 5.54 10.98 5.73 10.85 5.85C9.47 7.24 8.09 8.62 6.71 10C7.64 10 8.57 10 9.5 10C9.88 10 10.13 10.42 9.93 10.75C9.84 10.9 9.68 11 9.5 11C9.5 11 9.5 11 9.5 11",
59
- "M15.98 8.51C15.6 14.66 8.71 18.08 3.58 14.68C3.27 14.47 2.98 14.25 2.71 14.01C4.54 12.18 6.38 10.34 8.21 8.51C10.8 8.51 13.4 8.51 15.99 8.51C15.99 8.51 15.98 8.51 15.98 8.51M2 13.3C3.83 11.47 5.67 9.63 7.5 7.8C7.5 5.21 7.5 2.62 7.5 0.03C1.35 0.41 -2.07 7.3 1.33 12.43C1.53 12.73 1.75 13.02 2 13.3C2 13.3 2 13.3 2 13.3M8.5 0.03C12.52 0.28 15.73 3.49 15.99 7.52C13.49 7.52 11 7.52 8.5 7.52C8.5 5.02 8.5 2.53 8.5 0.03C8.5 0.03 8.5 0.03 8.5 0.03",
60
- "M8.66 8.66C8.66 7.33 8.66 5.99 8.66 4.66C8.22 4.66 7.78 4.66 7.34 4.66C7.34 5.99 7.34 7.33 7.34 8.66C7.78 8.66 8.21 8.66 8.65 8.66C8.65 8.66 8.66 8.66 8.66 8.66M8.66 11.34C8.66 10.89 8.66 10.45 8.66 10C8.22 10 7.78 10 7.34 10C7.34 10.45 7.34 10.89 7.34 11.34C7.78 11.34 8.21 11.34 8.65 11.34C8.65 11.34 8.66 11.34 8.66 11.34M8 1.34C9.83 1.34 11.4 1.99 12.7 3.29C14 4.59 14.65 6.16 14.66 8C14.67 9.84 14.02 11.41 12.71 12.7C11.4 13.99 9.83 14.65 8 14.66C6.17 14.67 4.6 14.02 3.3 12.7C2 11.38 1.35 9.81 1.34 8C1.33 6.19 1.99 4.62 3.3 3.3C4.61 1.98 6.18 1.33 8 1.34C8 1.34 8 1.34 8 1.34"
59
+ "M15.98 8.51C15.6 14.66 8.71 18.08 3.58 14.68C3.27 14.47 2.98 14.25 2.71 14.01C4.54 12.18 6.38 10.34 8.21 8.51C10.8 8.51 13.4 8.51 15.99 8.51C15.99 8.51 15.99 8.51 15.99 8.51M2 13.3C3.83 11.47 5.67 9.63 7.5 7.8C7.5 5.21 7.5 2.62 7.5 0.03C1.35 0.41 -2.07 7.3 1.33 12.43C1.53 12.73 1.75 13.02 2 13.3C2 13.3 2 13.3 2 13.3M8.5 0.03C12.52 0.28 15.73 3.49 15.99 7.52C13.49 7.52 11 7.52 8.5 7.52C8.5 5.02 8.5 2.53 8.5 0.03C8.5 0.03 8.5 0.03 8.5 0.03",
60
+ "M8.66 8.66C8.66 7.33 8.66 5.99 8.66 4.66C8.22 4.66 7.78 4.66 7.34 4.66C7.34 5.99 7.34 7.33 7.34 8.66C7.78 8.66 8.21 8.66 8.65 8.66C8.65 8.66 8.65 8.66 8.65 8.66M8.66 11.34C8.66 10.89 8.66 10.45 8.66 10C8.22 10 7.78 10 7.34 10C7.34 10.45 7.34 10.89 7.34 11.34C7.78 11.34 8.21 11.34 8.65 11.34C8.65 11.34 8.65 11.34 8.65 11.34M8 1.34C9.83 1.34 11.4 1.99 12.7 3.29C14 4.59 14.65 6.16 14.66 8C14.67 9.84 14.02 11.41 12.71 12.7C11.4 13.99 9.83 14.65 8 14.66C6.17 14.67 4.6 14.02 3.3 12.7C2 11.38 1.35 9.81 1.34 8C1.33 6.19 1.99 4.62 3.3 3.3C4.61 1.98 6.18 1.33 8 1.34C8 1.34 8 1.34 8 1.34"
61
61
  ],
62
62
  scaled: [
63
- "M15.2 8.05C15.2 4.57 11.98 1.75 8 1.75S0.8 4.57 0.8 8.05C0.8 9.63 1.47 11.08 2.57 12.19C2.49 13.1 2.2 14.1 1.88 14.86C1.81 15.02 1.94 15.21 2.12 15.18C4.15 14.85 5.36 14.34 5.89 14.07C6.58 14.26 7.29 14.35 8 14.35C11.98 14.35 15.2 11.53 15.2 8.05ZM7.27 6.94C7.35 7.05 7.42 7.17 7.48 7.3C7.86 8.15 7.83 9.44 6.63 10.63C6.48 10.78 6.24 10.78 6.08 10.64C5.93 10.5 5.92 10.26 6.07 10.11C6.45 9.73 6.68 9.36 6.8 9.01C6.56 9.16 6.27 9.25 5.96 9.25C5.1 9.25 4.4 8.57 4.4 7.75C4.4 6.92 5.1 6.25 5.96 6.25C6.2 6.25 6.44 6.3 6.64 6.4L6.65 6.4C6.8 6.46 6.94 6.56 7.07 6.69C7.15 6.76 7.21 6.85 7.27 6.94ZM10.7 9.01C10.46 9.16 10.17 9.25 9.86 9.25C9 9.25 8.3 8.57 8.3 7.75C8.3 6.92 9 6.25 9.86 6.25C10.11 6.25 10.34 6.3 10.54 6.4L10.55 6.4C10.7 6.46 10.84 6.56 10.97 6.69C11.05 6.76 11.11 6.85 11.17 6.93C11.25 7.04 11.32 7.17 11.38 7.29C11.76 8.15 11.73 9.43 10.53 10.63C10.38 10.78 10.14 10.78 9.98 10.64C9.83 10.5 9.82 10.25 9.97 10.11C10.35 9.73 10.57 9.36 10.7 9.01Z",
64
- "M15.2 13.4V5.3H0.8V13.4C0.8 14.39 1.61 15.2 2.6 15.2H13.4C14.39 15.2 15.2 14.39 15.2 13.4ZM3.1 11.9H2.47L4.17 7.1H4.8L6.51 11.9H5.86L5.38 10.46H3.59L3.1 11.9ZM4.49 7.82H4.48L3.76 9.96H5.21L4.49 7.82ZM9.66 8.2V11.9H9.06V11.41H9.04C8.91 11.71 8.56 11.96 7.97 11.96C7.21 11.96 6.66 11.52 6.66 10.68V8.2H7.27V10.5C7.27 11.19 7.67 11.41 8.15 11.41C8.68 11.41 9.06 11.08 9.06 10.49V8.2H9.67ZM10.81 12.17C10.88 12.47 11.19 12.75 11.7 12.75C12.28 12.75 12.66 12.41 12.66 11.83V11.28H12.64C12.5 11.6 12.09 11.86 11.59 11.86C10.73 11.86 10.11 11.26 10.11 10.15V9.85C10.11 8.76 10.72 8.15 11.59 8.15C12.09 8.15 12.49 8.41 12.66 8.72H12.68V8.2H13.27V11.83C13.27 12.78 12.53 13.25 11.69 13.25C10.75 13.25 10.28 12.79 10.19 12.17H10.81ZM12.66 9.89C12.66 9.14 12.29 8.67 11.7 8.67C11.08 8.67 10.72 9.11 10.72 9.89V10.12C10.72 10.89 11.08 11.35 11.7 11.35C12.31 11.35 12.66 10.88 12.66 10.12V9.89ZM4.4 1.25C4.4 0.9 4.03 0.69 3.72 0.86C3.59 0.94 3.5 1.09 3.5 1.25V1.7H2.6C1.61 1.7 0.8 2.51 0.8 3.5V4.4H15.2V3.5C15.2 2.51 14.39 1.7 13.4 1.7H12.5V1.25C12.5 0.9 12.13 0.69 11.83 0.86C11.69 0.94 11.6 1.09 11.6 1.25V1.7H4.4V1.25Z",
65
- "M5.75 1.25C5.75 1 5.95 0.8 6.2 0.8H9.8C10.15 0.8 10.36 1.18 10.19 1.48C10.11 1.61 9.96 1.7 9.8 1.7H8.9V2.66C13.7 3.36 15.95 8.99 12.95 12.8C12.69 13.13 12.4 13.43 12.08 13.7L12.82 14.43C13.06 14.68 12.95 15.1 12.62 15.19C12.46 15.23 12.3 15.18 12.18 15.07L11.35 14.24C10.35 14.87 9.19 15.2 8 15.2C6.81 15.2 5.65 14.87 4.65 14.24L3.82 15.07C3.57 15.31 3.15 15.2 3.06 14.87C3.02 14.71 3.07 14.55 3.18 14.43L3.92 13.7C0.22 10.55 1.32 4.59 5.89 2.96C6.28 2.82 6.69 2.72 7.1 2.66V1.7H6.2C5.95 1.7 5.75 1.5 5.75 1.25ZM1.57 5.65C0.27 4.51 0.68 2.39 2.32 1.82C3.19 1.52 4.15 1.78 4.75 2.47C3.38 3.17 2.27 4.28 1.57 5.65ZM12.95 1.7C12.27 1.7 11.66 2 11.25 2.47C12.62 3.17 13.73 4.28 14.43 5.65C15.73 4.51 15.32 2.39 13.68 1.82C13.45 1.74 13.2 1.7 12.95 1.7ZM8.45 5.3C8.45 4.95 8.08 4.74 7.78 4.91C7.64 4.99 7.55 5.14 7.55 5.3V8.79L6.25 11.4C6.09 11.71 6.33 12.07 6.67 12.05C6.83 12.04 6.98 11.95 7.05 11.8L8.4 9.1C8.43 9.04 8.45 8.97 8.45 8.9V5.3Z",
66
- "M2.6 0.8H13.4C14.39 0.8 15.2 1.61 15.2 2.6V13.4C15.2 14.39 14.39 15.2 13.4 15.2H2.6C1.61 15.2 0.8 14.39 0.8 13.4V2.6C0.8 1.61 1.61 0.8 2.6 0.8ZM5.62 4.98C5.37 4.74 4.95 4.85 4.86 5.18C4.82 5.34 4.87 5.5 4.98 5.62L7.36 8L4.98 10.38C4.74 10.63 4.85 11.05 5.18 11.14C5.34 11.18 5.5 11.13 5.62 11.02L8 8.64L10.38 11.02C10.63 11.26 11.05 11.15 11.14 10.82C11.18 10.66 11.13 10.5 11.02 10.38L8.64 8L11.02 5.62C11.26 5.37 11.15 4.95 10.82 4.86C10.66 4.82 10.5 4.87 10.38 4.98L8 7.36L5.62 4.98Z",
67
- "M2.6 4.4C1.61 4.4 0.8 5.21 0.8 6.2V11.6C0.8 12.59 1.61 13.4 2.6 13.4H13.4C14.39 13.4 15.2 12.59 15.2 11.6V6.2C15.2 5.21 14.39 4.4 13.4 4.4H12.35C11.87 4.4 11.41 4.21 11.07 3.87L10.33 3.13C9.99 2.79 9.53 2.6 9.05 2.6H6.95C6.47 2.6 6.01 2.79 5.67 3.13L4.93 3.87C4.59 4.21 4.13 4.4 3.65 4.4H2.6ZM10.25 8.45C10.25 6.72 8.38 5.64 6.88 6.5C6.18 6.9 5.75 7.65 5.75 8.45C5.75 10.18 7.63 11.26 9.13 10.4C9.82 10 10.25 9.25 10.25 8.45ZM3.05 6.2C2.7 6.2 2.49 5.82 2.66 5.53C2.74 5.39 2.89 5.3 3.05 5.3C3.4 5.3 3.61 5.68 3.44 5.98C3.36 6.11 3.21 6.2 3.05 6.2ZM11.15 8.45C11.15 10.87 8.53 12.39 6.43 11.18C5.45 10.62 4.85 9.58 4.85 8.45C4.85 6.03 7.48 4.51 9.57 5.72C10.55 6.28 11.15 7.32 11.15 8.45Z",
68
- "M2.6 0.8C1.61 0.8 0.8 1.61 0.8 2.6V13.4C0.8 14.39 1.61 15.2 2.6 15.2H13.4C14.39 15.2 15.2 14.39 15.2 13.4V2.6C15.2 1.61 14.39 0.8 13.4 0.8H2.6ZM9.35 10.7H5.75C5.5 10.7 5.3 10.5 5.3 10.25V6.65C5.3 6.3 5.68 6.09 5.98 6.26C6.11 6.34 6.2 6.49 6.2 6.65V9.16L9.93 5.43C10.18 5.19 10.6 5.3 10.69 5.63C10.73 5.79 10.68 5.95 10.57 6.07L6.84 9.8H9.35C9.7 9.8 9.91 10.18 9.74 10.48C9.66 10.61 9.51 10.7 9.35 10.7Z",
69
- "M15.18 8.46C14.84 14 8.64 17.07 4.02 14.01C3.74 13.83 3.48 13.63 3.24 13.41L8.19 8.46H15.19ZM2.6 12.77L7.55 7.82V0.83C2.01 1.17 -1.06 7.37 2 11.99C2.18 12.26 2.37 12.52 2.6 12.77ZM8.45 0.83C12.07 1.05 14.96 3.94 15.19 7.57H8.45V0.83Z",
70
- "M8.59 8.59V4.99H7.41V8.59H8.59ZM8.59 11.01V9.8H7.41V11.01H8.59ZM8 2.01Q10.48 2.01 12.23 3.76T13.99 8T12.24 12.23T8 13.99T3.77 12.23T2.01 8T3.77 3.77T8 2.01Z"
63
+ "M14.4 7.2C14.4 3.72 11.18 0.9 7.2 0.9S0 3.72 0 7.2C0 8.78 0.67 10.23 1.77 11.34C1.69 12.25 1.4 13.26 1.08 14.01C1.01 14.18 1.14 14.36 1.32 14.34C3.35 14 4.56 13.49 5.09 13.22C5.78 13.41 6.49 13.5 7.2 13.5C11.18 13.5 14.4 10.68 14.4 7.2ZM6.47 6.09C6.55 6.2 6.62 6.32 6.68 6.45C7.06 7.3 7.03 8.59 5.83 9.78C5.68 9.93 5.44 9.94 5.28 9.79C5.13 9.65 5.12 9.41 5.27 9.26C5.65 8.89 5.88 8.52 6 8.16C5.76 8.31 5.47 8.4 5.16 8.4C4.3 8.4 3.6 7.73 3.6 6.9C3.6 6.07 4.3 5.4 5.16 5.4C5.4 5.4 5.64 5.45 5.84 5.55L5.85 5.55C6 5.62 6.14 5.72 6.27 5.84C6.35 5.92 6.41 6 6.47 6.09ZM9.9 8.17C9.66 8.31 9.37 8.4 9.06 8.4C8.2 8.4 7.5 7.73 7.5 6.9C7.5 6.07 8.2 5.4 9.06 5.4C9.31 5.4 9.54 5.45 9.74 5.55L9.75 5.55C9.9 5.62 10.04 5.72 10.17 5.84C10.25 5.92 10.31 6 10.37 6.09C10.45 6.2 10.52 6.32 10.58 6.45C10.96 7.3 10.93 8.59 9.73 9.78C9.58 9.93 9.34 9.93 9.18 9.79C9.03 9.65 9.02 9.41 9.17 9.26C9.55 8.89 9.77 8.51 9.9 8.16Z",
64
+ "M14.4 12.6V4.5H0V12.6C0 13.59 0.81 14.4 1.8 14.4H12.6C13.59 14.4 14.4 13.59 14.4 12.6ZM2.3 11.1H1.67L3.37 6.3H4L5.71 11.1H5.06L4.58 9.66H2.79L2.3 11.1ZM3.69 7.02H3.68L2.96 9.16H4.41L3.69 7.02ZM8.87 7.4V11.1H8.26V10.61H8.24C8.11 10.91 7.76 11.16 7.17 11.16C6.41 11.16 5.86 10.72 5.86 9.88V7.4H6.47V9.7C6.47 10.39 6.87 10.61 7.35 10.61C7.88 10.61 8.26 10.28 8.26 9.69V7.4H8.87ZM10.01 11.37C10.08 11.67 10.39 11.95 10.9 11.95C11.48 11.95 11.86 11.61 11.86 11.03V10.48H11.84C11.7 10.8 11.29 11.06 10.79 11.06C9.93 11.06 9.31 10.46 9.31 9.35V9.05C9.31 7.96 9.92 7.35 10.79 7.35C11.29 7.35 11.69 7.61 11.86 7.92H11.88V7.4H12.47V11.03C12.47 11.98 11.73 12.45 10.89 12.45C9.95 12.45 9.48 11.99 9.39 11.37H10.01ZM11.86 9.09C11.86 8.34 11.49 7.87 10.9 7.87C10.28 7.87 9.92 8.31 9.92 9.09V9.32C9.92 10.09 10.28 10.55 10.9 10.55C11.51 10.55 11.86 10.08 11.86 9.32V9.09ZM3.6 0.45C3.6 0.1 3.23 -0.11 2.93 0.06C2.79 0.14 2.7 0.29 2.7 0.45V0.9H1.8C0.81 0.9 0 1.71 0 2.7V3.6H14.4V2.7C14.4 1.71 13.59 0.9 12.6 0.9H11.7V0.45C11.7 0.1 11.33 -0.11 11.03 0.06C10.89 0.14 10.8 0.29 10.8 0.45V0.9H3.6V0.45Z",
65
+ "M4.95 0.45C4.95 0.2 5.15 0 5.4 0H9C9.35 0 9.56 0.37 9.39 0.68C9.31 0.81 9.16 0.9 9 0.9H8.1V1.86C12.9 2.56 15.15 8.19 12.15 12C11.89 12.33 11.6 12.63 11.28 12.9L12.02 13.63C12.26 13.88 12.15 14.3 11.82 14.39C11.66 14.43 11.5 14.38 11.38 14.27L10.55 13.44C9.55 14.07 8.39 14.4 7.2 14.4C6.01 14.4 4.85 14.07 3.85 13.44L3.02 14.27C2.77 14.51 2.35 14.4 2.26 14.07C2.22 13.91 2.27 13.75 2.38 13.63L3.12 12.9C-0.58 9.75 0.52 3.79 5.09 2.16C5.48 2.02 5.89 1.92 6.3 1.86V0.9H5.4C5.15 0.9 4.95 0.7 4.95 0.45ZM0.77 4.85C-0.53 3.71 -0.12 1.59 1.52 1.02C2.39 0.72 3.35 0.98 3.95 1.67C2.58 2.37 1.47 3.48 0.77 4.85ZM12.15 0.9C11.47 0.9 10.86 1.2 10.45 1.67C11.82 2.37 12.93 3.48 13.63 4.85C14.93 3.71 14.52 1.59 12.88 1.02C12.65 0.94 12.4 0.9 12.15 0.9ZM7.65 4.5C7.65 4.15 7.28 3.94 6.98 4.11C6.84 4.19 6.75 4.34 6.75 4.5V7.99L5.45 10.6C5.29 10.91 5.53 11.27 5.87 11.25C6.03 11.24 6.18 11.15 6.25 11L7.6 8.3C7.63 8.24 7.65 8.17 7.65 8.1V4.5Z",
66
+ "M1.8 0H12.6C13.59 0 14.4 0.81 14.4 1.8V12.6C14.4 13.59 13.59 14.4 12.6 14.4H1.8C0.81 14.4 0 13.59 0 12.6V1.8C0 0.81 0.81 0 1.8 0ZM4.82 4.18C4.57 3.94 4.15 4.05 4.06 4.38C4.02 4.54 4.07 4.7 4.18 4.82L6.56 7.2L4.18 9.58C3.94 9.83 4.05 10.25 4.38 10.34C4.54 10.38 4.7 10.33 4.82 10.22L7.2 7.84L9.58 10.22C9.83 10.46 10.25 10.35 10.34 10.02C10.38 9.86 10.33 9.7 10.22 9.58L7.84 7.2L10.22 4.82C10.46 4.57 10.35 4.15 10.02 4.06C9.86 4.02 9.7 4.07 9.58 4.18L7.2 6.56L4.82 4.18Z",
67
+ "M1.8 3.6C0.81 3.6 0 4.41 0 5.4V10.8C0 11.79 0.81 12.6 1.8 12.6H12.6C13.59 12.6 14.4 11.79 14.4 10.8V5.4C14.4 4.41 13.59 3.6 12.6 3.6H11.55C11.07 3.6 10.61 3.41 10.27 3.07L9.53 2.33C9.19 1.99 8.73 1.8 8.25 1.8H6.15C5.67 1.8 5.21 1.99 4.87 2.33L4.13 3.07C3.79 3.41 3.33 3.6 2.85 3.6H1.8ZM9.45 7.65C9.45 5.92 7.57 4.84 6.08 5.7C5.38 6.1 4.95 6.85 4.95 7.65C4.95 9.38 6.83 10.46 8.33 9.6C9.02 9.2 9.45 8.45 9.45 7.65ZM2.25 5.4C1.9 5.4 1.69 5.02 1.86 4.73C1.94 4.59 2.09 4.5 2.25 4.5C2.6 4.5 2.81 4.88 2.64 5.18C2.56 5.31 2.41 5.4 2.25 5.4ZM10.35 7.65C10.35 10.07 7.73 11.59 5.63 10.38C4.65 9.82 4.05 8.78 4.05 7.65C4.05 5.23 6.68 3.71 8.78 4.92C9.75 5.48 10.35 6.52 10.35 7.65Z",
68
+ "M1.8 0C0.81 0 0 0.81 0 1.8V12.6C0 13.59 0.81 14.4 1.8 14.4H12.6C13.59 14.4 14.4 13.59 14.4 12.6V1.8C14.4 0.81 13.59 0 12.6 0H1.8ZM8.55 9.9H4.95C4.7 9.9 4.5 9.7 4.5 9.45V5.85C4.5 5.5 4.88 5.29 5.18 5.46C5.31 5.54 5.4 5.69 5.4 5.85V8.36L9.13 4.63C9.38 4.39 9.8 4.5 9.89 4.83C9.93 4.99 9.88 5.15 9.77 5.27L6.04 9H8.55C8.9 9 9.11 9.38 8.94 9.68C8.86 9.81 8.71 9.9 8.55 9.9Z",
69
+ "M14.38 7.66C14.04 13.19 7.84 16.27 3.22 13.21C2.94 13.02 2.68 12.83 2.44 12.61L7.39 7.66H14.39ZM1.8 11.97L6.75 7.02V0.03C1.22 0.37 -1.86 6.57 1.2 11.19C1.38 11.46 1.58 11.72 1.8 11.97ZM7.65 0.03C11.27 0.25 14.16 3.14 14.39 6.77H7.65V0.03Z",
70
+ "M7.79 7.79V4.19H6.61V7.79H7.79ZM7.79 10.21V9H6.61V10.21H7.79ZM7.2 1.21Q9.68 1.21 11.43 2.96T13.19 7.2T11.44 11.43T7.2 13.19T2.97 11.43T1.21 7.2T2.97 2.97T7.2 1.21Z"
71
71
  ],
72
72
  translated: [
73
73
  "M17 9C17 5.13 13.42 2 9 2S1 5.13 1 9C1 10.76 1.74 12.37 2.97 13.6C2.87 14.62 2.55 15.73 2.2 16.57C2.12 16.75 2.27 16.96 2.47 16.93C4.73 16.56 6.07 15.99 6.65 15.69C7.42 15.9 8.21 16 9 16C13.42 16 17 12.87 17 9ZM8.19 7.77C8.28 7.89 8.36 8.03 8.42 8.17C8.85 9.11 8.81 10.54 7.48 11.87C7.31 12.04 7.04 12.04 6.87 11.88C6.7 11.72 6.69 11.46 6.86 11.29C7.27 10.88 7.53 10.46 7.67 10.07C7.4 10.24 7.08 10.33 6.74 10.33C5.78 10.33 5 9.59 5 8.67C5 7.75 5.78 7 6.73 7C7.01 7 7.26 7.06 7.49 7.17L7.5 7.17C7.67 7.24 7.82 7.35 7.97 7.49C8.05 7.58 8.13 7.67 8.19 7.77ZM12 10.07C11.73 10.24 11.41 10.33 11.07 10.33C10.11 10.33 9.34 9.59 9.34 8.67C9.34 7.75 10.11 7 11.07 7C11.34 7 11.6 7.06 11.82 7.17L11.83 7.17C12 7.24 12.16 7.35 12.3 7.49C12.39 7.58 12.46 7.67 12.53 7.76C12.61 7.89 12.69 8.02 12.75 8.16C13.18 9.11 13.15 10.54 11.81 11.87C11.64 12.03 11.37 12.04 11.2 11.88C11.03 11.72 11.02 11.45 11.19 11.29C11.61 10.87 11.86 10.46 12 10.07Z",
@@ -80,24 +80,24 @@ const shapes = {
80
80
  "M9.66 9.66V5.66H8.34V9.66H9.65ZM9.66 12.34V11H8.34V12.34H9.65ZM9 2.34Q11.75 2.34 13.7 4.29T15.66 9T13.71 13.7T9 15.66T4.3 13.7T2.34 9T4.3 4.3T9 2.34Z"
81
81
  ],
82
82
  length: [
83
- 81.67065384079928,
84
- 170.2789195370525,
85
- 103.70428978485825,
86
- 96.79917983123107,
87
- 90.71949502282325,
88
- 91.3801783563817,
89
- 93.39237679379238,
90
- 57.849175958330065
83
+ 81.67071892681327,
84
+ 170.27898053351782,
85
+ 103.70446684221288,
86
+ 96.79922293172581,
87
+ 90.7196977830866,
88
+ 91.38021514948004,
89
+ 93.39245633427387,
90
+ 57.84918795039813,
91
91
  ],
92
92
  pointAt50: [
93
- { x: 15.93524072243249, y: 8.894528250283352},
94
- { x: 14.832297521743689, y: 15.8185922802482},
95
- { x: 1.8809045863993987, y: 5.602489286814455 },
96
- { x: 0, y: 9.424767194704785},
97
- { x: 10.497039071194694, y: 8.379025379074518},
98
- { x: 12.566356259606373, y: 0},
99
- { x: 6.486195189102064, y: 0.15495458998798228},
100
- { x: 1.8348582863102771, y: 5.4415127662134}
93
+ { x: 15.938953304842967, y: 8.868891726272725 },
94
+ { x: 14.832293673094282, y: 15.818594853651366 },
95
+ { x: 1.8808184432764348, y: 5.602539862243249 },
96
+ { x: 0, y: 9.424777960769376 },
97
+ { x: 10.497072046759587, y: 8.379040530375336 },
98
+ { x: 12.566370614359172, y: 0},
99
+ { x: 6.406410409169571, y: 0.17024392855151 },
100
+ { x: 1.8274263290642496, y: 5.4591901510102145 }
101
101
  ]
102
102
  }
103
103
 
@@ -0,0 +1,75 @@
1
+ const simpleShapes = {
2
+ initial: [
3
+ 'M10 10l80 80V10H50', // line
4
+ 'M10 90C30 90 25 10 50 10s20 80 40 80s15 -80 40 -80s20 80 40 80', // cubic
5
+ 'M10 50q15 -25 30 0t30 0t30 0t30 0t30 0t30 0', // quad
6
+ 'M6 10a6 4 10 1 0 8 0m-8 0a6 4 10 1 1 8 0m-8 0a6 4 10 0 1 8 0m-8 0a6 4 10 0 0 8 0' // arc
7
+ ],
8
+ // {translate: 15, rotate: 15, scale: 0.5}
9
+ normalized: [
10
+ "M10 10L90 90L90 10L50 10",
11
+ "M10 90C30 90 25 10 50 10C75 10 70 90 90 90C110 90 105 10 130 10C155 10 150 90 170 90",
12
+ "M10 50Q25 25 40 50Q55 75 70 50Q85 25 100 50Q115 75 130 50Q145 25 160 50Q175 75 190 50",
13
+ "M6 10A6 4 10 1 0 14 10M6 10A6 4 10 1 1 14 10M6 10A6 4 10 0 1 14 10M6 10A6 4 10 0 0 14 10"
14
+ ],
15
+ transformed: [
16
+ "M18.54 6.12L46.82 55.11L57.17 16.48L37.85 11.3",
17
+ "M8.18 44.76C17.84 47.35 25.78 8.06 37.85 11.3S37.16 52.53 46.82 55.11S64.42 18.42 76.49 21.65S75.8 62.88 85.46 65.47",
18
+ "M13.36 25.44Q23.84 15.31 27.85 29.32T42.34 33.21T56.83 37.09T71.31 40.97T85.8 44.85T100.29 48.74",
19
+ "M16.6 5.61C14.93 6.26 15.42 8.37 17.49 9.41C19.55 10.44 21.64 9.62 21.25 7.93C21.14 7.49 20.87 7.04 20.47 6.64M16.6 5.61C15.06 4.09 15.78 2.3 17.9 2.39C20.02 2.48 21.95 4.37 21.37 5.8C21.22 6.18 20.91 6.47 20.47 6.64M16.6 5.61C17.74 5.16 19.42 5.61 20.47 6.64M16.6 5.61C17.65 6.63 19.33 7.09 20.47 6.64"
20
+ ],
21
+ // {scale: [0.55,0.6,0.65]}
22
+ scaled3d: [
23
+ "M5.5 6L49.5 54V6H27.5",
24
+ "M5.5 54C16.5 54 13.75 6 27.5 6S38.5 54 49.5 54S57.75 6 71.5 6S82.5 54 93.5 54",
25
+ "M5.5 30Q13.75 15 22 30T38.5 30T55 30T71.5 30T88 30T104.5 30",
26
+ "M3.3 6C1.71 7.28 2.83 9.57 5.32 10.13C7.81 10.69 9.79 9.09 8.9 7.25C8.66 6.77 8.24 6.34 7.7 6M3.3 6C1.23 4.72 1.48 2.43 3.76 1.87C6.04 1.31 8.63 2.91 8.42 4.75C8.37 5.23 8.12 5.66 7.7 6M3.3 6C4.38 5.13 6.29 5.13 7.7 6M3.3 6C4.71 6.87 6.62 6.87 7.7 6"
27
+ ],
28
+ // {skew: 45}
29
+ // {skew: [45,0]}
30
+ skewedX: [
31
+ "M20 10L180 90L100 10H60",
32
+ "M100 90C120 90 35 10 60 10S160 90 180 90S115 10 140 10S240 90 260 90",
33
+ "M60 50Q50 25 90 50T120 50T150 50T180 50T210 50T240 50",
34
+ "M16 10C15.24 12.13 21.11 15.95 26.56 16.88C32.01 17.81 32.96 15.15 28.26 12.09C27.03 11.29 25.55 10.56 24 10M16 10C10.1 7.87 6.74 4.05 9.96 3.12C13.17 2.19 20.54 4.85 23.22 7.91C23.93 8.71 24.2 9.44 24 10M16 10C16.52 8.56 20 8.56 24 10M16 10C20 11.44 23.48 11.44 24 10"
35
+ ],
36
+ // {skew: [0,45]}
37
+ skewedY: [
38
+ "M10 20L90 180V100L50 60",
39
+ "M10 100C30 120 25 35 50 60S70 160 90 180S105 115 130 140S150 240 170 260",
40
+ "M10 60Q25 50 40 90T70 120T100 150T130 180T160 210T190 240",
41
+ "M6 16C3.11 15.24 5.15 21.11 9.67 26.56C14.2 32.01 17.81 32.96 16.17 28.26C15.75 27.03 14.99 25.55 14 24M6 16C2.23 10.1 2.7 6.74 6.84 9.96C10.98 13.17 15.69 20.54 15.31 23.22C15.22 23.93 14.76 24.2 14 24M6 16C7.96 16.52 11.44 20 14 24M6 16C8.56 20 12.04 23.48 14 24"
42
+ ],
43
+ reversed: [
44
+ "M50 10H90V90L10 10",
45
+ "M170 90C150 90 155 10 130 10S110 90 90 90S75 10 50 10S30 90 10 90",
46
+ "M190 50Q175 75 160 50T130 50T100 50T70 50T40 50T10 50",
47
+ "M14 10A6 4 10 1 1 6 10M14 10A6 4 10 1 0 6 10M14 10A6 4 10 0 0 6 10M14 10A6 4 10 0 1 6 10"
48
+ ],
49
+ length: [
50
+ 233.1370849898476,
51
+ 379.0289739091177,
52
+ 244.25352263349316,
53
+ 63.11262433473098,
54
+ ],
55
+ pointAt0: [
56
+ { "x": 10, "y": 10 },
57
+ { "x": 10, "y": 90 },
58
+ { "x": 10, "y": 50 },
59
+ { "x": 6, "y": 10 }
60
+ ],
61
+ pointAt400: [
62
+ { x: 50, y: 10 },
63
+ { x: 170, y: 90 },
64
+ { x: 190, y: 50 },
65
+ { x: 14, y: 10 }
66
+ ],
67
+ pointAt50: [
68
+ { x: 45.35533905932737, y: 45.35533905932737 },
69
+ { x: 28.85808806500117, y: 46.6836898667648 },
70
+ { x: 46.84696090751847, y: 58.807108530914896 },
71
+ { x: 7.697454886004856, y: 9.193767828563768 }
72
+ ]
73
+ };
74
+
75
+ export default simpleShapes;
@@ -0,0 +1,324 @@
1
+ import { expect, it, describe, beforeEach, vi } from 'vitest';
2
+ import SVGPathCommander, { type CurveArray, type ShapeTypes } from '~/index';
3
+ import invalidPathValue from '../src/parser/invalidPathValue';
4
+ import error from '../src/parser/error';
5
+
6
+ import getMarkup from './fixtures/getMarkup';
7
+ import simpleShapes from './fixtures/simpleShapes';
8
+ import shapes from './fixtures/shapes';
9
+ import shapeObjects from './fixtures/shapeObjects';
10
+
11
+ import "../docs/assets/style.css";
12
+
13
+ describe('SVGPathCommander Static Methods', () => {
14
+ const wrapper = document.createElement('div');
15
+ document.body.append(wrapper);
16
+
17
+ beforeEach(async () => {
18
+ wrapper.innerHTML = '';
19
+ });
20
+
21
+ it('Convert shape to path with incomplete values should return false', () => {
22
+ ['line', 'circle', 'ellipse', 'rect', 'polygon', 'polyline', 'glyph'].forEach((SHAPE) => {
23
+ // @ts-expect-error
24
+ expect(SVGPathCommander.shapeToPath({ type: SHAPE, fill: 'red' }), `${SHAPE} with no specific attributes`).to.be.false;
25
+ })
26
+ });
27
+
28
+ it('Convert shape to pathArray with incomplete values should return false', () => {
29
+ ['line', 'circle', 'ellipse', 'rect', 'polygon', 'polyline', 'glyph'].forEach((SHAPE) => {
30
+ // @ts-expect-error
31
+ expect(SVGPathCommander.shapeToPathArray({ type: SHAPE, fill: 'red' }), `${SHAPE} with no specific attributes`).to.be.false;
32
+ })
33
+ });
34
+
35
+ ['wombat', 'line', 'circle', 'ellipse', 'rect', 'polygon', 'polyline', 'glyph', 'path'].forEach((SHAPE) => {
36
+ it(`Convert <${SHAPE}> to path`, async () => {
37
+ wrapper.append(getMarkup());
38
+ await vi.waitFor(() => wrapper.querySelector('svg') as SVGElement, { timeout: 200 });
39
+ const svg = await vi.waitFor(() => wrapper.querySelector('svg') as SVGElement, { timeout: 200 });
40
+ svg.setAttribute('viewBox', '0 0 182 72');
41
+ svg.innerHTML = `<line id="line" x1="0" y1="0" x2="182" y2="72" stroke="turquoise" stroke-width="2" />
42
+ <circle id="circle" cx="27.5" cy="36.9" r="23.5" fill="orangered"/>
43
+ <ellipse id="ellipse" cx="68.3" cy="37" rx="15.1" fill="darkorange"/>
44
+ <wombat id="wombat" fill="black"/>
45
+ <polygon id="polygon" points="107.4,13 113.7,28.8 127.9,31.3 117.6,43.5 120.1,60.8 107.4,52.6 94.6,60.8 97.1,43.5 86.8,31.3 101,28.8" fill="yellow"/>
46
+ <polyline id="polyline" points="107.39,17.78 112.43,30.42 123.79,32.42 115.55,42.18 117.55,56.02 107.39,49.46 97.15,56.02 99.15,42.18 90.91,32.42 102.27,30.42" fill="none" stroke="black" stroke-width="2"/>
47
+ <rect id="rect" x="131" y="13.2" width="47.5" height="47.6" rx="25" fill="yellowgreen"/>
48
+ <path id="path" d="M143.5 22.72H166s3 0 3 3v22.56s0 3 -3 3h-22.5s-3 0 -3 -3V25.72s0 -3 3 -3" fill="rgba(255,255,255,0.3)"/>
49
+ <glyph id="glyph" d="M143.5 22.72H166s3 0 3 3v22.56s0 3 -3 3h-22.5s-3 0 -3 -3V25.72s0 -3 3 -3" fill="rgba(255,255,255,0.3)"/>`;
50
+
51
+ const shape = await vi.waitFor(() => wrapper.querySelector(SHAPE) as SVGElement, { timeout: 200 });
52
+ if (SHAPE === 'wombat') {
53
+ try {
54
+ SVGPathCommander.shapeToPathArray(shape as unknown as SVGCircleElement, shape.ownerDocument);
55
+ } catch (er) {
56
+ expect(er).to.be.instanceOf(TypeError);
57
+ expect(er).to.have.property('message', `${error}: "${SHAPE}" is not SVGElement`);
58
+ }
59
+ try {
60
+ SVGPathCommander.shapeToPath(shape as unknown as SVGCircleElement, true, shape.ownerDocument);
61
+ } catch (er) {
62
+ expect(er).to.be.instanceOf(TypeError);
63
+ expect(er).to.have.property('message', `${error}: "${SHAPE}" is not SVGElement`);
64
+ }
65
+ } else if (SHAPE === 'path') {
66
+ try {
67
+ SVGPathCommander.shapeToPath(shape as unknown as SVGCircleElement, true, shape.ownerDocument);
68
+ } catch (er) {
69
+ expect(er).to.be.instanceOf(TypeError);
70
+ expect(er).to.have.property('message', `${error}: "${SHAPE}" is already SVGPathElement`);
71
+ }
72
+ } else {
73
+ SVGPathCommander.shapeToPath(shape as unknown as ShapeTypes, true, shape.ownerDocument);
74
+ expect(svg.querySelector(SHAPE)).to.not.exist;
75
+ expect(svg.querySelector(`#${SHAPE}`)).to.exist;
76
+ expect(svg.querySelector(`#${SHAPE}`)?.getAttribute('d')).to.have.length.greaterThan(0);
77
+ }
78
+ });
79
+ });
80
+
81
+ shapeObjects.forEach((SHAPE) => {
82
+ it(`Convert "${SHAPE.type}" Object to pathArray`, () => {
83
+ expect(SVGPathCommander.shapeToPathArray(SHAPE as unknown as ShapeTypes)).to.have.length.greaterThan(0);
84
+ });
85
+ });
86
+
87
+ it(`Convert <wombat> Object to pathArray should throw error`, () => {
88
+ try {
89
+ SVGPathCommander.shapeToPathArray({ type: 'wombat', fill: 'red' } as unknown as ShapeTypes)
90
+ } catch (er) {
91
+ expect(er).to.be.instanceOf(TypeError);
92
+ expect(er).to.have.property('message', `${error}: "wombat" is not SVGElement`);
93
+ }
94
+ });
95
+
96
+ shapeObjects.forEach((SHAPE) => {
97
+ it(`Convert "${SHAPE.type}" Object to path`, async () => {
98
+ wrapper.append(getMarkup());
99
+ await vi.waitFor(() => wrapper.querySelector('svg') as SVGElement, { timeout: 200 });
100
+ const svg = await vi.waitFor(() => wrapper.querySelector('svg') as SVGElement, { timeout: 200 });
101
+ svg.setAttribute('viewBox', '0 0 182 72');
102
+
103
+ svg.append(SVGPathCommander.shapeToPath(SHAPE as unknown as ShapeTypes) as SVGPathElement);
104
+ const shape = svg.querySelector(`#${SHAPE.type}`);
105
+ expect(shape).to.exist;
106
+ expect(shape?.getAttribute('d')).to.have.length.greaterThan(0);
107
+ });
108
+ });
109
+
110
+ simpleShapes.normalized.forEach((SHAPE, i) => {
111
+ it(`Can do optimizePath #${i}`, () => {
112
+ const path = new SVGPathCommander(SHAPE);
113
+
114
+ expect(path.optimize().toString()).to.equal(simpleShapes.initial[i]);
115
+ });
116
+ });
117
+
118
+ it(`Can revert back to default round option`, () => {
119
+ const sample = [["M", 0, 0], ["L", 181.99955, 0], ["L", 91, 72], ["L", 0, 0], ["Z"]];
120
+ const rounded = [["M", 0, 0], ["L", 181.9996, 0], ["L", 91, 72], ["L", 0, 0], ["Z"]];
121
+
122
+ // @ts-expect-error
123
+ expect(SVGPathCommander.roundPath(sample, -1), `use 4 decimals when negative number is provided`).to.deep.equal(rounded);
124
+ // @ts-expect-error
125
+ expect(SVGPathCommander.roundPath(sample, 'wombat'), `use 4 decimals when string is provided`).to.deep.equal(rounded);
126
+ });
127
+
128
+ it(`Can do reverseCurve`, () => {
129
+ const path = new SVGPathCommander(simpleShapes.normalized[1]);
130
+ const pathReversed = new SVGPathCommander(simpleShapes.normalized[1]).reverse();
131
+ const reversed = [["M", 170, 90], ["C", 150, 90, 155, 10, 130, 10], ["C", 105, 10, 110, 90, 90, 90], ["C", 70, 90, 75, 10, 50, 10], ["C", 25, 10, 30, 90, 10, 90]];
132
+
133
+ expect(pathReversed.segments).to.deep.equal(reversed);
134
+ expect(SVGPathCommander.reverseCurve(pathReversed.segments as CurveArray)).to.deep.equal(path.segments);
135
+ });
136
+
137
+ it(`Can do reversePath`, () => {
138
+ const path = new SVGPathCommander(simpleShapes.normalized[2]);
139
+ const pathReversed = new SVGPathCommander(simpleShapes.normalized[2]).reverse();
140
+ const reversed = [["M", 190, 50], ["Q", 175, 75, 160, 50], ["Q", 145, 25, 130, 50], ["Q", 115, 75, 100, 50], ["Q", 85, 25, 70, 50], ["Q", 55, 75, 40, 50], ["Q", 25, 25, 10, 50]];
141
+
142
+ expect(pathReversed.segments).to.deep.equal(reversed);
143
+ expect(SVGPathCommander.reversePath(pathReversed.segments)).to.deep.equal(path.segments);
144
+ });
145
+
146
+ it(`Can transformPath with arc segments`, () => {
147
+ const { transformPath, pathToString, reversePath } = SVGPathCommander;
148
+
149
+ // This test assumes **SVGPathCommander** static method can work with default
150
+ // transform origin *{0,0,0}* when no origin is provided in the **transformObject**.
151
+ // The test also shows how Arc segments are converted to CubicBezier for transformation.
152
+ const path = pathToString(transformPath(simpleShapes.initial[3], { rotate: 45 }));
153
+ expect(path).to.equal('M-2.8284 11.3137C-6.3778 10.7769 -7.6385 14.9238 -5.0977 18.7783C-2.5569 22.6327 1.8798 23.3038 2.8884 19.9862C3.153 19.1158 3.1321 18.0645 2.8284 16.9706M-2.8284 11.3137C-3.9859 7.1438 -0.9528 4.7691 2.631 7.0393C6.2148 9.3095 7.6616 14.5219 5.2352 16.4216C4.5986 16.92 3.7596 17.1114 2.8284 16.9706M-2.8284 11.3137C-0.4208 11.6779 2.0433 14.1419 2.8284 16.9706M-2.8284 11.3137C-2.0433 14.1423 0.4208 16.6064 2.8284 16.9706');
154
+
155
+ const path1 = pathToString(transformPath(simpleShapes.initial[3], { rotate: -45 }));
156
+ expect(path1).to.equal('M11.3137 2.8284C10.7769 6.3778 14.9238 7.6385 18.7783 5.0977C22.6327 2.5569 23.3038 -1.8798 19.9862 -2.8884C19.1158 -3.153 18.0645 -3.1321 16.9706 -2.8284M11.3137 2.8284C7.1438 3.9859 4.7691 0.9528 7.0393 -2.631C9.3095 -6.2148 14.5219 -7.6616 16.4216 -5.2352C16.92 -4.5986 17.1114 -3.7596 16.9706 -2.8284M11.3137 2.8284C11.6779 0.4208 14.1419 -2.0433 16.9706 -2.8284M11.3137 2.8284C14.1423 2.0433 16.6064 -0.4208 16.9706 -2.8284');
157
+
158
+ // @ts-expect-error
159
+ const path2 = pathToString(transformPath(reversePath(simpleShapes.initial[3]), { rotate: 45 }));
160
+ expect(path2).to.equal('M2.8284 16.9706C0.4208 16.6064 -2.0433 14.1423 -2.8284 11.3137M2.8284 16.9706C2.0433 14.1419 -0.4208 11.6779 -2.8284 11.3137M2.8284 16.9706C6.3778 17.5074 7.6385 13.3604 5.0977 9.506C2.5569 5.6516 -1.8798 4.9805 -2.8884 8.2981C-3.153 9.1684 -3.1321 10.2198 -2.8284 11.3137M2.8284 16.9706C3.9859 21.1405 0.9528 23.5152 -2.631 21.245C-6.2148 18.9748 -7.6616 13.7624 -5.2352 11.8626C-4.5986 11.3642 -3.7596 11.1729 -2.8284 11.3137');
161
+
162
+ // @ts-expect-error
163
+ const path3 = pathToString(transformPath(reversePath(simpleShapes.initial[3]), { rotate: -45 }));
164
+ expect(path3).to.equal('M16.9706 -2.8284C16.6064 -0.4208 14.1423 2.0433 11.3137 2.8284M16.9706 -2.8284C14.1419 -2.0433 11.6779 0.4208 11.3137 2.8284M16.9706 -2.8284C17.5074 -6.3778 13.3604 -7.6385 9.506 -5.0977C5.6516 -2.5569 4.9805 1.8798 8.2981 2.8884C9.1684 3.153 10.2198 3.1321 11.3137 2.8284M16.9706 -2.8284C21.1405 -3.9859 23.5152 -0.9528 21.245 2.631C18.9748 6.2148 13.7624 7.6616 11.8626 5.2352C11.3642 4.5986 11.1729 3.7596 11.3137 2.8284');
165
+ });
166
+
167
+ it(`Can do getPropertiesAtLength`, () => {
168
+ try {
169
+ SVGPathCommander.getPropertiesAtLength('M16.9706 -2.8284A4 6 89.5025 0 1 11.3137 2.8284M', 50);
170
+ } catch (er) {
171
+ expect(er).to.be.instanceOf(TypeError);
172
+ expect(er).to.have.property('message', `${error}: ${invalidPathValue} at index 48, "pathValue" is missing param`);
173
+ }
174
+
175
+ const props0 = SVGPathCommander.getPropertiesAtLength(simpleShapes.initial[0], 0);
176
+ // cy.log(props50)
177
+ expect(props0.index).to.equal(0)
178
+ expect(props0.lengthAtSegment).to.equal(0)
179
+ expect(props0.segment).to.deep.equal(["M", 10, 10])
180
+
181
+ const props50 = SVGPathCommander.getPropertiesAtLength(simpleShapes.initial[0], 50);
182
+ // cy.log(props50)
183
+ expect(props50.index).to.equal(1)
184
+ expect(props50.lengthAtSegment).to.equal(0)
185
+ expect(props50.segment).to.deep.equal(['l', 80, 80])
186
+
187
+ const props400 = SVGPathCommander.getPropertiesAtLength(simpleShapes.initial[0], 400);
188
+ // cy.log(props50)
189
+ expect(props400.index).to.equal(3)
190
+ expect(props400.lengthAtSegment).to.equal(193.1370849898476)
191
+ expect(props400.segment).to.deep.equal(['H', 50])
192
+ });
193
+
194
+ it(`Can do getPropertiesAtPoint`, () => {
195
+ const { getPropertiesAtPoint } = SVGPathCommander;
196
+
197
+ // getPropertiesAtPoint first point
198
+ const propsPoint0 = getPropertiesAtPoint(simpleShapes.initial[1], { "x": 10, "y": 90 });
199
+ expect(propsPoint0.closest).to.deep.equal({ x: 10, y: 90 });
200
+ expect(propsPoint0.distance).to.equal(0);
201
+ expect(propsPoint0.segment).to.deep.equal({ segment: ["M", 10, 90], index: 0, length: 0, point: { x: 10, y: 90 }, lengthAtSegment: 0 })
202
+
203
+ // getPropertiesAtPoint mid point
204
+ const propsPoint50 = getPropertiesAtPoint(simpleShapes.initial[1], { x: 30.072453006153214, y: 41.42818552481854 });
205
+ expect(propsPoint50.closest).to.deep.equal({ x: 30.072383912322863, y: 41.42816186159437 })
206
+ expect(propsPoint50.distance).to.equal(0.00007303359207048124)
207
+ expect(propsPoint50.segment).to.deep.equal({ segment: ['C', 30, 90, 25, 10, 50, 10], index: 1, length: 94.75724347727943, lengthAtSegment: 0 })
208
+
209
+ // getPropertiesAtPoint last point
210
+ const propsPoint400 = getPropertiesAtPoint(simpleShapes.initial[1], { "x": 50, "y": 10 });
211
+ expect(propsPoint400.closest).to.deep.equal({ x: 50.000003520199236, y: 10.000000000000531 })
212
+ expect(propsPoint400.distance).to.equal(0.0000035201992361067316)
213
+ expect(propsPoint400.segment).to.deep.equal({ segment: ['s', 20, 80, 40, 80], index: 2, length: 94.75724347727943, lengthAtSegment: 94.75724347727943 })
214
+ });
215
+
216
+ it(`Can do getSegmentAtLength`, () => {
217
+ const { getSegmentAtLength } = SVGPathCommander;
218
+ expect(getSegmentAtLength(simpleShapes.initial[1])).to.deep.equal(['M', 10, 90]);
219
+ expect(getSegmentAtLength(simpleShapes.initial[1], 0)).to.deep.equal(['M', 10, 90]);
220
+ expect(getSegmentAtLength(simpleShapes.initial[3], 15)).to.deep.equal(['a', 6, 4, 10, 1, 0, 8, 0]);
221
+ expect(getSegmentAtLength(simpleShapes.initial[3], 400)).to.deep.equal(['a', 6, 4, 10, 0, 0, 8, 0]);
222
+ });
223
+
224
+ it(`Can do getSegmentOfPoint`, () => {
225
+ const { getSegmentOfPoint } = SVGPathCommander;
226
+ // first point
227
+ expect(getSegmentOfPoint(simpleShapes.initial[1], { x: 10, y: 90 })).to.deep.equal({ segment: ["M", 10, 90], index: 0, length: 0, point: { x: 10, y: 90 }, lengthAtSegment: 0 });
228
+ // mid point
229
+ expect(getSegmentOfPoint(simpleShapes.initial[3], { x: 9, y: 9 })).to.deep.equal({ segment: ["a", 6, 4, 10, 0, 1, 8, 0], index: 5, length: 7.498916687913066,/* point: { x: 6, y: 10 },*/ lengthAtSegment: 48.11479095890485 });
230
+ });
231
+
232
+ it(`Can do getClosestPoint`, () => {
233
+ const { getClosestPoint } = SVGPathCommander;
234
+ // first point
235
+ expect(getClosestPoint(simpleShapes.initial[1], { x: 10, y: 90 })).to.deep.equal({ x: 10, y: 90 });
236
+ // mid point
237
+ expect(getClosestPoint(simpleShapes.initial[3], { x: 9, y: 9 })).to.deep.equal({ x: 8.995511191469355, y: 8.952970323068374 });
238
+ });
239
+
240
+ it(`Can do isPointInStroke`, () => {
241
+ const { isPointInStroke } = SVGPathCommander;
242
+ // first point
243
+ expect(isPointInStroke(simpleShapes.initial[1], { x: 10, y: 90 })).to.be.true;
244
+ // mid point'
245
+ // expect(isPointInStroke(simpleShapes.initial[1], { x: 28.94438057441916, y: 46.29922469345143 })).to.be.true;
246
+ expect(isPointInStroke(simpleShapes.initial[1], { x: 90, y: 90 })).to.be.true;
247
+ // ({ x: 10, y: 10 })
248
+ expect(isPointInStroke(simpleShapes.initial[1], { x: 10, y: 10 })).to.be.false;
249
+ // ({ x: 45.355339, y: 45.355339 })
250
+ expect(isPointInStroke(simpleShapes.initial[1], { x: 45.355339, y: 45.355339 })).to.be.false;
251
+ // ({ x: 50, y: 10 })
252
+ expect(isPointInStroke(simpleShapes.initial[1], { x: 50, y: 10 })).to.be.true;
253
+ });
254
+
255
+ it(`Can do getDrawDirection`, () => {
256
+ const { getDrawDirection } = SVGPathCommander;
257
+ expect(getDrawDirection(simpleShapes.reversed[1])).to.be.true;
258
+ expect(getDrawDirection(simpleShapes.initial[1])).to.be.false;
259
+ });
260
+
261
+ it(`Can do splitCubic`, () => {
262
+ const { splitCubic } = SVGPathCommander;
263
+ expect(splitCubic([70, 60, 70, 80, 110, 80, 110, 60])).to.deep.equal([
264
+ ['C', 70, 70, 80, 75, 90, 75],
265
+ ['C', 100, 75, 110, 70, 110, 60],
266
+ ]);
267
+ });
268
+
269
+ it(`Can do polygonLength`, () => {
270
+ const { polygonLength } = SVGPathCommander;
271
+ expect(polygonLength([[100, 100], [150, 25], [150, 75], [200, 0]])).to.equal(230.27756377319946);
272
+ });
273
+
274
+ it(`Can do polygonArea`, () => {
275
+ const { polygonArea } = SVGPathCommander;
276
+ expect(polygonArea([[107.4, 13], [113.7, 28.8], [127.9, 31.3], [117.6, 43.5], [120.1, 60.8], [107.4, 52.6], [94.6, 60.8], [97.1, 43.5], [86.8, 31.3], [101, 28.8]])).to.equal(-836.69);
277
+ });
278
+
279
+ it(`Can do transformPath with empty object`, () => {
280
+ const { transformPath, pathToString } = SVGPathCommander;
281
+ const path = pathToString(transformPath(simpleShapes.normalized[0] as string));
282
+ expect(path).to.equal(simpleShapes.normalized[0]);
283
+ const path1 = pathToString(transformPath(simpleShapes.normalized[0], {}));
284
+ expect(path1).to.equal(simpleShapes.normalized[0]);
285
+ const path2 = pathToString(transformPath(simpleShapes.normalized[0], { origin: [0, 0, 0] }));
286
+ expect(path2).to.equal(simpleShapes.normalized[0]);
287
+ });
288
+
289
+ it(`Can check path type`, () => {
290
+ const { parsePathString, isPathArray, isCurveArray, isAbsoluteArray, isRelativeArray, isNormalizedArray } = SVGPathCommander;
291
+ // const
292
+ expect(isPathArray(simpleShapes.initial[0])).to.be.false;
293
+ expect(isPathArray(parsePathString(simpleShapes.initial[0]))).to.be.true;
294
+ expect(isAbsoluteArray(simpleShapes.normalized[0])).to.be.false;
295
+ expect(isAbsoluteArray(parsePathString(simpleShapes.normalized[0]))).to.be.true;
296
+ expect(isRelativeArray(shapes.relative[7])).to.be.false;
297
+ // console.log(parsePathString(shapes.relative[7]))
298
+ expect(isRelativeArray(parsePathString(shapes.relative[7]))).to.be.true;
299
+ expect(isNormalizedArray(simpleShapes.normalized[0])).to.be.false;
300
+ expect(isNormalizedArray(parsePathString(simpleShapes.normalized[0]))).to.be.true;
301
+ expect(isCurveArray(simpleShapes.normalized[1])).to.be.false;
302
+ expect(isCurveArray(parsePathString(simpleShapes.normalized[1]))).to.be.true;
303
+
304
+ });
305
+
306
+ it(`Can cover all remaining branches`, () => {
307
+ const { splitPath, parsePathString, getPathBBox, getPointAtLength, getTotalLength } = SVGPathCommander;
308
+ expect(getPointAtLength(simpleShapes.normalized[3], 24.057395479452424)).to.deep.equal({ x: 14, y: 10 });
309
+ expect(getPointAtLength(simpleShapes.normalized[0], 0)).to.deep.equal({ x: 10, y: 10 });
310
+ expect(getPointAtLength(simpleShapes.normalized[3], undefined)).to.deep.equal({ x: 6, y: 10 });
311
+ expect(getTotalLength(simpleShapes.normalized[0])).to.be.above(233);
312
+ expect(getPathBBox(simpleShapes.normalized[2])).to.deep.equal({
313
+ "cx": 100, "cy": 50, "cz": 192.5,
314
+ "height": 25, "width": 180,
315
+ "x": 10, "y": 37.5, "x2": 190, "y2": 62.5,
316
+ });
317
+ expect(getPathBBox(simpleShapes.normalized[1])).to.deep.equal({
318
+ "cx": 90, "cy": 50, "cz": 200,
319
+ "height": 80, "width": 160,
320
+ "x": 10, "y": 10, "x2": 170,"y2": 90,
321
+ });
322
+ expect(splitPath(parsePathString(shapes.relative[1])).length).to.equal(7);
323
+ });
324
+ });