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 an example document and the output I get from it.

\documentclass[convert={size=480}]{standalone}

\usepackage{tikz}

\tikzset{ little circle/.style = { fill = black,
                                   shape = circle,
                                   minimum size = 1.5mm,
                                   inner sep = 0mm,
                                   outer sep = 0mm},
          concentric circles/.style = {draw = gray!90, very thick}}

\begin{document}

\begin{tikzpicture}
    \def\concentriccircles{\foreach \r in {1.5, ..., 19} {circle (\r mm)};}
    \foreach \name/\x/\y in {A/8/30, B/16/-24, C/-30/8} {
        \node [little circle] (\name) at (\x mm, \y mm) {};
    }
    \node [little circle] (P) at (barycentric cs:A=1,B=1,C=1) {};
    \foreach \name/\origin/\destination in {H/A/B, J/B/C, K/C/A} {
        \path (\origin) -- (\destination) coordinate [midway] (\name);
        \path (P) -- (\name) node [pos = 1.6, little circle] (\name 2) {};
    }
    \draw [concentric circles] (P) \concentriccircles;
    \foreach \x/\y/\v/\c in {A/B/H/green, B/C/J/red, C/A/K/blue} {
        \begin{scope}
            \clip (\x) .. controls (P) .. (\y) -- (\v 2) -- (\x); % (*)
            \draw [concentric circles, draw = \c] (P) \concentriccircles;
        \end{scope}
    }
    \begin{scope}[very thick]
        \foreach \x/\y/\c in {A/B/red, B/C/blue, C/A/green} {
            \draw [\c] (\x) .. controls (P) .. (\y);
        }
    \end{scope}
    \begin{scope}[very thick, red]
        \path [use as bounding box];
        \clip (A) circle [radius = 25mm];
        \draw (A) .. controls (P) .. (B);
    \end{scope}
\end{tikzpicture}

\end{document}

I don't understand why the clipping area excludes the triangle (A, B, H2) ((B, C, J2) and (C, A, K2)). You can see it does because the concentric circles beyond the line between A and B (B and C, C and A) are still grey.

Edit

Here is what it looks like if you add the draw option to the \clip command at (*).

share|improve this question
    
You can see the clipping area using an option \clip[draw] –  Sigur Jan 2 at 21:23
    
See what happens if you do \clip[draw] (\x) .. controls (P) .. (\y) -- (\v) ; that is, non closed path. Strange! –  Sigur Jan 2 at 21:37
    
@Sigur, if you do that then the clip area appears the same, though if you look closely you can see that it stops a short distance from the drawn line (which is drawn to halfway between A and B, as you would expect). –  Hammerite Jan 2 at 21:43
    
Try with coordinates instead of nodes... Or use \x.center, \y.center, \v 2.center, etc. –  Paul Gaborit Jan 2 at 23:14

1 Answer 1

up vote 5 down vote accepted

If you build a path with nodes, TikZ cuts this path into several segments to avoid the content of nodes.

To build your closed clipping path, use coordinates instead of nodes... or use \x.center, \y.center, \v 2.center, etc.

enter image description here

\documentclass[convert={size=480}]{standalone}

\usepackage{tikz}

\tikzset{ little circle/.style = { fill = black,
                                   shape = circle,
                                   minimum size = 1.5mm,
                                   inner sep = 0mm,
                                   outer sep = 0mm},
          concentric circles/.style = {draw = gray!90, very thick}}

\begin{document}

\begin{tikzpicture}
    \def\concentriccircles{\foreach \r in {1.5, ..., 19} {circle (\r mm)};}
    \foreach \name/\x/\y in {A/8/30, B/16/-24, C/-30/8} {
        \node [little circle] (\name) at (\x mm, \y mm) {};
    }
    \node [little circle] (P) at (barycentric cs:A=1,B=1,C=1) {};
    \foreach \name/\origin/\destination in {H/A/B, J/B/C, K/C/A} {
        \path (\origin) -- (\destination) coordinate [midway] (\name);
        \path (P) -- (\name) node [pos = 1.6, little circle] (\name 2) {};
    }
    \draw [concentric circles] (P) \concentriccircles;
    \foreach \x/\y/\v/\c in {A/B/H/green, B/C/J/red, C/A/K/blue} {
        \begin{scope}
            \clip (\x.center) .. controls (P.center) .. (\y.center)
            -- (\v 2.center) -- cycle; % (*)
            \draw [concentric circles, draw = \c] (P) \concentriccircles;
        \end{scope}
    }
    \begin{scope}[very thick]
        \foreach \x/\y/\c in {A/B/red, B/C/blue, C/A/green} {
            \draw [\c] (\x) .. controls (P) .. (\y);
        }
    \end{scope}
    \begin{scope}[very thick, red]
        \path [use as bounding box];
        \clip (A) circle [radius = 25mm];
        \draw (A) .. controls (P) .. (B);
    \end{scope}
\end{tikzpicture}

\end{document}
share|improve this answer
    
Can you tell me why it makes a difference whether it's a coordinate or a node? If x is a node, then isn't saying (x) the same as saying (x.center)? The TikZ/PGF manual doesn't say anything about not being able to clip using paths that make use of nodes-as-coordinates, as far as I can tell. –  Hammerite Jan 3 at 0:14
    
@Hammerite If you build a path with nodes, TikZ cuts this path into several segments to avoid the content of nodes. –  Paul Gaborit Jan 3 at 0:27
    
Thank you for the explanation. I feel like this could be addressed in the TikZ manual. –  Hammerite Jan 3 at 11: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.