1

I'm just trying to fill each peripheral segment of my drawing. The names of the hexagon and the circle are test and circ. Additionally, the line pieces connecting edges of the hexagon to the outer circle are named in the for loop. However, when I use the names as the intersection segments, a there is no named path called '2 and circ and test' is thrown.

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{arrows.meta,shapes,positioning}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepgfplotslibrary{fillbetween}
\begin{document}
    \begin{tikzpicture}
    \node[
    fill=red!15,
    draw = black,
    regular polygon,
    regular polygon sides=6,
    align=center,
    minimum size=5cm](test){};

    \node[
    fill=none,
    draw = black,
    circle,
    dashed,
    minimum size=9.2cm](circ){};

    \foreach \n in {1,...,6}
    {
        \draw[black, name path = \n](test.corner \n) --
        ({\n*60}:4.6);
    }

    \node[] (c) at (test.center){$\pi^{0}$};

    \foreach \n in {1,...,6}
    {
        \node[] (\n) at ({\n*60+30}:3.3){$\pi^{\n}$};
    }

    \fill[
    orange!50,
    intersection segments={
        of=1 and 2 and circ and test
    }];
    \end{tikzpicture}
\end{document}

What am I doing wrong?

2
  • You can only compute the intersection segments of two paths, not three, at once.
    – user121799
    Nov 27, 2018 at 15:01
  • @marmot: I have four! What is the doable plan, then?
    – user78499
    Nov 27, 2018 at 15:02

1 Answer 1

3

In this example, the simplest possibility would be to do

\fill[orange] (test.corner 1) -- (60:4.6) arc(60:120:4.6) -- (test.corner 2);

However, let's discuss how to build up intersection segments of more than two paths. Just define a new path from the intersection segments of two of the paths, store it as an auxiliary path, and then combine it with the next path, and so on.

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{arrows.meta,shapes,positioning,backgrounds}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepgfplotslibrary{fillbetween}
\begin{document}
    \begin{tikzpicture}
    \node[name path=test,
    fill=red!15,
    draw = black,
    regular polygon,
    regular polygon sides=6,
    align=center,
    minimum size=5cm](test){};

    \node[name path=circ,
    fill=none,
    draw = black,
    circle,
    dashed,
    minimum size=9.2cm](circ){};

    \foreach \n in {1,...,6}
    {
        \draw[black, name path = \n](test.corner \n) --
        ({\n*60}:4.6);
    }

    \node (c) at (test.center){$\pi^{0}$};

    \foreach \n in {1,...,6}
    {
        \node[] (\n) at ({\n*60+30}:3.3){$\pi^{\n}$};
    }
    \path [name path=aux1,%draw=blue,thick,->,
    intersection segments={of=1 and circ,
        sequence={L1--R2}}];
    \begin{scope}[on background layer]
      %\fill[orange] (test.corner 1) -- (60:4.6) arc(60:120:4.6) -- (test.corner 2);
      \path [fill=orange,%draw=red,thick,->,
      intersection segments={of=aux1 and 2,
          sequence={L1--R1[reverse]}}];
    \end{scope} 
    \end{tikzpicture}
\end{document}

enter image description here

1
  • This is a beautiful answer! Trivial remark: The \begin{scope}[on background layer] could be placed before the aux1 path is constructed, to ensure that auxiliary path is also on the background layer.
    – PatrickT
    Dec 8, 2021 at 11:56

You must log in to answer this question.