Overlapping graphic primitives

As the only workaround seems to be to turn it to a Polygon, here is a way. The idea is to merge the graphics objects and to extract its boundary coordinates using existing tools:

Your rod can be simply defined as two disks + a rectangle:

rod = {Disk[{-l/2 + r, 0}, r], Disk[{l/2 - r, 0}, r], 
Rectangle[{-l/2 + r, -r}, {l/2 - r, r}]} /. {l -> 3, r -> .6};

Then this seems pretty smooth at any size / magnification :

Graphics[{Opacity[0.1],
Polygon@MeshCoordinates@BoundaryDiscretizeRegion[RegionUnion @@ rod, AccuracyGoal -> 3]}]

Blockquote


In practice, there isn't much you can do to stitch together multiple transparent graphics primitives with no artefacts. The better solution is to have a single object.

Looking at the coordinates, the alignment of your objects is clearly perfect. The problem is with how they are rendered on screen, not with how they are constructed. The misalignment happens due to rounding to integer pixel coordinates, and is a common problem with the display of vector graphics. Sadly, Mathematica is not very good at handling rounding in these cases, but it is by no means alone in this. I expect that if you export this figure to PDF, some PDF readers will show the artefacts and some will not. Preview.app on Mac does not show them while Adobe Reader shows very subtle lines. I also expect differences between platforms.

The best practical solution is to have a single Polygon object that approximates this shape.


One exception is when all your objects are Polygons contained within a single GraphicsComplex. These are stitchable without artefacts. On OS X, it is necessary to use the Graphics option Method -> {"TransparentPolygonMesh" -> True} to make them render correctly.


In versions 10.2+, you can use StadiumShape to get a single primitive that gives the same shape as your rod:

rodF[l_, r_] := {Opacity[.1],StadiumShape[{{-l/2 + r,0}, {l/2 - r, 0}}, r]}

Graphics[rodF[3,.5]]

enter image description here