大家好,我正在尝试蚀刻类似于下图中管子的半圆形区域,请帮忙。
\begin{tikzpicture}
\draw[thick] (-2.4,0)--(-2.4,5);
\draw[thick] (0,0)--(0,5);
\draw [thick] (0,0) arc(0:-180:1.2cm);
\draw[thick] (-2.2,0)--(-2.2,5);
\draw[thick] (-0.2,0)--(-0.2,5);
\draw [thick] (-0.2,0) arc(0:-180:1cm);
\draw[pattern=north west lines, pattern color=green] (-2.4,1)--(-2.2,1)--(-2.2,0)--(-2.4,0)--(-2.4,1);
\draw[pattern=north west lines, pattern color=green] (0,2)--(-0.2,2)--(-0.2,0)--(0,0)--(0,2);
\end{tikzpicture}
这是我用过的代码。
答案1
不确定所需的最终输出,但这是一个高度参数化的版本:
\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{patterns}
\begin{document}
\begin{tikzpicture}
\def\r{1.1}% Mid-tube radius
\def\t{.2} % Tube thickness
\def\h{5} % Straight height (total height is \r + \t/2 + \h)
\def\lh{2} % Left height
\def\rh{4} % Right height
\path [pattern=north west lines, pattern color=green]
(-\r+\t/2, \lh) -- ++(0, -\lh) arc (180:360:\r-\t/2) |-
( \r+\t/2, \rh) -- ++(0, -\rh) arc (360:180:\r+\t/2) |- cycle;
\draw (-\r-\t/2, \lh) -- ++(\t,0) (\r-\t/2, \rh) -- ++(\t,0);
\draw [black, thick]
(-\r-\t/2, \h) -- ++(0, -\h) arc (180:360:\r+\t/2) -- ++(0, \h)
(-\r+\t/2, \h) -- ++(0, -\h) arc (180:360:\r-\t/2) -- ++(0, \h);
\end{tikzpicture}
\end{document}