@inkscape I'm writing an Inkscape extension using Python Inkex, and I need to know if the contour of two vectors overlap. I'm very much a beginner with Inkex, so I've been using the bounding boxes so far, and it works after a fashion, but of course this produces weird results when a smaller shape is within the bounding-box of a larger shape, but they don't actually overlap. So I need to work out if they really DO overlap, so I can then deal with them appropriately. Can anyone tell me if it's possible to either ascertain if two vectors overlap via the API, or short of that, how to get a raster of pixels of a vector rendered (at any resolution) so I can convert that to a set, and can then check for intersection?
Sorry, I don't even know if this question makes sense, so for context, I'm trying to change the z-order of shapes that are enclosed by larger shapes so that they are lower than the enclosing shape(s), because I use Inkscape to design SVGs for #LaserCutting, and you need to cut internal vectors before their enclosing vectors. Lasers on laser cutters have a focal length, and you have to set the focus before you cut; when the laser has completed a closed cut, the material is apt to drop down by a few millimetres, and the laser is then no longer focused properly on it, so any internal vectors cut after this has happened will be out of focus and may not cut through properly.
=> More informations about this toot | More toots from cybervegan@autistics.life
@inkscape Update 4. It's now working properly: it always places enclosed shapes - defined by the enclosed shape's contour being within the continuous contour of the enclosing shape - lower in z-order than their enclosing shape; it also orders multiple contained shapes by proximity, recursively, in an attempt to minimise laser head zig-zagging. I now need to tidy it up and refactor it, and remove all of the debugging output!
It calls inkscape in shell mode to determine the contour overlaps (builds a script, pipes it into Inkscape, then parses the output). Inkscape is only called in this way ONCE per invocation of the plugin.
Thanks for all the valuable pointers - it all helped.
=> More informations about this toot | More toots from cybervegan@autistics.life
@cybervegan Congrats! 🎉
=> More informations about this toot | More toots from inkscape@mastodon.art This content has been proxied by September (3851b).Proxy Information
text/gemini