我想使用 tikz 绘制以下图片,但我不知道如何将其着色为 3d 对象以及如何将上箭头覆盖其他箭头?
以下是我的尝试:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=.3,xscale=.8]
\draw (-1,8) arc (90:-82.8:8 and 3);
\draw (-1,8)-- (-1,7);
\draw (7,4)-- (7,5);
\draw (-1,7) arc (90:10:8 and 3);
\draw (7,4) arc (0:-82.8:8 and 3);
\draw (0,1.02) --(0,.5)--(-1.5,1.54) node[left]{cc}--(0,2.5) --(0,2);
%----------------------------------
\draw (-1,1) arc (90:-82.8:8 and 3);
\draw (-1,0)-- (-1,1);
\draw (7,-3)-- (7,-2);
\draw (-1,0) arc (90:10:8 and 3);
\draw (7,-3) arc (0:-82.8:8 and 3);
\draw (0,-5.98) --(0,-6.5)--(-1.5,-5.48) node[left]{cc}--(0,-4.5) --(0,-5);
%----------------------------------
\end{tikzpicture}
\end{document}
答案1
3D 效果和叠加都可以通过 的填充选项实现\draw
。可能会有更好的解决方案。下面我根据您的示例做了最小的修改:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=.3,xscale=.8]
\draw[fill=gray] (-1,7) -- (-1,8) arc (90:-7:8 and 3);
\draw (-1,8) arc (90:-82.8:8 and 3);
\draw (7,4)-- (7,5);
\draw[fill=white] (-1,7) arc (90:10:8 and 3);
\draw (7,4) arc (0:-82.8:8 and 3);
\draw (0,1.02) --(0,.5)--(-1.5,1.54) node[left]{cc}--(0,2.5) --(0,2);
%----------------------------------
\draw[fill=gray] (-1,0)-- (-1,1) arc (90:-7.8:8 and 3);
\draw (-1,1) arc (90:-82.8:8 and 3);
\draw (7,-3)-- (7,-2);
\draw[fill=white] (-1,0) arc (90:10:8 and 3);
\draw (7,-3) arc (0:-82.8:8 and 3);
\draw (0,-5.98) --(0,-6.5)--(-1.5,-5.48) node[left]{cc}--(0,-4.5) --(0,-5);
%----------------------------------
\end{tikzpicture}
\end{document}
编辑:对于渐变着色,可以通过设置来完成shading = axis
。
您还可以设置shading angle=x
某个角度 x 来获得不同的视觉效果。