svg-path-simplify 0.4.0 → 0.4.2
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/CHANGELOG.md +14 -0
- package/README.md +36 -10
- package/dist/svg-path-simplify.esm.js +534 -167
- package/dist/svg-path-simplify.esm.min.js +2 -2
- package/dist/svg-path-simplify.js +534 -167
- package/dist/svg-path-simplify.min.js +2 -2
- package/dist/svg-path-simplify.pathdata.esm.js +40 -0
- package/dist/svg-path-simplify.pathdata.esm.min.js +2 -2
- package/index.html +82 -17
- package/package.json +5 -2
- package/src/pathSimplify-main.js +15 -4
- package/src/string_helpers.js +18 -0
- package/src/svgii/convert_units.js +8 -2
- package/src/svgii/pathData_convert.js +38 -0
- package/src/svgii/pathData_parse_els.js +135 -133
- package/src/svgii/svg-styles-to-attributes-const.js +2 -1
- package/src/svgii/svg_cleanup.js +328 -35
- package/src/svgii/svg_el_parse_style_props.js +35 -5
- package/tests/testSVG_shape.js +59 -0
- package/tests/testSVG_transform.js +61 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.4.2] - 2026-03-18
|
|
4
|
+
### Fixed
|
|
5
|
+
- attribute retrieval and conversion in node
|
|
6
|
+
- transform conversions
|
|
7
|
+
### Added
|
|
8
|
+
- mixed SVG path data: chooses between most compact commands – relative or absolute
|
|
9
|
+
- web UI features (e.g marker resizing, toggle original and optimized)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
## [0.4.1] - 2026-03-16
|
|
13
|
+
### Fixed
|
|
14
|
+
- null transform removal matrix(1 0 0 1 0 0)
|
|
15
|
+
|
|
16
|
+
|
|
3
17
|
## [0.4.0] - 2026-03-16
|
|
4
18
|
### Added
|
|
5
19
|
- convert transforms to hard coded geometry
|
package/README.md
CHANGED
|
@@ -15,26 +15,58 @@ While this library reduces SVG markup sizes significantly by removing commands i
|
|
|
15
15
|
Unlike most existing approaches (e.g in graphic applications), it checks where simplifications are suitable and stops simplification at the right »point« (literally).
|
|
16
16
|
|
|
17
17
|

|
|
18
|
-
*Fira Sans (based on truetype/glyph quadratic commands) converted to cubic
|
|
18
|
+
*Fira Sans (based on truetype/glyph quadratic commands) converted to cubic Béziers. Right:Original; Left:optimized*
|
|
19
19
|
|
|
20
|
-
## Features
|
|
21
|
-
|
|
20
|
+
## Features
|
|
21
|
+
### Path simplification
|
|
22
|
+
* reduces the number of SVG commands (both Béziers and lines) by converting/combining adjacent:
|
|
22
23
|
* Béziers (`C`, `Q`)
|
|
23
24
|
* flat Béziers to Linetos
|
|
24
25
|
* colinear lines (`L`)
|
|
26
|
+
* converts cubic Béziers which can be expressed as more compact quadratic
|
|
25
27
|
|
|
26
28
|
* reorders path starting points to replace unnecessary closing linetos by `Z` commands
|
|
27
29
|
* optimizes SVG file size by contextually converting to:
|
|
28
30
|
* shorthand commands (`C` => `S`, `Q` => `T`, `L`=>`H` or `V`)
|
|
29
31
|
* cubics to quadratic Béziers (only 1 control point)
|
|
30
|
-
* cubic arc-like segments to `A` (elliptic arc)
|
|
32
|
+
* cubic arc-like segments to `A` (elliptic arc) and `rx`, `ry` radii optimization for semi-circle segments
|
|
31
33
|
|
|
34
|
+
### Coordinate rounding
|
|
32
35
|
* adaptive coordinate rounding: small or large details can be auto-detected to find a suitable floating point accuracy without guessing the decimal value (3 decimals may not be the silver bullet=)
|
|
36
|
+
|
|
37
|
+
### SVG optimization
|
|
38
|
+
Cleanup for:
|
|
39
|
+
* meta data
|
|
40
|
+
* namespaced attributes or elements
|
|
41
|
+
* convert `xlink:href` to `href` and vice-versa
|
|
42
|
+
* move `defs` to the top
|
|
43
|
+
* remove futile `<clipPath>` defs spanning across the entire viewBox
|
|
44
|
+
* convert styles to presentation attributes
|
|
45
|
+
|
|
46
|
+
### Shape conversions
|
|
47
|
+
* convert shapes such as `<circle>`, `<ellipse>`, `<rect>` etc. to `<path>` – supports relative `%` or physical units like `mm`
|
|
48
|
+
* convert paths to shapes – if applicable
|
|
49
|
+
|
|
50
|
+
### Polygons
|
|
51
|
+
* convert paths to polygons
|
|
52
|
+
* reduce poly vertices
|
|
53
|
+
* convert/smooth polygons to curved path data
|
|
54
|
+
|
|
55
|
+
### Transforms
|
|
56
|
+
* convert transforms to hard-coded path data
|
|
57
|
+
* scale SVGs to desired output size
|
|
58
|
+
|
|
59
|
+
### Path directions
|
|
60
|
+
* reverse path drawing directions
|
|
61
|
+
* auto-fix compound path directions to comply with non-zero fill rules
|
|
62
|
+
|
|
63
|
+
### Additional features
|
|
33
64
|
* split segments at extremes – only useful for manual editing
|
|
34
65
|
* optimize either path data strings or SVG markup code
|
|
35
66
|
* create curves from polylines (curve-fitting)
|
|
36
67
|
|
|
37
68
|
|
|
69
|
+
|
|
38
70
|
## TOC
|
|
39
71
|
* [Usage](#usage)
|
|
40
72
|
+ [Browser](#browser)
|
|
@@ -44,12 +76,6 @@ Unlike most existing approaches (e.g in graphic applications), it checks where s
|
|
|
44
76
|
- [Example 2: Apply options](#example-2-apply-options)
|
|
45
77
|
+ [Web worker](#web-worker)
|
|
46
78
|
* [API](#api)
|
|
47
|
-
+ [Simplification parameters](#simplification-parameters)
|
|
48
|
-
+ [Advanced simplifications](#advanced-simplifications)
|
|
49
|
-
+ [Output options](#output-options)
|
|
50
|
-
+ [SVG scaling](#svg-scaling)
|
|
51
|
-
+ [SVG output optimizations](#svg-output-optimizations)
|
|
52
|
-
+ [SVG input normalization](#svg-input-normalization)
|
|
53
79
|
* [Lite version](#lite-version--only-path-data)
|
|
54
80
|
* [Demos](#demos)
|
|
55
81
|
+ [Web app](#web-app)
|