tikz: empate em cima do espião

Sep 17 2020

Quero traçar um tikz-espião e a nova linha deve cobrir as copiadas pelo espião. Por exemplo:

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{spy,shapes}

\pgfdeclarelayer{bg}    % declare background layer
\pgfsetlayers{bg,main}  % set the order of the layers (main is the standard layer)


\begin{document}
\begin{tikzpicture}[spy using outlines={rectangle, width=4.5cm, height=3cm, magnification=4, connect spies,every spy on node/.append style={thin}},hide/.style={opacity=1}]

\begin{scope}
    \draw  circle (8) node[yshift=8.8cm,align=center] {};
    \draw  circle (8.2) node {};
    \draw (-5,7.4) -- (5,7.4);
\end{scope}

%\begin{pgfonlayer}{bg}    % select the background layer
\spy [black] on (-3.4,7.4) in node (spyleft) [left] at (-0.5,4.5);
%\end{pgfonlayer}

%\begin{pgfonlayer}{main}    % select the main layer
\draw[line width=2pt,color=blue] (-3.3,4.5) -- (-1.35,4.5) -- (-1.35,5.35) -- cycle;
%\end{pgfonlayer}

\end{tikzpicture}

\end{document}

deve ter o triângulo azul no topo das linhas pretas. Colocar explicitamente as partes do desenho em uma camada não parece ajudar. Existe uma camada de espionagem específica que eu possa abordar?

(Idealmente, também gostaria que os cantos do triângulo fossem definidos pelas interseções dos círculos e da linha, mas, por enquanto, estou feliz em posicioná-lo manualmente se ao menos eu pudesse obter as camadas corretas ...)

Respostas

1 muzimuzhiZ Sep 17 2020 at 17:46

Declare uma camada de primeiro plano e coloque o triângulo azul nessa camada.

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{spy,shapes}

\pgfdeclarelayer{fg}    % declare foreground layer
\pgfsetlayers{main,fg}  % set the order of the layers (main is the standard layer)


\begin{document}
\begin{tikzpicture}[spy using outlines={rectangle, width=4.5cm, height=3cm, magnification=4, connect spies,every spy on node/.append style={thin}},hide/.style={opacity=1}]

  \begin{scope}
      \draw  circle (8) node[yshift=8.8cm,align=center] {};
      \draw  circle (8.2) node {};
      \draw (-5,7.4) -- (5,7.4);
  \end{scope}
  
  \spy [black] on (-3.4,7.4) in node (spyleft) [left] at (-0.5,4.5);
  
  \begin{pgfonlayer}{fg}    % select the main layer
    \draw[line width=2pt,blue] (-3.3,4.5) -- (-1.35,4.5) -- (-1.35,5.35) -- cycle;
  \end{pgfonlayer}
\end{tikzpicture}

\end{document}