A plugin for the svgdotjs.github.io library to modify SVG paths. The core of this plugin is based on simplify-js (c) 2017, Vladimir Agafonkin
npm install svg.pathmod.js
If you don't see image below look at this page on https://janmisker.github.io/svg.pathmod.js/, because inline SVG might be disabled.
Quickest to just show it. First image is a path with 133 points, for example drawn by user. Second image is the simplified version of that path.
var svg = SVG().addTo('#drawing').size(100,100)
var path = svg.path(....) // create a path
path.simplify(1, true)
The simplified version has only 16 points, making it much more lightweight, and it also looks better. There are of course parameters, for example using a tolerance of 5 and not employing the radial distance algorithm this is the result:
path.simplify(5, false)
Do note that the path is modified in place, if you need to keep hold of the existing path make sure to clone it first.
svg.pathmod.js is licensed under the terms of the MIT License.
This module requires svg.js >= v3.0.12