3 ms·
Is there a library out there that allows you to make some of these manipulations in code? Like: translateX(svg, 10px), scale(svg, 10%), ConvertToRelative(svg),
by toufka 6y ago
Is there a library out there that allows you to make some of these manipulations in code? Like: translateX(svg, 10px), scale(svg, 10%), ConvertToRelative(svg), AutoBounds(svg), etc.
There are many that allow you to generate an svg, but it's been hard to find those that allow you to manipulate an existing svg.
- yqnn 6y agoYou can copy 'svg.ts' and 'svg-parser.ts', from here: https://github.com/Yqnn/svg-path-editor/tree/master/src/app https://github.com/Yqnn/svg-path-editor/tree/master/src/app It's what's used internally by the tool. const path = new Svg('M 0 0 L 1 1'); path.translate(1, 2); // Translates (x:1pt , y:2pt) path.scale(2, 3); // Scales (x:200%, y:300%) path.setRelative(true); // Converts the path to use only relative commands path.asString(); // Export the path with no minification path.asString(1, true); // Export the path with 4 decimals, and minification I wanted to publish them separately on npm, but didn't had time to do it :)
- toufka 6y agoVery cool! Thanks!