Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Here is the source code:

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
    \draw (0, 0) circle (1cm);
    \path[fill=black] (90:1cm) arc (90:270:1cm);
    \path[fill=black] (0:0cm) arc (-90:90:.5cm);
    \path[fill=white] (0:0cm) arc (90:270:.5cm);
    \path[fill=white] (0, .5) circle (.1cm);
    \path[fill=black] (0, -.5) circle (.1cm);
\end{tikzpicture}

\begin{tikzpicture}
    \draw (0, 0) circle (1cm);
    \filldraw[color=black] (90:1cm) arc (90:270:1cm);
    \fill[color=black] (0, .5) circle (.5cm);
    \fill[color=white] (0, -.5) circle (.5cm);
    \fill[color=white] (0, .5) circle (.1cm);
    \fill[color=black] (0, -.5) circle (.1cm);
\end{tikzpicture}

\end{document}

enter image description here

Both approaches should work, but apparently the first one has some flaws, why?

share|improve this question
1  
It's not a border, it's a rendering mistake of your PDF viewer, basically based on rounding errors. –  yo' Oct 20 '13 at 20:10
    
Indeed, and this disappears when zoomed in. –  qed Oct 20 '13 at 20:12

2 Answers 2

up vote 5 down vote accepted

While this may be a rounding errror,it can still be annoying. It's also an artifact of the manner in which you constructed your symbol since you draw and fill a semi-circle. Instead you can do something along the lines of:

\documentclass{article}
\usepackage{tikz}
\begin{document}

    \begin{tikzpicture}
      \draw (0, 0) circle (1cm);
      \path[fill=black] (90:1cm) arc (90:-90:0.5cm)
                        (0,0)    arc (90:270:0.5cm)
                        (0,-1cm) arc (-90:-270:1cm);
      \path[fill=white] (0, 0.5) circle (0.1cm);
      \path[fill=black] (0,-0.5) circle (0.1cm);
    \end{tikzpicture}

\end{document}

enter image description here

share|improve this answer
1  
Well, qed is doing something like this in the second picture, I suppose that it was just an example to show the deeper problem. –  yo' Oct 20 '13 at 20:26
1  
@tohecz I noticed that. But I thought the OP could benefit from seeing how to draw and fill the tear-drop portion without having to do it in several parts. –  A.Ellett Oct 20 '13 at 20:28

Or, you do it in one path:

Code

\documentclass[tikz]{standalone}
\tikzset{
  YinYang/.style={insert path={{[even odd rule, start angle=90, delta angle=180]
    coordinate (@aux) circle              [radius={#1}]
    arc                                   [radius={(#1)/2}]
    arc                                   [radius={#1},     start angle=270]
    arc                                   [radius={(#1)/2}, delta angle=-180]
    ([shift=(down:{(#1)/2})] @aux) circle [radius={(#1)/10}]
    ([shift=(  up:{(#1)/2})] @aux) circle [radius={(#1)/10}]
    % doing the big circle as an edge allows us to only draw that and only fill the rest
    (@aux) edge[to path={circle [radius={#1}]}] ()}}}}
\begin{document}
\tikz\fill[YinYang=1];
\tikz\fill[
    draw=white, every edge/.style,
    even odd rule, inner color=red,  outer color=blue,
    preaction    ={inner color=blue, outer color=red },
    % the preaction uses nonzero rule, so it is essentially only the full circle.
  ] [YinYang=-1];% negative raduius flips the two halves
\end{document}

Output

enter image description hereenter image description here

share|improve this answer
    
Nice! How does @aux work? I could not find it in the manual... –  Bordaigorl Oct 21 '13 at 10:10
    
@Bordaigorl @aux is just the name of the coordinate I use later. –  Qrrbrbirlbel Oct 21 '13 at 15:07
    
Oh now I see! I thought it was set to the current coord internally but I see now you name the coordinate before drawing the first circle. Thanks! –  Bordaigorl Oct 21 '13 at 18:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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