svg-path-commander 0.1.10 → 0.1.11-alpha4

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 (76) hide show
  1. package/README.md +1 -1
  2. package/dist/svg-path-commander.esm.js +556 -392
  3. package/dist/svg-path-commander.esm.min.js +2 -2
  4. package/dist/svg-path-commander.js +581 -400
  5. package/dist/svg-path-commander.min.js +2 -2
  6. package/package.json +3 -4
  7. package/src/convert/pathToAbsolute.js +17 -13
  8. package/src/convert/pathToCurve.js +2 -3
  9. package/src/convert/pathToRelative.js +11 -6
  10. package/src/convert/pathToString.js +1 -1
  11. package/src/math/midPoint.js +4 -4
  12. package/src/parser/finalizeSegment.js +3 -3
  13. package/src/parser/parsePathString.js +2 -2
  14. package/src/parser/pathParser.js +1 -1
  15. package/src/parser/scanFlag.js +1 -1
  16. package/src/parser/scanParam.js +1 -1
  17. package/src/parser/scanSegment.js +1 -1
  18. package/src/parser/skipSpaces.js +1 -1
  19. package/src/process/arcToCubic.js +9 -7
  20. package/src/process/clonePath.js +1 -1
  21. package/src/process/fixArc.js +4 -4
  22. package/src/process/fixPath.js +30 -0
  23. package/src/process/getSVGMatrix.js +32 -30
  24. package/src/process/lineToCubic.js +9 -3
  25. package/src/process/normalizePath.js +5 -4
  26. package/src/process/normalizeSegment.js +16 -13
  27. package/src/process/optimizePath.js +40 -10
  28. package/src/process/projection2d.js +5 -6
  29. package/src/process/reverseCurve.js +6 -7
  30. package/src/process/reversePath.js +20 -14
  31. package/src/process/roundPath.js +4 -4
  32. package/src/process/segmentToCubic.js +21 -14
  33. package/src/process/shortenSegment.js +54 -0
  34. package/src/process/shorthandToCubic.js +1 -1
  35. package/src/process/shorthandToQuad.js +1 -1
  36. package/src/process/splitCubic.js +3 -3
  37. package/src/process/splitPath.js +1 -1
  38. package/src/process/transformPath.js +22 -23
  39. package/src/svg-path-commander.js +21 -9
  40. package/src/util/getCubicSize.js +1 -1
  41. package/src/util/getDrawDirection.js +1 -1
  42. package/src/util/getPathArea.js +5 -5
  43. package/src/util/getPathBBox.js +22 -15
  44. package/src/util/getPathLength.js +4 -2
  45. package/src/util/getPointAtLength.js +7 -4
  46. package/src/util/getSegArcLength.js +6 -2
  47. package/src/util/isAbsoluteArray.js +1 -1
  48. package/src/util/isCurveArray.js +1 -1
  49. package/src/util/isNormalizedArray.js +1 -1
  50. package/src/util/isPathArray.js +1 -1
  51. package/src/util/isRelativeArray.js +1 -1
  52. package/src/util/shapeToPath.js +38 -32
  53. package/src/util/util.js +2 -0
  54. package/types/index.d.ts +96 -49
  55. package/types/math/midPoint.d.ts +1 -1
  56. package/types/parser/finalizeSegment.d.ts +1 -1
  57. package/types/parser/scanFlag.d.ts +1 -1
  58. package/types/parser/scanParam.d.ts +1 -1
  59. package/types/parser/scanSegment.d.ts +1 -1
  60. package/types/parser/skipSpaces.d.ts +1 -1
  61. package/types/process/arcToCubic.d.ts +1 -1
  62. package/types/process/fixPath.d.ts +1 -0
  63. package/types/process/getSVGMatrix.d.ts +1 -1
  64. package/types/process/normalizeSegment.d.ts +1 -1
  65. package/types/process/optimizePath.d.ts +1 -1
  66. package/types/process/projection2d.d.ts +1 -1
  67. package/types/process/segmentToCubic.d.ts +1 -1
  68. package/types/process/shortenSegment.d.ts +1 -0
  69. package/types/process/transformPath.d.ts +1 -1
  70. package/types/svg-path-commander.d.ts +2 -2
  71. package/types/util/getCubicSize.d.ts +1 -1
  72. package/types/util/getPathBBox.d.ts +1 -1
  73. package/types/util/shapeToPath.d.ts +6 -6
  74. package/types/util/util.d.ts +2 -0
  75. package/index.js +0 -3
  76. package/rollup.config.js +0 -58
package/README.md CHANGED
@@ -60,7 +60,7 @@ For developer guidelines, head over to the [wiki pages](https://github.com/thedn
60
60
 
61
61
  # Technical Considerations
62
62
 
63
- * as already mentioned, the `optimize()` method will not simplify/merge the path commands or determine and create shorthand notations; you might need [SVGO](https://github.com/svg/svgo) and its `convertPathData` plugin; however, while computing path command values, the library will try to deliver the best outcome in path reverse or transformation;
63
+ * the `optimize()` instance method will not merge path segments (for instance 2 or more cubic-bezier segments into one or more arc segments); however, it will try to provide shorthand notations where possible, pick the shortest string for each segment; while computing path command values, the script will try to deliver the best possible outcome;
64
64
  * all tools processing path segments will always round float values to 3 decimals; EG: 0.5666 => 0.566, 0.50 => 0.5; you can change the default option with `SVGPathCommander.options.decimals = 2` or remove the value rounding all together with `SVGPathCommander.options.round = 0`; you can also control this feature via instance options;
65
65
  * the `getSVGMatrix` utility we developed will always compute the matrix by applying the transform functions in the following order: `translate`, `rotate`, `skew` and `scale`, which is the default composition/recomposition order specified in the W3C draft;
66
66
  * all 3d transformations as well as skews will convert `A` (arc) path commands to `C` (cubic bezier) due to the lack of resources on 3D to 2D projection;