bezierjs
bezierjs copied to clipboard
add in SVG parsing
The old SVG parsing was throwaway code and was never part of the public API. I've ripped it out so so it can be done properly. An implementation task list:
- [ ] PolyBezier.fromSVG(path) for accepting a full path
- [ ] convert any line (LVH) into a quadratic
{S, (S+E)/2, E}
- [ ] convert any elliptical arc (A) into one or more cubics
- [ ] convert any line (LVH) into a quadratic
- [ ] Bezier.fromSVG(pathsegment) for accepting individual curves (note that arcs cannot be supported by this call)
- [ ] PolyBezier.toSVG(), as aggregate call for all contained Bezier objects
- [ ] remember to replace
a b M a b
with justa b
(because each Bezier toSVG() starts withM
)
- [ ] remember to replace
- [x] Bezier.toSVG(), already implemented
To make this easier, path normalization can be taken from https://github.com/Pomax/svg-path-reverse/blob/gh-pages/reverse.js
https://github.com/thednp/svg-path-commander has implemented a lot of this.
But does way more than is needed here, and at almost 10x the size of this library, definitely not happening.