svg-path-simplify 0.1.3 → 0.2.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/README.md +10 -0
- package/dist/svg-path-simplify.esm.js +3905 -1533
- package/dist/svg-path-simplify.esm.min.js +13 -1
- package/dist/svg-path-simplify.js +3923 -1551
- package/dist/svg-path-simplify.min.js +13 -1
- package/dist/svg-path-simplify.min.js.gz +0 -0
- package/index.html +61 -31
- package/package.json +3 -5
- package/src/constants.js +3 -0
- package/src/index-node.js +0 -1
- package/src/index.js +26 -0
- package/src/pathData_simplify_cubic.js +74 -31
- package/src/pathData_simplify_cubicsToArcs.js +566 -0
- package/src/pathData_simplify_harmonize_cpts.js +170 -0
- package/src/pathData_simplify_revertToquadratics.js +21 -0
- package/src/pathSimplify-main.js +253 -86
- package/src/poly-fit-curve-schneider.js +570 -0
- package/src/simplify_poly_RDP.js +146 -0
- package/src/simplify_poly_radial_distance.js +100 -0
- package/src/svg_getViewbox.js +1 -1
- package/src/svgii/geometry.js +389 -63
- package/src/svgii/geometry_area.js +2 -1
- package/src/svgii/pathData_analyze.js +259 -212
- package/src/svgii/pathData_convert.js +91 -663
- package/src/svgii/pathData_fromPoly.js +12 -0
- package/src/svgii/pathData_parse.js +90 -89
- package/src/svgii/pathData_parse_els.js +3 -0
- package/src/svgii/pathData_parse_fontello.js +449 -0
- package/src/svgii/pathData_remove_collinear.js +44 -37
- package/src/svgii/pathData_reorder.js +2 -1
- package/src/svgii/pathData_simplify_redraw.js +343 -0
- package/src/svgii/pathData_simplify_refineCorners.js +18 -9
- package/src/svgii/pathData_simplify_refineExtremes.js +19 -78
- package/src/svgii/pathData_split.js +42 -45
- package/src/svgii/pathData_toPolygon.js +130 -4
- package/src/svgii/poly_analyze.js +470 -14
- package/src/svgii/poly_to_pathdata.js +224 -19
- package/src/svgii/rounding.js +55 -112
- package/src/svgii/svg_cleanup.js +13 -1
- package/src/svgii/visualize.js +8 -3
- package/{debug.cjs → tests/debug.cjs} +3 -0
- /package/{test.js → tests/test.js} +0 -0
- /package/{testSVG.js → tests/testSVG.js} +0 -0
package/README.md
CHANGED
|
@@ -45,6 +45,7 @@ Unlike most existing approaches (e.g in graphic applications), it checks where s
|
|
|
45
45
|
+ [Simplification parameters](#simplification-parameters)
|
|
46
46
|
+ [Advanced simplifications](#advanced-simplifications)
|
|
47
47
|
+ [Output options](#output-options)
|
|
48
|
+
+ [SVG scaling](#svg-scaling)
|
|
48
49
|
+ [SVG output optimizations](#svg-output-optimizations)
|
|
49
50
|
+ [SVG input normalization](#svg-input-normalization)
|
|
50
51
|
* [Demos](#demos)
|
|
@@ -253,6 +254,14 @@ These params control shich simplifications are applied. The default settings aim
|
|
|
253
254
|
| toRelative | converts all commands to relative – reduces file size | Boolean | true |
|
|
254
255
|
| toShorthands | converts all commands to shorthand when applicable – reduces file size | Boolean | true |
|
|
255
256
|
|
|
257
|
+
### SVG scaling
|
|
258
|
+
Scaling only indirectly affects file size analogous to rounding. Use it only for very large or small SVGs. Finding the »sweet spot« where all coordinates can be expressed in integers can reduce file size as no decimal separators are required.
|
|
259
|
+
|
|
260
|
+
| parameter | effect | type | default |
|
|
261
|
+
| -- | -- | -- | -- |
|
|
262
|
+
| scale | scales all pathdata, `viewBox`, `width` and `height` attributes | Boolean | true |
|
|
263
|
+
| scaleTo | scales to a specified max width | Boolean | false |
|
|
264
|
+
|
|
256
265
|
|
|
257
266
|
### SVG input normalization
|
|
258
267
|
| parameter | effect | type | default |
|
|
@@ -274,6 +283,7 @@ You can easily test this library via the [**webapp**](https://herrstrietzel.gith
|
|
|
274
283
|
### Demo files
|
|
275
284
|
* [simple setup IIFE](./demo/simple-iife.html)
|
|
276
285
|
* [simple setup esm](./demo/simple-esm.html)
|
|
286
|
+
* [codepen](https://codepen.io/herrstrietzel/pen/PwzxpoE)
|
|
277
287
|
|
|
278
288
|
|
|
279
289
|
|