SVG Path Editor
yqnn.github.io
yqnn.github.io
I’m pleased to see that the minification doesn’t put a space after the “0” or “1” of large-arc-flag and sweep-flag; historically I’ve found most minification tools doing so, and even some tools failing to parse `a1 2 3 104 5` (arc: rx=1, ry=2, x-axis-rotation=3, large-arc-flag enabled, sweep-flag disabled, dx=4, dy=5).
One missing optimisation is culling superfluous path commands. If you have two commands of the same type in a row, you don’t need to repeat the letter: `L1 2L-3 4` can become just `L1 2-3 4`; also, after the initial M or m command, it switches to L or l automatically, so in `M1 2L-3 4` the L could be removed.
An area I’d really like to see more work in (in SVG tooling in general) is path simplification/minification. In automated tools I’ve only seen rounding to a fixed number of decimal places, which is what this tool is offering, and which is terrible: some decimal places are far more significant than others, and indeed some points could be happily dropped, and rounding everything is not always the correct behaviour for fidelity. Instead of “two decimal places”, I’d like to see things like “accurate to within one pixel in any given direction”, which I reckon will normally compress better for a given quality level. There’s also the approach taken by Inkscape’s path simplification, which chooses a completely new set of points and curves that approximate the current values, but this harms the accuracy of the path and isn’t flexible enough (you run it in discrete steps, rather than there being a continuous slider or the ability to simplify some sections harder than others, whether automatically for best accuracy or manually).
We could do with some help on the accuracy of some of them :-)
I found a related article: https://news.ycombinator.com/item?id=14310652
Not forgetting compression too as it makes a huge impact on big enough SVG: Firefox goes from 1024 (not 1023?) to 522 bytes, HN goes from 229 to 208.
That depends on the transport, this is one of the things that HTTP/2 (and HTTP/3) aim to fix by downloading them in parallel in a single connection.
Watch the devtools network tab: http://www.http2demo.io/
[0]: https://camo.githubusercontent.com/d0518022b7a02d405ad5112a0...
[1]: https://blog.cloudflare.com/hpack-the-silent-killer-feature-...
Any Tips and Tricks would be appreciated.
Despite the repo description, it's a universally useful SVG library
I wonder what you think about SVGOMG: https://jakearchibald.github.io/svgomg/
Could you please point me to some resource where the kind of abbreviation you show in the arc example are specified? I googled and couldn't find it.
Thanks!
https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d
https://www.w3.org/TR/SVG11/paths.html#PathData (SVG 1.1 spec) or https://svgwg.org/svg2-draft/paths.html#DProperty (SVG 2 spec); the two are much of a muchness.
Perhaps of interest, one of our devs poked at native JS approach for a while- https://github.com/SpeciesFileGroup/svg-detailer/. It definitely needs some code cleanup prior to production readiness, but it illustrates our needs/thought process.
Thanks for sharing !
Tools like Sketch are a little intimidating to start learning and I'm not even sure if they expose things like path commands.
My hobby is plotting (AxiDraw) generative art. I often want to hand tweak SVGs prior to plotting them. I often get frustrated with the heavy weight tools such as InkScape and Illustrator.
This looks like just the thing I need. Looking forward to trying it out this weekend!
Especially for the Sciter (and now Sciter.JS [1]) where we can use SVG paths directly in CSS as vector images:
input.radio {
background-image: url(path: M 4 8 L 10 1 L 13 0);
background-size: 1em;
stroke: black;
stroke-width: 3px;
}
More details are here: https://sciter.com/lightweight-inline-vector-images-in-scite...[1] Sciter.JS preview: https://github.com/c-smile/sciter-js-sdk
Meta: link [1] uses text-fragments [2] that seem super useful to me but apparently are not implemented by Firefox (yet!)
1: https://diveinto.html5doctor.com/past.html#:~:text=original%...
As of <include> (so called client side includes) Sciter has them [1] as they make sense in precisely desktop environments - when files included from local sources (synchronously).
[1] <include> in Sciter: https://sciter.com/forums/topic/import-html-in-html/
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.
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 :)0 = https://svg-edit.github.io/svgedit/dist/editor/index.html
Looks great, though :P
- copy/paste-in-place introduces minor deviations.
- I can never be sure if copy/paste/move will change path values or do it as a transformation.
- I don't do it often and forget to turn off path auto-minification; it's a real pain to have inkscape constantly shift between relative accumulating coordinates and absolute coordinates.
It's here: https://github.com/Yqnn/svg-path-editor/blob/master/src/app/...