tikz: วาดบนสปาย

Sep 17 2020

ฉันต้องการวาดบน tikz-spy และบรรทัดใหม่ควรครอบคลุมสิ่งที่คัดลอกโดยสายลับ เช่น:

\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}

ควรมีสามเหลี่ยมสีน้ำเงินอยู่ด้านบนของเส้นสีดำ การวางส่วนต่างๆของภาพวาดในเลเยอร์อย่างชัดเจนดูเหมือนจะไม่ช่วยอะไร มีชั้นสอดแนมเฉพาะที่ฉันสามารถจัดการได้หรือไม่?

(ตามหลักการแล้วฉันต้องการให้มุมของสามเหลี่ยมถูกกำหนดโดยจุดตัดของวงกลมและเส้น แต่ตอนนี้ฉันยินดีที่จะวางตำแหน่งด้วยมือถ้าฉันสามารถทำให้เลเยอร์ถูกต้องได้ ... )

คำตอบ

1 muzimuzhiZ Sep 17 2020 at 17:46

ประกาศเลเยอร์เบื้องหน้าและวางสามเหลี่ยมสีน้ำเงินบนเลเยอร์นั้น

\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}