tikz:箭頭、奇偶規則、梯形;如何畫一個穿過洞的箭頭

tikz:箭頭、奇偶規則、梯形;如何畫一個穿過洞的箭頭

我想 tikz 這樣的東西:

目標

和:

% https://tex.stackexchange.com/q/245944
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\standaloneenv{tikzpicture}
\begin{document}
\usetikzlibrary{calc,shapes.geometric}
\begin{tikzpicture}
    \coordinate (hole) at (1ex, 3ex);
    \node[trapezium, trapezium left angle=120, trapezium right angle=60, minimum width=4ex, minimum height=4ex, rotate=30] (layer) {};
    \path[draw, even odd rule]
        {(layer.top left corner) -- (layer.bottom left corner) -- (layer.bottom right corner) -- (layer.top right corner) -- cycle}
        {($(layer.bottom left corner)+(hole)$) ellipse [draw, x radius=1.0ex,y radius=0.8ex, rotate=0]};
    \draw[-]  ($(layer.bottom left corner)+(hole)$)            -- +(0ex, 4ex);
    \draw[->] ($(layer.bottom left corner)+(hole)+(0ex,-3ex)$) -- +(0ex,-2ex);
\end{tikzpicture}
\end{document}

我可以生產:

姆韋

然而,這個解決方案感覺很粗糙(重新繪製梯形,將箭頭一分為二,...)並且有點死氣沉沉。

如何在沒有額外的情況下使用even odd rulewith並通過孔繪製箭頭而不猜測箭頭間間隙的大小?trapezium\patheven odd rule

答案1

這在 上使用奇偶規則\clip。請注意,您仍然需要分離 3D 物件的前景和背景。

\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\standaloneenv{tikzpicture}
\begin{document}
\usetikzlibrary{calc,shapes.geometric}
\begin{tikzpicture}
    \coordinate (hole) at (1ex, 3ex);
    \node[trapezium, trapezium left angle=120, trapezium right angle=60, minimum width=4ex, minimum height=4ex, rotate=30] (layer) {};
    \path[draw]
        (layer.top left corner) -- (layer.bottom left corner) -- (layer.bottom right corner) -- (layer.top right corner) -- cycle
        ($(layer.bottom left corner)+(hole)$) coordinate(C) ellipse [draw, x radius=1.0ex,y radius=0.8ex, rotate=0];
    \path[->] (C) ++(0ex, 4ex) -- ++(0ex,-8ex);% grow bounding box
    \begin{scope}[even odd rule]
    \clip (current bounding box.south west) rectangle  (current bounding box.north east)
        (layer.top left corner) -- (layer.bottom left corner) -- (layer.bottom right corner) -- cycle;
    \draw[->] (C) ++(0ex, 4ex) -- ++(0ex,-8ex);
    \end{scope}
\end{tikzpicture}
\end{document}

相關內容