svgpathtools
svgpathtools copied to clipboard
Create relatives path instead of absolute.
Is there anyway to get out svg to generate a relative path instead of an absolute one?
Instead of this:
<path d="M 0.0,1.0 L 2.0,1.0 L 3.0,2.0" fill="none" stroke="#000000" stroke-width="1.175"/>
something like this:
<path d="m 18.815667,1 h 2 l 1,1" fill="none" stroke="#000000" stroke-width="1.175"/>
@Cabalist Nope. This is not a current feature. I agree it would be nice though.
@mathandy I would like to be able to generate paths, and parse paths from existing SVG's whilst keeping the relative path points, also please. I wondered if this planned or in progress? Thanks Wayne
Hey @WayneKeenan, if I'm understanding correctly, this is an output problem right? The new (still experimental) Document module allows unmodified paths to be left alone.
Any path imported to an svgpathtools.Path, however, will then be exported using the Path.d() method.
If someone wants to add support to the Path.d() method for outputting relative paths, and then add an attribute to the Path class to remember/set this preference; that'd be great.
As always, unittests would be required to check the new functionality (and any functionality this new code could reasonably break).
The code in svgelements tends to support full end-to-end. Basically you can flag each pathsegment with a flag for being relative. This is set during the parsing process. When writing out the code again with the .d() we either use the form set there. And d() attribute can override this and force a relative path or force an absolute path and the default is simply the original parsed values as set. So each segment is either relative(True) relative(False) or relative(None). And same for the use of d(relative=True), d(relative=False), d(relative=None)