Open jvolker opened 4 years ago
This is a nontrivial amount of computational geometry, unfortunately. The work would have to happen in flatten-svg.
@jvolker I think it's worth pointing out that ClipPath and masks are virtual features of SVG, which do not translate into CNC operations in a meaningful way because CNC machines work by moving along vector paths. ClipPath is only virtually hiding the paths / vertices and not really changing the SVG paths, so the machine cannot distinguish between clipPath and no clipPath.
In order to get the output desired, you'd need to actually modify the paths (trim, crop). I was working on a tool that can do that for you but never finished it.
You can check it out here: https://msurguy.github.io/svg-cropper-tool/
Thanks for your fast replies.
@nornagon feel free to transfer this issue to the flatten-svg repository.
@msurguy Thanks for explaining this in more detail. I am aware of the problem but am surprised there aren't more tools implementing this yet.
Thanks for mentioning your tool. When you are saying you've never finished it, what's still missing?
I did a little more research on this topic and found the following code fragments/projects that might be useful:
https://github.com/ubilabs/axidraw/blob/master/src/lib/crop-lines-by-bbox.js https://github.com/ubilabs/axidraw/blob/master/src/lib/crop-lines-by-circle.js
And these two: https://github.com/w8r/martinez/ (mentioned in https://github.com/svg/svgo/issues/680) https://github.com/velipso/polybooljs (used in https://daef.github.io/poly-bool-comparison/ -> https://github.com/w8r/martinez/issues/123)
@jvolker thank you, I'm fully aware of those algos + quite a few more since I had to implement clipping into my tool to be able to crop shapes. Did you try the tool?
What's not done in my tool (but could be done if somebody can contribute):
If you tried the tool - let me know what you think!
PS, @nornagon I'm using Flatten-SVG in the cropper tool :) thank you so much for it!
I've given some feedback in the other thread. Your tool looks really promising. Thanks for that.
I've realized manually removing vectors was far easier and closer to what I wanted using Illustrator compared Affinity. The "Lasso tool", "Erasor tool" and of course "Direct Selection Tool" of Illustrator can be helpful.
Also Affinity doesn't cut the paths:
Illustrator cuts the paths (closer to what I wanted to achieve):
I have no plans to work on this currently, but I'd be happy to review a PR from anyone that wants to take a crack at it!
@msurguy for your tool, are you using any other algorithms on top of what's shipped with https://github.com/junmer/clipper-lib? Thanks.
@jvolker I think we can move that conversation to this issue: https://github.com/msurguy/svg-cropper-tool/issues/5
At the moment clipPath is not used. Would be great to get support for it.
The following is an example using a circle a clipPath/mask.
Original file in Affinity Designer:
In saxi:
Source of SVG
``` ```I've also tried several methods and other software (Illustrator, Inkscape) to convert this clipPath/mask into lines. Without luck. I'm happy about any suggestions.
Thanks.