6

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)

8
  • This doesn't happen for me on Acrobat Reader 9. What viewer are you using? On a side note, TikZ already loads xcolor so there is no need to do so yourself separately. Mar 27, 2012 at 10:23
  • I can reproduce this using the PDF viewer in TeXmaker, evince, and ghostview, all on Ubuntu.
    – Jake
    Mar 27, 2012 at 10:28
  • The problem appears on OS X with Skim and Adobe reader but it's more easy to see it with fill=yellow. We need to remove anti-aliasing in Skim and Reader to remove the problem. Mar 27, 2012 at 11:32
  • This is pretty similar to your question on pixel blending. In both, you want to separate components of how the picture is rendered but it looks extremely unlikely that this can be done. In any case, this is handled by the program that renders the PDF and so there will be a limit on what TikZ can achieve. I'm not sure what you are trying to achieve with these questions, but it sounds as though your difficulties are more with the restrictions on the PDF format than with TikZ/PGF. Perhaps you should do your drawings in a graphics program and export to a bitmap. Mar 27, 2012 at 17:21
  • @AndrewStacey Well, I'm using Tikz so while it may not be the source of the problem it is the conduit. I've already written most of the code to do what I want in tex and need to clean it up and it is easier to do it inside tex than deal with including images(since I'm generating the "images" on the fly and they can be changed easily). I could potentially create an external program to generate the images and be called from tex but that's more work. Surely there is a way to stop anti-aliasing in tikz then anti-alias the picture?
    – Uiy
    Mar 27, 2012 at 22:39

1 Answer 1

9

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .