Improve and fix behaviour when collapsing straight paths segments (#146)

* Do not collapse straight path segments in paths that have intermediate markers (see #145). The intermediate nodes might be unnecessary for the shape of the path, but their markers would be lost.
* Collapse subpaths of moveto `m` and lineto `l` commands if they have the same direction (before we only collapsed horizontal/vertical `h`/`v` lineto commands)
* Attempt to collapse lineto `l` commands into a preceding moveto `m` command (these are then called "implicit lineto commands")
* Preserve empty path segments if they have `stroke-linecap` set to `round` or `square`. They render no visible line but a tiny dot or square.
This commit is contained in:
Eduard Braun 2017-05-18 00:53:25 +02:00 committed by GitHub
parent 75bacbc8e6
commit cc592c8e8a
6 changed files with 194 additions and 85 deletions

View file

@ -1,4 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg">
<path fill="none" stroke="#000" stroke-width="5" stroke-linecap="round" d="m 11,8 0,0" />
<path id="none" d="m0 0 0 0"/>
<path id="attr_butt" d="m0 0 0 0" stroke-linecap="butt"/>
<path id="attr_round" d="m0 0 0 0" stroke-linecap="round"/>
<path id="attr_square" d="m0 0 0 0" stroke-linecap="square"/>
<path id="style_butt" d="m0 0 0 0" style="stroke-linecap:butt"/>
<path id="style_round" d="m0 0 0 0" style="stroke-linecap:round"/>
<path id="style_square" d="m0 0 0 0" style="stroke-linecap:square"/>
</svg>

Before

Width:  |  Height:  |  Size: 195 B

After

Width:  |  Height:  |  Size: 522 B

Before After
Before After