0

I want to create svg image with line going through circle, cropped to the circle.

So I

  • created a circle
  • turned it into a path
  • removed stroke from it, set black fill
  • centered in on the page (vertical and horizontal)
  • copied this circle
  • centered copy on the page
  • set gray fill for the copy
  • created path representing line across circle
  • selected line and circle
  • set red color on line, removed stroke
  • used path -> intersection
  • changed colour of created object

But the intersection is not accurate! Created path is not really reaching the circle edge!

enter image description here

Is it normal? Is it some bug? Running already in limitation of floating points? But I can improve it manually.

How can I get exact intersection of paths?

My input file is at https://gist.github.com/matkoniecz/d9d5570b92458657f157afa627a8bccf

I am aware of clipping but it is not always supported. For example in Lubuntu thumbnails (reported as bug at https://bugs.launchpad.net/ubuntu/+source/lubuntu-artwork/+bug/1952627 ).

3
  • A bezier curve can not perfectly describe a circle. Also a bezier curve can not perfectly describe another unless it has same node points. When you boolean your operating on one copy, you should back copy the boolean nodes to the original copy if you want to be accurate but offcourse nobody does that.
    – joojaa
    Nov 30 '21 at 1:28
  • "Also a bezier curve can not perfectly describe another" why that is relevant? Nov 30 '21 at 15:37
  • Because, you are complaining about what computer graphics programmers calls a tear. One way to avoid tears is to share nodes between adjoining shapes. So if the bezier on underlying shape does not share a node structure with overlapping shape then this is what you get.
    – joojaa
    Nov 30 '21 at 15:50
3

I can reproduce the issue, so you aren't imagining it.

After a bit of testing I noticed it only seems to affect objects with Bézier curves. I tried it on rectangles and the Intersection boolean operation works perfectly, so I suspect the inaccuracy is due to fact that Bézier curves are not capable of creating mathematically perfect circles, at least not perfect enough that you can zoom in fully and expect an exact match.

To check my theory, I also tried the same boolean operation in Adobe Illustrator (Pathfinder > Intersect), and the result is very similar. So, I'm going to say, it's probably not a bug, just a limitation with the accuracy of Béziers.

If you need accuracy like this, I'd suggest you use CAD software instead. Software such as Inkscape/Illustrator is designed for pretty graphics, not for engineering.

Workarounds are possible of course, for example you could use a clipping mask to clip the red rectangle instead of a boolean operation.

For example, using a copy of the circle as a clipping mask on the red rectangle (at full zoom)

enter image description here

5
  • If you need accuracy like this, I'd suggest you use CAD software instead. Software such as Inkscape/Illustrator is designed for pretty graphics, not for engineering. Sadly, it is a minimal reproducible example of editing a pretty graphic (SVG icon) Nov 28 '21 at 20:52
  • @reducingactivity - sure, but I've given a workaround to avoid it.
    – Billy Kerr
    Nov 28 '21 at 20:54
  • As I mentioned I am aware of this ability- and it is not viable. Tool that consumes SVGs that I will produce is not supporting clipping. Nov 28 '21 at 21:13
  • @reducingactivity but that's not the fault of Inkscape though, is it? Clipping masks are pretty standard in SVG. Looks like the only option left is to manually edit it.
    – Billy Kerr
    Nov 28 '21 at 21:24
  • Alternate construction is to add a node at intersection ofbith of the beziers then boolean. This way the edges wont tear out. This is a well known limitation of how computer maths work.
    – joojaa
    Nov 30 '21 at 1:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.