![tikz:箭头、奇偶规则和梯形;如何绘制穿过孔的箭头](https://linux22.com/image/476027/tikz%EF%BC%9A%E7%AE%AD%E5%A4%B4%E3%80%81%E5%A5%87%E5%81%B6%E8%A7%84%E5%88%99%E5%92%8C%E6%A2%AF%E5%BD%A2%EF%BC%9B%E5%A6%82%E4%BD%95%E7%BB%98%E5%88%B6%E7%A9%BF%E8%BF%87%E5%AD%94%E7%9A%84%E7%AE%AD%E5%A4%B4.png)
我想要 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 rule
不trapezium
带额外内容的功能\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}