Minor change to actually cover the case where a line segment doe not point into the same direction.

Also increases coverage by explicitly optimizing a lineto command (instead of only "implicit lineto", i.e. effectively moveto, commands)
This commit is contained in:
Eduard Braun 2017-05-18 00:38:16 +02:00
parent 44cd072e37
commit df3a3ccc5b
2 changed files with 4 additions and 3 deletions

View file

@ -1240,7 +1240,7 @@ class CollapseStraightPathSegments(unittest.TestCase):
'm0 0h10 20', 'm0 0h10 20',
'm0 0h10 20', 'm0 0h10 20',
'm0 0h10 20', 'm0 0h10 20',
'm0 0 20 40', 'm0 0 20 40v1l10 20',
'm0 0 10 10-20-20 10 10-20-20', 'm0 0 10 10-20-20 10 10-20-20',
'm0 0 1 2m1 2 2 4m1 2 2 4', 'm0 0 1 2m1 2 2 4m1 2 2 4',
'm6.3228 7.1547 81.198 45.258'] 'm6.3228 7.1547 81.198 45.258']

View file

@ -21,8 +21,9 @@
<path d="m0 0h10 20" style="marker:url(#dot)"/> <path d="m0 0h10 20" style="marker:url(#dot)"/>
<path d="m0 0h10 20" style="marker-mid:url(#dot)"/> <path d="m0 0h10 20" style="marker-mid:url(#dot)"/>
<!-- all lineto commands should be collapsed into a single (implicit if possible) lineto command --> <!-- all consecutive lineto commands pointing into the sam direction
<path d="m 0 0 l 10 20 0.25 0.5 l 0.75 1.5 l 5 10 0.2 0.4 l 3 6 0.8 1.6"/> should be collapsed into a single (implicit if possible) lineto command -->
<path d="m 0 0 l 10 20 0.25 0.5 l 0.75 1.5 l 5 10 0.2 0.4 l 3 6 0.8 1.6 l 0 1 l 1 2 9 18"/>
<!-- must not be collapsed (same slope, but different direction) --> <!-- must not be collapsed (same slope, but different direction) -->
<path d="m 0 0 10 10 -20 -20 l 10 10 -20 -20"/> <path d="m 0 0 10 10 -20 -20 l 10 10 -20 -20"/>
<!-- first parameter pair of a moveto subpath must not be collapsed as it's not drawn on canvas --> <!-- first parameter pair of a moveto subpath must not be collapsed as it's not drawn on canvas -->

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Before After
Before After