svg-path-simplify 0.4.1 → 0.4.3

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 (48) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +6 -4
  3. package/dist/svg-path-simplify.esm.js +2450 -888
  4. package/dist/svg-path-simplify.esm.min.js +2 -2
  5. package/dist/svg-path-simplify.js +2450 -888
  6. package/dist/svg-path-simplify.min.js +2 -2
  7. package/dist/svg-path-simplify.pathdata.esm.js +167 -85
  8. package/dist/svg-path-simplify.pathdata.esm.min.js +2 -2
  9. package/docs/privacy-webapp.md +24 -0
  10. package/index.html +333 -132
  11. package/package.json +5 -2
  12. package/src/css_parse.js +317 -0
  13. package/src/detect_input.js +34 -4
  14. package/src/pathData_simplify_harmonize_cpts.js +77 -1
  15. package/src/pathSimplify-main.js +246 -262
  16. package/src/pathSimplify-presets.js +243 -0
  17. package/src/poly-fit-curve-schneider.js +14 -7
  18. package/src/simplify_poly_RC.js +102 -0
  19. package/src/simplify_poly_RDP.js +109 -1
  20. package/src/simplify_poly_radial_distance.js +3 -3
  21. package/src/string_helpers.js +144 -0
  22. package/src/svgii/convert_units.js +8 -2
  23. package/src/svgii/geometry.js +182 -3
  24. package/src/svgii/geometry_length.js +237 -0
  25. package/src/svgii/pathData_convert.js +43 -1
  26. package/src/svgii/pathData_fix_directions.js +6 -0
  27. package/src/svgii/pathData_fromPoly.js +3 -3
  28. package/src/svgii/pathData_getLength.js +86 -0
  29. package/src/svgii/pathData_parse.js +2 -0
  30. package/src/svgii/pathData_parse_els.js +189 -189
  31. package/src/svgii/pathData_split_to_groups.js +168 -0
  32. package/src/svgii/pathData_stringify.js +26 -64
  33. package/src/svgii/pathData_toPolygon.js +3 -4
  34. package/src/svgii/poly_analyze.js +61 -0
  35. package/src/svgii/poly_normalize.js +11 -2
  36. package/src/svgii/poly_to_pathdata.js +85 -24
  37. package/src/svgii/rounding.js +8 -7
  38. package/src/svgii/svg-styles-to-attributes-const.js +1 -0
  39. package/src/svgii/svg_cleanup.js +467 -421
  40. package/src/svgii/svg_cleanup_convertPathLength.js +32 -0
  41. package/src/svgii/svg_cleanup_general_svg_atts.js +97 -0
  42. package/src/svgii/svg_cleanup_normalize_transforms.js +83 -0
  43. package/src/svgii/svg_cleanup_remove_els_and_atts.js +72 -0
  44. package/src/svgii/svg_cleanup_ungroup.js +36 -0
  45. package/src/svgii/svg_el_parse_style_props.js +76 -28
  46. package/src/svgii/svg_getElementLength.js +67 -0
  47. package/tests/testSVG_shape.js +59 -0
  48. package/tests/testSVG_transform.js +61 -0
@@ -0,0 +1,61 @@
1
+
2
+ /**
3
+ * load node polyfills for DOM parsing
4
+ * loads linkedom npm module for DOM parsing and emulation
5
+ */
6
+ import 'svg-path-simplify/node';
7
+ import { svgPathSimplify } from 'svg-path-simplify';
8
+
9
+
10
+
11
+ let svgMarkup =`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 100" font-size="24px" font-family="Arial" style="fill:red">
12
+ <g style="transform:translate(-25%, 10px); stroke:#000000; stroke-width:2px">
13
+ <g transform="translate(25.0 0)" style="transform:translate(49.765%, 1em) scale(50%); transform-origin:center 10px">
14
+ <ellipse cx="50%" cy="50%" rx="50%" ry="50%" fill="orange" fill-opacity="0.5" style="transform:rotate(-0.785398rad)
15
+ matrix(1.2, 0 ,0,1.2,0,0 ) translateX(-1mm) translateY(-1mm) skewX(10rad) skewY(10rad) scaleX(0.8) scaleY(75%); transform-origin:10mm 5mm; rotate:25deg; scale:50% 1.25; translate:-3mm -0.1in;"></ellipse>
16
+ <circle cx="50%" cy="50%" r="50%" fill="blue" fill-opacity="0.5" font-family="Arial" font-size="12px" transform="translate(-1 2) translate(-50 0)"></circle>
17
+ <rect x="0" y="0" width="49.999%" height="50.0001%" stroke-dasharray="0 10" stroke-linecap="round" transform="rotate(3 120 60) translate(-3,-5) rotate(-15) scale(0.75)" transform-origin="center"></rect>
18
+
19
+ <rect x="0" y="0" width="49.999%" height="60.0001%" stroke-dasharray="0 10" rx="5%" ry="20%" stroke-linecap="round" transform="translate(-80,-50) scale(0.75)" transform-origin="center" style="fill:green; fill-opacity:0.5"></rect>
20
+
21
+ <text x="50%" y="50%" stroke="none" fill="#000000" transform="rotate(-15) translate(-200 0)">Text</text>
22
+
23
+ </g>
24
+ </g>
25
+ </svg>`
26
+
27
+
28
+ // try to simplify
29
+ let options = {
30
+ stylesToAttributes:true,
31
+ //mergePaths:true,
32
+ //shapesToPaths:true,
33
+ convertTransforms:true,
34
+ }
35
+
36
+
37
+ let svgOpt = svgPathSimplify(svgMarkup, options);
38
+
39
+ // simplified pathData
40
+ console.log(svgOpt)
41
+
42
+
43
+
44
+ /*
45
+ let document = new DOMParser().parseFromString(svgMarkup, 'image/svg+xml');
46
+ let svg = document.querySelector('svg');
47
+ let path = svg.querySelector('path');
48
+ let els = svg.querySelectorAll('path')
49
+ let d = path.getAttribute('d').substring(0, 10)
50
+ //console.log(els);
51
+
52
+
53
+ //let markup = document.toString()
54
+ let markup = new XMLSerializer().serializeToString(svg)
55
+ */
56
+ //console.log(markup);
57
+
58
+
59
+
60
+ /*
61
+ */