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.

I need to draw a two-colored circle split, exactly as is specified in the section 39.6 of the manual for rectangle splits, meaning that one half of the circle split has one fill color and the other half a different fill color. I have to rotate it afterwards, but that is not a problem.

For rectangle splits is seems to be as easy as adding the option rectangle split part fill={red, blue} in the definition. Is there a similar way to multiple-color circle splits?

Greetings from Chile,
Marcelo.

share|improve this question
    
no the option circle split part fill does not exist. –  Alain Matthes May 13 '12 at 4:44
add comment

1 Answer

up vote 19 down vote accepted

Final code

Correction of bugs

1) \begin{scope}[on background layer] is not useful.

2) Instead of \insiderad-0.5\pgflinewidth, the correct code is \insiderad-\pgflinewidth

The style circle split part fill needs two colors like in circle split part fill={blue!50,red!50}

Here a complete example

\documentclass[11pt]{scrartcl}
\usepackage{tikz}
\usetikzlibrary{shapes,backgrounds,calc}

\makeatletter
\tikzset{circle split part fill/.style  args={#1,#2}{%
 alias=tmp@name, % Jake's idea !!
  postaction={%
    insert path={
     \pgfextra{% 
     \pgfpointdiff{\pgfpointanchor{\pgf@node@name}{center}}%
                  {\pgfpointanchor{\pgf@node@name}{east}}%            
     \pgfmathsetmacro\insiderad{\pgf@x}
      %\begin{scope}[on background layer]
      %\fill[#1] (\pgf@node@name.base) ([xshift=-\pgflinewidth]\pgf@node@name.east) arc
      %                    (0:180:\insiderad-0.5\pgflinewidth)--cycle;
      %\fill[#2] (\pgf@node@name.base) ([xshift=\pgflinewidth]\pgf@node@name.west)  arc
      %                     (180:360:\insiderad-0.5\pgflinewidth)--cycle;  
      \fill[#1] (\pgf@node@name.base) ([xshift=-\pgflinewidth]\pgf@node@name.east) arc
                          (0:180:\insiderad-\pgflinewidth)--cycle;
      \fill[#2] (\pgf@node@name.base) ([xshift=\pgflinewidth]\pgf@node@name.west)  arc
                           (180:360:\insiderad-\pgflinewidth)--cycle;            %  \end{scope}   
         }}}}}  
 \makeatother  

\begin{document}

\Huge  

\begin{tikzpicture}
  \node[shape=circle split,
    draw=gray!40,
    line width=1mm,text=white,font=\bfseries,
    circle split part fill={blue!50,red!50}
    ] at (5,5) {text\nodepart{lower}lower};
 \end{tikzpicture} 
 \begin{tikzpicture}
 \node[name=s,
    shape=circle split,
    draw=gray!40,
    line width=10mm, minimum width =5cm,
    circle split part fill={blue!50,red!50}
    ] at (5,5) {text\nodepart{lower}lower};
\end{tikzpicture}
\begin{tikzpicture}
\node[name=s,
    shape=circle split,
    draw=gray!40,line width=2mm,
    circle split part fill={blue!50,red!50}
    ] at (5,5) {Big text\nodepart{lower} very big lower};
\end{tikzpicture} 
\end{document} 

enter image description here

A workaround (the first idea):

\documentclass[11pt]{scrartcl}
\usepackage{tikz}
\usetikzlibrary{shapes,backgrounds,calc}

\begin{document}

\Huge
\begin{tikzpicture}
  \node[name=s,shape=circle split,draw=gray!40,line width=4mm,minimum size=8cm] {text\nodepart{lower}lower};
  \foreach \anchor/\placement in
    {north west/above left, north/above, north east/above right,
     west/left, center/below, east/right,
     mid west/right, mid/above, mid east/left,
     base west/left, base/below, base east/right,
     south west/below left, south/below, south east/below right,
     text/left, lower/left, 130/above}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}}; 

\begin{scope}[on background layer]
    \fill[blue!50] (s.base) ([xshift=-4mm]s.east) arc (0:180:4cm-2mm)--cycle;
    \fill[red!50] (s.base) ([xshift=4mm]s.west) arc (180:360:4cm-2mm)--cycle;  
\end{scope}
\end{tikzpicture}
\end{document}

enter image description here

It's not easy to make a style from this code. Finally it was possible !

share|improve this answer
    
You are right. I tried it but I got an error perhaps with a problem of syntax. Thanks ! –  Alain Matthes May 13 '12 at 10:48
    
Wow, this is just awesome. It worked perfectly. Thanks a lot @Altermundus! –  Marcelo Figueroa May 13 '12 at 14:39
    
Thanks, but I corrected several bugs and modified the code several times, perhaps small bugs also may still exist. –  Alain Matthes May 13 '12 at 15:20
    
@AlainMatthes: this is quite handy, however it does not accept none as a fill, could you point me to a solution for that? ANy chance this makes it into TikZ? –  ted Jun 24 '13 at 8:40
add comment

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.