37

I've attempted (as a test) to make a circle with a bar going through it. The bar should go under one side of the circle and over the other.

I've done this by splitting the circle into two objects, however there are visible seams where the split was done, even though the paths match up exactly.

enter image description here

Also, the shadow under the left part of the circle doesn't go on top of the bar like it ought to, and I can't think of any way to fix this without splitting the shadow object too.

Is there a better way to do this?


If needed I can also upload the svg.

  • 2
    Have you tried splitting the bar? Also, make sure you're not in a fractional zoom amount, as they sometimes affect the rendering of lines and line joints. – Johnny Kutnowski Oct 21 '14 at 9:19
  • What software are you using? Illustrator? – Henrik Ekblom Oct 21 '14 at 9:25
  • 1
    A mixed superimposition of the object is not allowed in Inkscape, but you can proceed in several ways. The fastest probably is cut the circle where is covered by the bar (the cut is straight). Alternately you can move more accurately the junction points (seams should not be visible: probably the problem was in the way you cut the circle). – Paolo Gibellini Oct 21 '14 at 9:49
  • 2
    P.S. The alignment of the edges seems to be a Inkscape problem (see here, here and here). And see also Inkscape FAQ about antialiasing: Snap your horizontal/vertical edges on the pixel grid, and use strokes of a whole number of pixels wide. Export bitmap at 90dpi so that 1 px unit corresponds to 1 bitmap pixel – Paolo Gibellini Oct 21 '14 at 10:18
  • @JohnnyKutnowski It does change with zoom, sometimes the split almost goes away. However it's very visible at 1:1 zoom. – gandalf3 Oct 21 '14 at 19:42
41

The gap you see is due to an imperfect rendering by Inkscape and not necessarily a problem depending on how you export or use your SVG (as long as you cut precisely). The shadows however will likely cause problems, when cut up (which is the only way I can think of to make them right).

Here is my solution to this. As an example, I cut up a plain bar, because it’s easier. But cutting up the outer circles has some advantage, which I will mention later. First an image:

Some overlay techniques

The left uses transparent objects (one blue, one red) for demonstration, the right shows the result.

  • In the top, I reproduced what you did and just cut my bar. This leads to the aforementioned gap on some zoom levels or pixel exports (it may also happen in some PDF renderers or similar).
  • In the middle, I let the two halves of the bar overlap, which avoids the gap but lets the bar appear slightly thicker around the cut (you may have to zoom in to see this).
  • In the bottom, I used what I recommend to do¹. The biggest overlap is half the bar’s width. I could not find any zoom level or export for which this produced an undesired aliasing effect (i.e., a gap or a thickened bar).

Now, let’s have a look at the shadows:

enter image description here

The order is the same as above. On the right, we have the shadows alone for better illustration.

  • The shadow for the simple cut looks okay, but we can see, that it’s somewhat weaker at the cutting position. This becomes more of a problem for fuzzier shadows.
  • In the middle, we have a significant problem.
  • In the bottom, we can make out the position of the cut, but the shadow is neither weaker nor stronger, just distributed differently. In particular, it does not get any worse, if the shadow gets fuzzier. The cut is even less visible, if it does not happen on a straight segment, which is why it may be advantageous better for you to cut the circles instead of the middle bar.

¹ You can achieve this as follows:

  1. Make the cut as normal.
  2. Add a node in the middle of each cut edge.
  3. Move each node outwards by one quarter of the width² of whatever you cut.

² For this value, I empirically found the distortion of the shadow to be lowest.

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.