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

@ -2,10 +2,10 @@
<svg xmlns="http://www.w3.org/2000/svg">
<path id="p0" d="M 100.0000001 99.9999999 h100.01 v123456789.123456789 h-100 z" />
<path id="p1" d="m 1 12 123 1234 12345 123456 " />
<path id="p2" d="m 1.0 12.0 123.0 1234.0 12345.0 123456.0" />
<path id="p3" d="m 01 012 0123 01234 012345 0123456 " />
<path id="p4" d="m -1 -12 -123 -1234 -12345 -123456 " />
<path id="p1" d="m 1 21 321 4321 54321 654321 " />
<path id="p2" d="m 1.0 21.0 321.0 4321.0 54321.0 654321.0" />
<path id="p3" d="m 01 021 0321 04321 054321 0654321 " />
<path id="p4" d="m -1 -21 -321 -4321 -54321 -654321 " />
<path id="p6" d="m 123.456 101.001 -123.456 -101.001" />
</svg>

Before

Width:  |  Height:  |  Size: 517 B

After

Width:  |  Height:  |  Size: 517 B

Before After
Before After