abey79 / vpype

The Swiss-Army-knife command-line tool for plotter vector graphics.
https://vpype.readthedocs.io/
MIT License
687 stars 61 forks source link

Request: Splitdist with overlapping segments #600

Open erinrrobinson opened 1 year ago

erinrrobinson commented 1 year ago

It would be great to have a feature that when splitting lines by distance creates some overlap for painting to create the illusion of a smoother continuous line. For example, if the lines are split by a distance of 5cm, to extend all lines except the last one by 1cm so that they overlap. This will reduce the issues of weakening the paint stream over time. Going to have a go at implementing this on my local machine today but I'm not very good at under-the-hood stuff so thought I'd make a request!

abey79 commented 1 year ago

The way this is currently is that input lines are not cut to fit the distance budget. Rather they are kept whole, and simply sorted across many layer. This makes it tricker to implement overlap, because there is no guarantee that extending one line would overlap the next line.

An alternative implementation of splitdist where lines are actually cut precisely when the distance budget is exhausted would make it easier, as the splitting could be done such are leaving some overlap. I would certainly consider such a PR :)

erinrrobinson commented 1 year ago

Using svgpathtools I've written a seperate script which can split an svg by distance, overlapping the lines by an offset amount (not perfect but proof of concept) to the same layer. Is there a way with vpype to append each path with a another path(s) thats been implemented, but on the same layer? It's possible with svgpathtools but doesn't offer any layout options which makes it exceedingly difficult to put a path in the right spot for a paint pot.

If I get this to work I'd be happy to make a PR and write it up properly!

abey79 commented 1 year ago

I'm not sure exactly I understand exactly what you mean. In vpype, layers are basically glorified list of 1-dimensional numpy arrays of complex (where the imaginary part stands for the y axis). In a command you can manipulate the content of a layer however you like. To create a command, you can fork vpype and edit, e.g., splitdist or create a new command, or make a plug-in.

Edit: I'm happy to assist with the details, but discord might be a better place for that :)