svg-path-simplify 0.4.2 → 0.4.4

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 (61) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +7 -4
  3. package/dist/svg-path-simplify.esm.js +3593 -1279
  4. package/dist/svg-path-simplify.esm.min.js +2 -2
  5. package/dist/svg-path-simplify.js +3594 -1278
  6. package/dist/svg-path-simplify.min.js +2 -2
  7. package/dist/svg-path-simplify.pathdata.esm.js +1017 -538
  8. package/dist/svg-path-simplify.pathdata.esm.min.js +2 -2
  9. package/dist/svg-path-simplify.poly.cjs +9 -8
  10. package/docs/privacy-webapp.md +24 -0
  11. package/index.html +331 -152
  12. package/package.json +1 -1
  13. package/src/constants.js +4 -0
  14. package/src/css_parse.js +317 -0
  15. package/src/detect_input.js +76 -28
  16. package/src/index.js +8 -0
  17. package/src/pathData_simplify_cubic.js +26 -16
  18. package/src/pathData_simplify_harmonize_cpts.js +77 -1
  19. package/src/pathData_simplify_revertToquadratics.js +0 -1
  20. package/src/pathSimplify-main.js +304 -276
  21. package/src/pathSimplify-only-pathdata.js +7 -2
  22. package/src/pathSimplify-presets.js +254 -0
  23. package/src/poly-fit-curve-schneider.js +14 -7
  24. package/src/simplify_poly_RC.js +102 -0
  25. package/src/simplify_poly_RDP.js +109 -1
  26. package/src/simplify_poly_radial_distance.js +3 -3
  27. package/src/string_helpers.js +130 -4
  28. package/src/svg-getAttributes.js +4 -2
  29. package/src/svgii/convert_units.js +1 -1
  30. package/src/svgii/geometry.js +322 -5
  31. package/src/svgii/geometry_bbox_element.js +1 -1
  32. package/src/svgii/geometry_deduceRadius.js +116 -27
  33. package/src/svgii/geometry_length.js +253 -0
  34. package/src/svgii/pathData_analyze.js +18 -0
  35. package/src/svgii/pathData_convert.js +193 -89
  36. package/src/svgii/pathData_fix_directions.js +12 -14
  37. package/src/svgii/pathData_fromPoly.js +3 -3
  38. package/src/svgii/pathData_getLength.js +86 -0
  39. package/src/svgii/pathData_parse.js +2 -0
  40. package/src/svgii/pathData_parse_els.js +66 -68
  41. package/src/svgii/pathData_reorder.js +122 -16
  42. package/src/svgii/pathData_simplify_refineCorners.js +130 -35
  43. package/src/svgii/pathData_simplify_refine_round.js +420 -0
  44. package/src/svgii/pathData_split_to_groups.js +168 -0
  45. package/src/svgii/pathData_stringify.js +26 -64
  46. package/src/svgii/pathData_toPolygon.js +3 -4
  47. package/src/svgii/poly_analyze.js +61 -0
  48. package/src/svgii/poly_normalize.js +11 -2
  49. package/src/svgii/poly_to_pathdata.js +85 -24
  50. package/src/svgii/rounding.js +80 -78
  51. package/src/svgii/svg_cleanup.js +421 -619
  52. package/src/svgii/svg_cleanup_convertPathLength.js +39 -0
  53. package/src/svgii/svg_cleanup_general_svg_atts.js +97 -0
  54. package/src/svgii/svg_cleanup_normalize_transforms.js +83 -0
  55. package/src/svgii/svg_cleanup_remove_els_and_atts.js +77 -0
  56. package/src/svgii/svg_cleanup_ungroup.js +36 -0
  57. package/src/svgii/svg_el_parse_style_props.js +72 -47
  58. package/src/svgii/svg_getElementLength.js +67 -0
  59. package/src/svgii/svg_validate.js +220 -0
  60. package/tests/testSVG.js +14 -1
  61. package/src/svgii/pathData_refine_round.js +0 -222
package/index.html CHANGED
@@ -15,6 +15,7 @@
15
15
  content="https://herrstrietzel.github.io/svg-path-simplify/demo/img/repository-open-graph-template.png">
16
16
 
17
17
 
18
+ <!--
18
19
  <script type="application/ld+json">
19
20
  {
20
21
  "@context": "https://schema.org",
@@ -25,6 +26,8 @@
25
26
  "description": "A JavaScript library to simplify and optimize SVG path data."
26
27
  }
27
28
  </script>
29
+ -->
30
+
28
31
 
29
32
 
30
33
  <link rel="preload" href="demo/css/IBM-Plex-Sans_static/fonts/IBM-Plex-Sans/IBMPlexSans_latin_400.woff2" as="font"
@@ -67,7 +70,11 @@
67
70
  <script src="demo/samples.js" defer></script>
68
71
 
69
72
  <!-- Md parser -->
73
+ <!--
70
74
  <script src="https://cdn.jsdelivr.net/gh/UmemotoCtrl/mdpjs@0.1.4/js/mdp.min.js" defer></script>
75
+ -->
76
+
77
+ <script src="https://cdn.jsdelivr.net/npm/mdpjs@0.0.5/dist/mdpjs.min.js"></script>
71
78
 
72
79
  <!-- Zip creation -->
73
80
  <script src="https://cdn.jsdelivr.net/npm/uzip@0.20201231.0/UZIP.min.js" async></script>
@@ -75,23 +82,24 @@
75
82
 
76
83
  <!-- UI helpers -->
77
84
 
78
- <link rel="preload" href="https://cdn.jsdelivr.net/npm/enhance-inputs@0.3.9/dist/enhanceInputs.min.css"
79
- as="style" />
80
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/enhance-inputs@0.3.9/dist/enhanceInputs.min.css">
81
- <script src="https://cdn.jsdelivr.net/npm/enhance-inputs@0.3.9/dist/enhanceInputs.min.js" defer></script>
82
85
 
86
+ <link rel="preload" href="demo/css/app.css" as="style" />
87
+
88
+ <link rel="preload" href="https://cdn.jsdelivr.net/npm/enhance-inputs@0.4.1/dist/enhanceInputs.min.css"
89
+ as="style" />
90
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/enhance-inputs@0.4.1/dist/enhanceInputs.min.css">
91
+ <script src="https://cdn.jsdelivr.net/npm/enhance-inputs@0.4.1/dist/enhanceInputs.min.js" defer></script>
83
92
  <!--
93
+
84
94
  <link rel="stylesheet" href="//localhost/___git/enhance-inputs/enhance-inputs/dist/enhanceInputs.css">
85
95
  <script src="//localhost/___git/enhance-inputs/enhance-inputs/dist/enhanceInputs.js" defer></script>
86
-
87
96
  -->
88
97
 
89
-
90
98
  <!--
91
99
  <script src="https://cdn.jsdelivr.net/npm/svg-path-simplify@0.1.2/dist/svg-path-simplify.min.js" defer></script>
92
100
  -->
93
101
 
94
- <script src="dist/svg-path-simplify.min.js" defer></script>
102
+ <script src="dist/svg-path-simplify.js" defer></script>
95
103
  <link rel="stylesheet" href="demo/css/app.css">
96
104
 
97
105
  <script src="demo/lib/elzoomo/elzoomo.js" defer></script>
@@ -125,53 +133,20 @@
125
133
  </p>
126
134
 
127
135
  <h1 class="txt-cnt h1">Simplify SVG files and path data</h1>
128
- <h2 class="p txt-cnt">Optimizes SVG data by removing excessive commands and applying markup
136
+ <h2 class="p txt-cnt">Optimize and sanitize SVG data by removing excessive commands and applying markup
129
137
  minifications such as coordinate rounding, relative and applicable shorthand commands</h2>
130
138
 
131
- <p class="--btn-neg" data-ui="reset"></p>
132
-
133
- <details>
134
- <summary class="h3">Privacy</summary>
135
-
136
- <h3>Simplification</h3>
137
- <p>Enter your SVG pathData or complete file markup or upload SVG files.</p>
138
- <p class="fnt-wgh-700">All data is processed 100% client-side – no data is transferred or analyzed
139
- by any third-party service during simplification.</p>
140
-
141
- <h3>Sharing and editing</h3>
142
- <ul>
143
- <li>Codepen – sends your current data to <a href="https://codepen.io">codepen.io</a> and creates
144
- a new pen
145
- for testing purposes</li>
146
- <li>Edit – sends data to <a href="https://yqnn.github.io/svg-path-editor">svg-path-editor</a>
147
- for further
148
- path node editing</li>
149
- </ul>
150
-
151
- <h3>External scripts</h3>
152
- <p>The webapp loads these external scripts from jsdelivr</p>
153
- <ul>
154
- <li><a href="https://github.com/WebReflection/linkedom">linkedom</a>
155
- – used for web worker based multi file
156
- processing</li>
157
- <li><a href="https://github.com/photopea/UZIP.js">UZIP</a>
158
- – for multifile zip exports</li>
159
- <li><a href="https://github.com/herrstrietzel/enhance-inputs">enhance-inputs</a>
160
- – used for GUI input
161
- styling and updating logic</li>
162
- </ul>
163
-
164
- <h3>Local Storage</h3>
165
- <p>Your current settings as well as your input SVG data is stored in local Storage. This provides to
166
- apply the same settings to multiple files after reloads. You can delete this settings cache via
167
- the reset settings button.</p>
168
- <p>You image data is never transferred to the github server.</p>
169
-
170
- </details>
139
+ <p>Use the usual shortcuts for copying, pasting or saving output: <kbd>Ctrl</kbd>/<kbd>⌘</kbd> +
140
+ <kbd>C</kbd>, <kbd>Ctrl</kbd>/<kbd>⌘</kbd> + <kbd>V</kbd>,
141
+ <kbd>Ctrl</kbd>/<kbd>⌘</kbd> + <kbd>S</kbd>
142
+ </p>
171
143
 
144
+ <!--
145
+ <p class="--btn-neg" data-ui="reset"></p>
146
+ -->
172
147
 
173
148
  <p><input type="file" class="dsp-non --btn-neg" id="inputFile" name="svgFile" value="upload"
174
- data-label="Upload SVG file/s" accept=".svg" data-ignore="true" multiple></p>
149
+ data-label="Upload SVG file/s" accept=".svg" data-ignore multiple></p>
175
150
 
176
151
 
177
152
  <p>
@@ -185,114 +160,152 @@
185
160
  </textarea>
186
161
  </label>
187
162
 
188
- <details open>
189
- <summary class="h3">SVG cleanup</summary>
190
- <p>
191
- <!--
192
- <label><input type="checkbox" name="removePrologue" checked>removePrologue</label>
193
- -->
194
163
 
195
- <label><input type="checkbox" data-type="checkbox-switch" name="removeNameSpaced"
196
- aria-description="Graphic applications often add a lot of propriatary/custom attributes – not required for browser or exchange format usage"
197
- checked>removeNameSpaced</label>
164
+ <details open class="detailsRemoveElements">
165
+ <summary class="h3">SVG elements/nodes</summary>
198
166
 
199
- <label><input type="checkbox" data-type="checkbox-switch" name="removeComments"
200
- aria-description="Remove custom commentsdisable it if you placed explanatory comments yourself"
201
- checked>removeComments</label>
167
+ <label><input type="checkbox" data-type="checkbox-switch" name="removeNameSpaced"
168
+ aria-description="Graphic applications often add a lot of propriatary/custom elementsnot required for browser or exchange format usage"
169
+ checked>removeNameSpaced</label>
202
170
 
171
+ <label><input type="checkbox" data-type="checkbox-switch" name="cleanupDefs"
172
+ aria-description="Removes empty defs and moves all defs to the top of the SVG markup – many environments struggle with footer placements (figma problem)"
173
+ checked>cleanupDefs</label>
203
174
 
204
- <label><input type="checkbox" data-type="checkbox-switch" name="removeHidden"
205
- aria-description="Graphic applications usually don't exclude hidden layers enable it to remove them to remove undesired bloat"
206
- checked>removeHidden</label>
175
+ <label><input type="checkbox" data-type="checkbox-switch" name="cleanupClip" checked
176
+ aria-description="Removes unnecessary clip-pathsspanning the entire viewBox (e.g typical for figma)">cleanupClip</label>
207
177
 
208
- <label><input type="checkbox" data-type="checkbox-switch" name="cleanupDefs"
209
- aria-description="Removes empty defs and moves all defs to the top of the SVG markup – many environments struggle with footer placements (figma problem)"
210
- checked>cleanupDefs</label>
178
+ <label><input type="checkbox" data-type="checkbox-switch" name="removeOffCanvas"
179
+ aria-description="Removes elements beyond viewBox/outside viewport">removeOffCanvas</label>
211
180
 
212
- <label><input type="checkbox" data-type="checkbox-switch" name="cleanupClip" checked
213
- aria-description="Removes unnecessary clip-pathsspanning the entire viewBox (e.g typical for figma)">cleanupClip</label>
181
+ <label><input type="checkbox" data-type="checkbox-switch" name="removeComments"
182
+ aria-description="Remove custom commentsdisable it if you placed explanatory comments yourself"
183
+ checked>removeComments</label>
214
184
 
185
+ <label><input type="checkbox" data-type="checkbox-switch" name="removeHidden"
186
+ aria-description="Graphic applications usually don't exclude hidden layers – enable it to remove them to remove undesired bloat"
187
+ checked>removeHidden</label>
215
188
 
216
- <label><input type="checkbox" data-type="checkbox-switch" name="cleanupSVGAtts"
217
- aria-description="Remove SVG non-presentational attributes from the root SVG"
218
- checked>cleanupSVGAtts</label>
219
189
 
220
- <label><input type="checkbox" data-type="checkbox-switch" name="allowMeta"
221
- aria-description="Allows metadata elements as well as title and description elements">allowMeta</label>
190
+ <!-- elements in current svg-->
191
+ <div id="removeSvgElsWrp" class="enhancedInputsDynamic">
192
+ </div>
193
+ </details>
222
194
 
223
- <label><input type="checkbox" data-type="checkbox-switch" name="allowAriaAtts"
224
- aria-description="Allows accessibility related ARIA attributes – probably added on purpose"
225
- checked>allowAriaAtts</label>
226
195
 
227
- <label><input type="checkbox" data-type="checkbox-switch" name="allowDataAtts"
228
- aria-description="Allows custom data attributes – probably added on purpose"
229
- checked>allowDataAtts</label>
230
196
 
197
+ <details open class="detailsRemoveSvgAttributes">
198
+ <summary class="h3">SVG attributes</summary>
231
199
 
232
- <label><input type="checkbox" data-type="checkbox-switch" name="removeOffCanvas"
233
- aria-description="Removes elements beyond viewBox/outside viewport">removeOffCanvas</label>
200
+ <label><input type="checkbox" data-type="checkbox-switch" name="removeNameSpacedAtts"
201
+ aria-description="Graphic applications often add a lot of propriatary/custom attributes – not required for browser or exchange format usage"
202
+ checked>removeNameSpacedAtts</label>
234
203
 
235
- <label><input type="checkbox" data-type="checkbox-switch" name="unGroup"
236
- aria-description="Applications often add too many nest groups – removing also converts any styles to elements">unGroup</label>
237
204
 
205
+ <label><input type="checkbox" data-type="checkbox-switch" name="cleanupSVGAtts"
206
+ aria-description="Remove SVG non-presentational attributes from the root SVG"
207
+ checked>cleanupSVGAtts</label>
238
208
 
239
- <!--
240
- <label><input type="checkbox" class="dsp-debug" name="convertTransforms">convertTransforms</label>
241
- -->
242
- </p>
209
+ <label><input type="checkbox" data-type="checkbox-switch" name="allowMeta"
210
+ aria-description="Allows metadata elements as well as title and description elements">allowMeta</label>
211
+
212
+ <label><input type="checkbox" data-type="checkbox-switch" name="allowAriaAtts"
213
+ aria-description="Allows accessibility related ARIA attributes – probably added on purpose"
214
+ checked>allowAriaAtts</label>
215
+
216
+ <label><input type="checkbox" data-type="checkbox-switch" name="allowDataAtts"
217
+ aria-description="Allows custom data attributes – probably added on purpose"
218
+ checked>allowDataAtts</label>
219
+
220
+ <label><input type="checkbox" data-type="checkbox-switch" name="addViewBox" checked
221
+ aria-description="Adds a viewBox attribute if missing – counter-productive if your SVG layout is fluid">addViewBox</label>
222
+
223
+ <label><input type="checkbox" data-type="checkbox-switch" name="addDimensions"
224
+ aria-description="Many graphic applications won't translate viewBox correctly to artboard/document size">addDimensions</label>
225
+
226
+ <label><input type="checkbox" data-type="checkbox-switch"
227
+ name="removeDimensions">removeDimensions</label>
228
+ <label><input type="checkbox" data-type="checkbox-switch" name="removeIds"
229
+ aria-description="Graphic applications usually add unsemantic generic IDs for each layer – remove them unless you need them for JS selection (e.g event bindings)">removeIds</label>
230
+ <label><input type="checkbox" data-type="checkbox-switch"
231
+ aria-description="Graphic applications often add un semantic class names – remove these unless you have specified them on your own or these are required for CSS styling (e.g icon assets)"
232
+ name="removeClassNames">removeClassNames</label>
233
+
234
+ <label><input type="checkbox" data-type="checkbox-switch" name="omitNamespace"
235
+ aria-description="Removes xmlns attribute - only recommended when embedding svg in DOM">omitNamespace</label>
236
+
237
+ <div id="removeSVGAttsWrp" class="enhancedInputsDynamic">
238
+ </div>
243
239
  </details>
244
240
 
241
+
245
242
  <details open>
246
243
  <summary class="h3">SVG style optimization</summary>
247
244
  <p>
248
- <label><input type="checkbox" data-type="checkbox-switch" name="cleanUpStrokes" checked
249
- aria-description="removes stroke attributes when stroke color is missing">cleanUpStrokes</label>
250
-
245
+ <!--
246
+ -->
251
247
  <label><input type="checkbox" data-type="checkbox-switch" name="stylesToAttributes"
252
248
  aria-description="replaces inline styles with SVG atributes and removes obsolete attributes and styles">stylesToAttributes</label>
253
249
 
250
+
251
+ <label><input type="checkbox" data-type="checkbox-switch" name="cleanUpStrokes" checked
252
+ aria-description="removes stroke attributes when stroke color is missing">cleanUpStrokes</label>
253
+
254
254
  <label><input type="checkbox" data-type="checkbox-switch" name="attributesToGroup"
255
255
  aria-description="Try to combine style attributes in group">attributesToGroup</label>
256
256
 
257
257
  <label><input type="checkbox" data-type="checkbox-switch" name="minifyRgbColors"
258
- aria-description="Minifies RGB colors e.g for fill, stroke or stop-color" checked>minifyRgbColors</label>
259
-
258
+ aria-description="Minifies RGB colors e.g for fill, stroke or stop-color"
259
+ checked>minifyRgbColors</label>
260
260
 
261
261
  </p>
262
262
 
263
263
  </details>
264
264
 
265
-
266
265
  <details open>
267
- <summary class="h3">SVG advanced conversions</summary>
266
+ <summary class="h3">Unit conversion</summary>
268
267
 
269
268
  <p>
270
- <label><input type="checkbox" data-type="checkbox-switch" name="addViewBox" checked
271
- aria-description="Adds a viewBox attribute if missingcounter-productive if your SVG layout is fluid">addViewBox</label>
269
+ <label><input type="checkbox" data-type="checkbox-switch" name="convertPathLength"
270
+ aria-description="Converts pathLength attribute to absolute dasharray valuesmany graphic apps han't handle pathLength">convertPathLength</label>
271
+
272
+ <label><input type="checkbox" data-type="checkbox-switch" name="toAbsoluteUnits"
273
+ aria-description="Converts relative units to absolute">toAbsoluteUnits</label>
274
+ </p>
275
+
276
+
277
+
278
+ </details>
272
279
 
273
- <label><input type="checkbox" data-type="checkbox-switch" name="addDimensions"
274
- aria-description="Many graphic applications won't translate viewBox correctly to artboard/document size">addDimensions</label>
275
280
 
276
281
 
282
+ <details open class="detailsRemoveElAttributes">
283
+ <summary class="h3">Child attributes</summary>
284
+
285
+ <label><input type="checkbox" data-type="checkbox-switch" name="fixHref"
286
+ aria-description="Replaces xlink:href with href – many applications still rely on xlink:href notation!">fixHref</label>
287
+
288
+ <label><input type="checkbox" data-type="checkbox-switch" name="legacyHref"
289
+ aria-description="Since many (non-browser) applications still depend on xlink:href notation you may convert href to xlink:href">legacyHref</label>
290
+
291
+ <!--dynamically added -->
292
+ <div id="removeElAttsWrp" class="enhancedInputsDynamic ">
293
+ </div>
294
+ </details>
295
+
296
+
297
+ <details open>
298
+ <summary class="h3">SVG merging/splitting</summary>
299
+ <p>
277
300
  <label><input type="checkbox" data-type="checkbox-switch" name="mergePaths"
278
301
  aria-description="Merge adjacent paths – can minify file size but won't allow you to select individual paths">mergePaths</label>
279
302
 
280
- <label><input type="checkbox" data-type="checkbox-switch"
281
- name="removeDimensions">removeDimensions</label>
282
- <label><input type="checkbox" data-type="checkbox-switch" name="removeIds"
283
- aria-description="Graphic applications usually add unsemantic generic IDs for each layer – remove them unless you need them for JS selection (e.g event bindings)">removeIds</label>
284
- <label><input type="checkbox" data-type="checkbox-switch"
285
- aria-description="Graphic applications often add un semantic class names – remove these unless you have specified them on your own or these are required for CSS styling (e.g icon assets)"
286
- name="removeClassNames">removeClassNames</label>
287
-
288
- <label><input type="checkbox" data-type="checkbox-switch" name="omitNamespace"
289
- aria-description="Removes xmlns attribute - only recommended when embedding svg in DOM">omitNamespace</label>
303
+ <label><input type="checkbox" data-type="checkbox-switch" name="unGroup"
304
+ aria-description="Applications often add too many nest groups – removing also converts any styles to elements">unGroup</label>
290
305
 
291
- <label><input type="checkbox" data-type="checkbox-switch" name="fixHref"
292
- aria-description="Replaces xlink:href with href many applications still rely on xlink:href notation!">fixHref</label>
306
+ <label><input type="checkbox" data-type="checkbox-switch" name="splitCompound"
307
+ aria-description="Tries to split compound paths finding overlapping compound sub paths">splitCompound</label>
293
308
 
294
- <label><input type="checkbox" data-type="checkbox-switch" name="legacyHref"
295
- aria-description="Since many (non-browser) applications still depend on xlink:href notation you may convert href to xlink:href">legacyHref</label>
296
309
 
297
310
  </p>
298
311
 
@@ -336,17 +349,29 @@
336
349
  </p>
337
350
 
338
351
  <p>
339
- <label><input type="checkbox" data-type="checkbox-switch" name="convert_rects"
340
- aria-description="convert paths to rects if applicable">rects</label>
352
+ <label><input type="checkbox" data-type="checkbox-switch" name="convertShapes[]" value="rect"
353
+ checked aria-description="convert paths to rects if applicable">rects</label>
354
+
355
+ <label><input type="checkbox" data-type="checkbox-switch" name="convertShapes[]" value="circle"
356
+ checked
357
+ aria-description="convert paths to circles or ellipses if applicable – ellipses/circles are usually more compact than paths – unless you merge paths">circles</label>
358
+
359
+ <label><input type="checkbox" data-type="checkbox-switch" name="convertShapes[]" value="ellipse"
360
+ checked
361
+ aria-description="convert paths to circles or ellipses if applicable – ellipses/circles are usually more compact than paths – unless you merge paths">ellipse</label>
362
+
341
363
 
342
- <label><input type="checkbox" data-type="checkbox-switch" name="convert_ellipses"
343
- aria-description="convert paths to circles or ellipses if applicable – ellipses/circles are usually more compact than paths – unless you merge paths">ellipses/circles</label>
364
+ <label><input type="checkbox" data-type="checkbox-switch" name="convertShapes[]" value="polygon"
365
+ checked
366
+ aria-description="convert paths to polys if applicable – polylines are quite inefficient as they are all absolute">polygon</label>
344
367
 
345
- <label><input type="checkbox" data-type="checkbox-switch" name="convert_poly"
346
- aria-description="convert paths to polys if applicable – polylines are quite inefficient as they are all absolute">polygons/polylines</label>
368
+ <label><input type="checkbox" data-type="checkbox-switch" name="convertShapes[]"
369
+ value="polyline" checked
370
+ aria-description="convert paths to polys if applicable – polylines are quite inefficient as they are all absolute">polyline</label>
347
371
 
348
- <label><input type="checkbox" data-type="checkbox-switch" name="convert_lines"
349
- aria-description="convert paths to lines if applicable">lines</label>
372
+
373
+ <label><input type="checkbox" data-type="checkbox-switch" name="convertShapes[]" value="line"
374
+ checked aria-description="convert paths to lines if applicable">line</label>
350
375
  </p>
351
376
 
352
377
 
@@ -407,7 +432,15 @@
407
432
  aria-description="Higher tolerance = sloppier approximations and more distortions – default 1"></label>
408
433
  </p>
409
434
 
435
+
436
+
410
437
  <p>
438
+
439
+ <label><input type="checkbox" data-type="checkbox-switch" name="keepSmaller"
440
+ aria-description="Ditches simplified output if original was more compact – useful for batch processing"
441
+ checked>keepSmaller</label>
442
+
443
+
411
444
  <label><input type="checkbox" data-type="checkbox-switch" name="simplifyBezier"
412
445
  aria-description="Tries to combine adjacent Bézier commands"
413
446
  checked>simplifyBezier</label>
@@ -476,6 +509,15 @@
476
509
  <label><input type="checkbox" data-type="checkbox-switch"
477
510
  aria-description="replaces Bézier segments enclosed by linetos with single quadratic commands – handy to reduce overly complex tiny corner roundings"
478
511
  name="simplifyCorners">simplifyCorners</label>
512
+
513
+ <label><input type="checkbox" data-type="checkbox-switch"
514
+ aria-description="Will disable curve adjustment for quadratic corner roundings – usually more compact but less accurate"
515
+ name="simplifyQuadraticCorners">simplifyQuadraticCorners</label>
516
+
517
+
518
+
519
+
520
+
479
521
  <label><input type="checkbox" data-type="checkbox-switch"
480
522
  name="simplifyRound">simplifyRound</label>
481
523
  <label><input type="checkbox" data-type="checkbox-switch"
@@ -545,6 +587,14 @@
545
587
  -->
546
588
  </p>
547
589
 
590
+ <p>
591
+ <label>Output Polygon
592
+ <textarea class="outputPoly code" name="polyOut" id="polyOut" data-tools="size copy"
593
+ data-ignore="true" readonly data-file="polygon.txt"></textarea>
594
+ </label>
595
+ </p>
596
+
597
+
548
598
  </details>
549
599
 
550
600
 
@@ -571,6 +621,7 @@
571
621
  <ul class="ul-bll">
572
622
  <li><strong>Minify</strong> = maximum string minification – my lead to problems in older
573
623
  applications!</li>
624
+ <li><strong>Safe</strong> = avoid floating point and arc param concatenation</li>
574
625
  <li><strong>Verbose</strong> = don't omit command type tokens</li>
575
626
  <li><strong>Beautify</strong>strong> = don't omit command type tokens and separate commands
576
627
  by new lines – handy for educational usage</li>
@@ -578,6 +629,7 @@
578
629
  </details>
579
630
 
580
631
  <p><label><input type="radio" name="minifyD" value="0" checked>minify</label>
632
+ <label><input type="radio" name="minifyD" value="0.5">safe</label>
581
633
  <label><input type="radio" name="minifyD" value="1">verbose</label>
582
634
  <label><input type="radio" name="minifyD" value="2">beautify</label>
583
635
  </p>
@@ -588,15 +640,14 @@
588
640
  </p>
589
641
 
590
642
  <p>
591
- <label class="wdt-100">decimals <input type="number" name="decimals" min="0" value="1"
592
- aria-description="Manual floating point rounding precision – overriden when autoAccuracy is enabled"></label>
643
+ <label class="wdt-100">decimals <input type="number" name="decimals" min="-1" value="1" step="0.5"
644
+ aria-description="Manual floating point rounding precision – overriden when autoAccuracy is enabled: -1 means no rounding"></label>
593
645
  </p>
594
646
  </details>
595
647
 
596
648
 
597
649
  <details open>
598
650
  <summary class="h3">Output</summary>
599
-
600
651
  <p>
601
652
  <label>Output SVG
602
653
  <textarea class="outputSvg code" name="dOutput" id="outputSvg" data-tools="size copy"
@@ -604,16 +655,12 @@
604
655
  </label>
605
656
  </p>
606
657
 
607
- <p>
608
- <label>Output Polygon
609
- <textarea class="outputPoly code" name="polyOut" id="polyOut" data-tools="size copy"
610
- data-ignore="true" readonly data-file="polygon.txt"></textarea>
611
- </label>
612
- </p>
613
658
  </details>
614
659
 
615
660
 
616
661
 
662
+ <!--
663
+
617
664
  <details>
618
665
  <summary class="h3">Settings</summary>
619
666
  <p>
@@ -627,6 +674,7 @@
627
674
 
628
675
  </p>
629
676
  </details>
677
+ -->
630
678
 
631
679
 
632
680
  </aside>
@@ -636,33 +684,35 @@
636
684
  <main class="main --spn-ld-2 --spn-ld-3 scrollbar scroll-content pst-rlt">
637
685
 
638
686
 
639
- <header class="pst-sticky --pdd-1em z-ind-1000 pdd-1em">
687
+ <header class="header-top pst-sticky --pdd-1em z-ind-1000 pdd-1em">
640
688
 
641
689
  <div class="header-nav">
690
+
691
+ <!-- reset -->
692
+ <button type="button" class="btn btnReset" title="Reset settings" data-icon="arrow-path"></button>
693
+
694
+
642
695
  <label class="navToggle"><input type="checkbox" name="showNav" class="showNav" id="showNav"
643
696
  data-icon="adjustments-vertical" checked title="show settings" data-sync="showNav0"></label>
644
697
 
698
+ <!-- load about -->
645
699
  <a href="#" class="a-dialog" data-dialog="#about" data-dialog-title="Options" data-icon="question"
646
700
  title="Available parameters"></a>
647
701
 
648
- <!-- reset -->
649
- <button type="button" class="btn btnReset" title="Reset settings" data-icon="arrow-path"></button>
702
+ <!-- load privacy -->
703
+ <a href="#" class="a-dialog" data-dialog="#privacy" data-dialog-title="privacy"
704
+ data-icon="finger-print" title="Privacy"></a>
705
+
706
+ <!-- file info -->
707
+ <a href="#" class="a-dialog" id="btnFileInfo" data-dialog="#fileInfo" data-dialog-title="File info"
708
+ data-icon="light-bulb" title="File info and recommendations"></a>
709
+
710
+
711
+ <!-- presets -->
712
+ <button type="button" class="btn btn-presets" title="Presets" data-icon="gear"
713
+ data-menu-anchor="menu2"></button>
650
714
 
651
- <!--settings-->
652
- <!--
653
-
654
- <button type="button" class="btn btn-menu btnConfig" title="Edit settings" data-icon="gear"
655
- data-menu-anchor="menu1"></button>
656
-
657
- <div class="menu menu-right-top menu-active" data-menu="menu1">
658
- <p>
659
- <label>Marker size
660
- <input type="number" name="markerSize" value="0.3" min="0.05" max="1" step="0.05">
661
- </label>
662
- </p>
663
- </div>
664
715
 
665
- -->
666
716
 
667
717
  <button type="button" class="elzoomo-btn elzoomo-btn-zoomin" title="zoom in"
668
718
  data-icon="plus"></button>
@@ -670,6 +720,7 @@
670
720
  data-icon="minus"></button>
671
721
  </div>
672
722
 
723
+ <!-- github link -->
673
724
  <a class="lnk-github" href="https://github.com/herrstrietzel/svg-path-simplify"
674
725
  title="See github repository">
675
726
  <svg viewBox="0 0 24 24" class="icn-svg">
@@ -697,8 +748,8 @@
697
748
  <span>
698
749
  <label><input type="checkbox" data-type="checkbox-switch" name="showMarkers"
699
750
  data-secondary="true" checked>showMarkers</label>
700
- <button type="button" class="btn btn-inline btn-menu btnConfig"
701
- title="Edit marker size" data-icon="gear" data-menu-anchor="menu1"></button>
751
+ <button type="button" class="btn btn-info btn-inline btn-menu btnConfig"
752
+ title="Edit marker size" data-icon="ellipsis-horizontal" data-menu-anchor="menu1"></button>
702
753
 
703
754
  </span>
704
755
 
@@ -808,8 +859,6 @@
808
859
 
809
860
  </div>
810
861
 
811
-
812
-
813
862
  </main>
814
863
 
815
864
 
@@ -833,15 +882,140 @@
833
882
 
834
883
 
835
884
 
885
+ <!-- menu presets -->
886
+ <div class="menu menu-presets menu-right-top pdd-1em --menu-active" data-menu="menu2">
887
+ <p class="h4">Presets</p>
888
+
889
+ <p>
890
+ <label>
891
+ <input data-secondary type="radio" name="preset" value="0" aria-description="Custom settings"
892
+ checked>Custom
893
+ </label>
894
+ </p>
895
+ <!--
896
+
897
+ -->
898
+
899
+ <p>
900
+ <label>
901
+ <input data-secondary type="radio" name="preset" value="null"
902
+ aria-description="Disable all – passthrough">null
903
+ </label>
904
+ </p>
905
+
906
+ <p>
907
+ <label>
908
+ <input data-secondary type="radio" name="preset" value="default"
909
+ aria-description="Back to default settings">default
910
+ </label>
911
+ </p>
912
+
913
+ <p>
914
+ <label>
915
+ <input data-secondary type="radio" name="preset" value="education"
916
+ aria-description="Prettified output - all absolute and longhand commands">
917
+ education
918
+ </label>
919
+ </p>
920
+
921
+ <p>
922
+ <label>
923
+ <input data-secondary type="radio" name="preset" value="editor"
924
+ aria-description="Maximum compatibility for graphic editors">
925
+ editor
926
+ </label>
927
+ </p>
928
+
929
+ <p>
930
+ <label>
931
+ <input data-secondary type="radio" name="preset" value="path"
932
+ aria-description="Convert all shapes to paths">
933
+ path
934
+ </label>
935
+ </p>
936
+
937
+ <p>
938
+ <label>
939
+ <input data-secondary type="radio" name="preset" value="detransform"
940
+ aria-description="Convert transforms to geometry">
941
+ detransform
942
+ </label>
943
+ </p>
944
+
945
+ <p>
946
+ <label>
947
+ <input data-secondary type="radio" name="preset" value="poly" aria-description="Convert Bézier to poly">
948
+ poly
949
+ </label>
950
+ </p>
951
+
952
+ <p>
953
+ <label>
954
+ <input data-secondary type="radio" name="preset" value="curvefit"
955
+ aria-description="Convert polygon to Bézier">
956
+ curvefit
957
+ </label>
958
+ </p>
959
+
960
+
961
+ <p>
962
+ <label>
963
+ <input data-secondary type="radio" name="preset" value="noSimplification"
964
+ aria-description="Retains original geometry but applies rounding, conversion to relative and shorthands">
965
+ noSimplification
966
+ </label>
967
+ </p>
968
+
969
+
970
+ <p>
971
+ <label>
972
+ <input data-secondary type="radio" name="preset" value="high"
973
+ aria-description="Prioritize filesize: Enables more optimizations: cubicToArcs, mixed value compression simplification">
974
+ high
975
+ </label>
976
+ </p>
977
+
978
+ <details class="mrg-0-5em mrg-top">
979
+ <summary class="h4">Current settings</summary>
980
+ <p>
981
+ <label>Current Settings
982
+ <textarea class="code" name="config" id="textConfig" data-tools="copy" data-secondary
983
+ readonly></textarea>
984
+ </label>
985
+ <label><input type="checkbox" data-type="checkbox-switch" name="omitDefaults" data-secondary
986
+ aria-description="only include settings that are not defaults" checked>omitDefaults</label>
987
+
988
+ </p>
989
+ </details>
990
+
991
+
992
+ </div>
993
+
994
+
995
+ <!-- dialogs -->
836
996
  <dialog class="--dialog sr-only" id="about">
837
997
  <div class="md-cnt" data-md="./docs/api.md">
838
998
  </div>
839
999
  </dialog>
840
1000
 
1001
+ <dialog class="sr-only" id="privacy">
1002
+ <div class="md-cnt" data-md="./docs/privacy-webapp.md">
1003
+ </div>
1004
+ </dialog>
1005
+
1006
+ <dialog class="sr-only fileInfo" id="fileInfo">
1007
+ <div class="--md-cnt" id="fileInfoReport">
1008
+ </div>
1009
+ </dialog>
1010
+
1011
+
1012
+
1013
+ <!-- menu marker size-->
841
1014
  <div class="menu menu-marker-size menu-top-right --menu-active" data-menu="menu1">
842
1015
  <p>
843
1016
  <label>Marker size
844
- <input type="number" id="inpuMarkerSize" name="markerSize" value="0.3" min="0.05" max="1" step="0.05" data-ignore>
1017
+ <input type="number" id="inpuMarkerSize" name="markerSize" value="0.3" min="0.05" max="1" step="0.05"
1018
+ data-ignore>
845
1019
  </label>
846
1020
  </p>
847
1021
  </div>
@@ -851,6 +1025,11 @@
851
1025
  <div id="spriteMap"></div>
852
1026
  -->
853
1027
 
1028
+
1029
+
1030
+
1031
+
1032
+
854
1033
  </body>
855
1034
 
856
1035
  </html>