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 ruletrapezium带额外内容的功能\path并画出穿过孔的箭头even 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}

相关内容