Skip to content

Refactor extrude extension

Closes #190 (closed)

The extrude extension has been refactored and fixed; instead of using CubicSuperPath which is not necessary in this case, we use the PathCommandProxy.

The extension works on all objects that can be converted to path, paths with multiple subpaths etc, and respects the stacking order. Code coverage is 99% (the only missed line is the one which aborts the extension).

I also added a new mode that makes more sense than the "Rectangle" mode: demo

Breaking change: Previously, the generated group / path was added as last child of the first element's parent, I changed it so it is inserted in between the two elements (which is a bit more sensible)

This merge request also includes some fixes to the PathCommandProxy code - previously, the coordinate computation was plain wrong:

path = Path("M 10 10 h 10 v 10 h -10 Z")
proxycommands = list(Path.proxy_iterator())
print(list(proxycommands[2].previous_end_point))

resulted in [20,20] because the Move command was applied twice.

This wasn't discovered by the tests - the entire PathCommandProxy stuff was only covered implicitly by tests for path.reverse which only used relative (lowercase) commands, so it didn't matter. Fixing this then broke the reverse command for relative ZoneClose which only worked for the incorrect coordinate computation. I added a unit test for the coordinate computation, but in general more tests for PathCommandProxy would be nice.

Also there was a mistake in the path reversal for arcs - a sweep flag of 1 was reversed to a flag of -1 which is invalid syntax and should be 0. This wasn't tested for at all (but is now through the unit tests for this extension).

Merge request reports