[Tex/LaTex] TikZ borders showing through when they shouldn’t (overlapping circles)

graphicstikz-pgf

If you draw two circles that are exactly the same in all aspects (location, size, etc…) except they have different colors, then the "border" of the underlying circle is showing through.

\documentclass[10pt]{book}
\usepackage{xcolor}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
    \fill (0,0) circle (0.1);
    \fill[color=red] (0,0) circle (0.1);
    \fill[color=red] (0.5,0) circle (0.1);
\end{tikzpicture}
\end{document}

Notice the first circle has a black "edge" around it that looks different than the 2nd circle which doesn't.

The problem is due to the fact that one is anti-aliasing both circles and the edge colors are being blended.

Is there a way to fix this but still have anti-aliasing? (basically render all the objects I need then anti-alias them properly afterwards?)

(I realize TikZ probably can't do anything about this but one doesn't know unless they ask)

Best Answer

The anti-aliasing operation is global and made by PDF renderer.

Here, your example:

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
    \fill (0,0) circle (0.1);
    \fill[color=yellow] (0,0) circle (0.1);
    \fill[color=yellow] (0.21,0) circle (0.1);
\end{tikzpicture}
\end{document}

The bitmap result produced by this command:

pdftoppm -r 900 example.pdf | pnmtopng > example.png

enter image description here

The bitmap result produced by the following command (the aaVector option allows to enable or disable vector anti-aliasing):

pdftoppm -r 900 -aaVector no example.pdf | pnmtopng > example.png

enter image description here

With Adobe Reader, you can enable or disable anti-aliasing: Preferences>>Page Display>>Smooth line art

Evince does not offer an option to disable the anti-aliasing.