答案1
这样就绘制了一个圆柱体并且也可用于patterns.meta
椭圆。
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{patterns.meta,decorations.pathmorphing}
\begin{document}
\def\pk#1{\pgfkeysvalueof{/pgf/pattern keys/#1}}
\tikzdeclarepattern{name=lines,
parameters={
\pk{size},
\pk{angle},
\pk{line width},
\pk{gap},
},
bounding box={(-.1pt,-.1pt) and
(\pk{size}+.1pt,
{\pk{gap}+.1pt})},
tile size={(\pk{size},
{\pk{gap}})},
tile transformation={rotate=\pk{angle}},
defaults={
size/.initial=5pt,
angle/.initial=0,
line width/.initial=.4pt,
gap/.initial=3pt
}, code={
\draw[line width=\pk{line width}]
(0,0) -- ({\pk{size}},0) ;
} }
\begin{tikzpicture}[pics/fcylinder/.style={code={
\tikzset{fcylinder/.cd,#1}
\def\pv##1{\pgfkeysvalueof{/tikz/fcylinder/##1}}
\draw[fill=gray!30] (0,\pv{r})
arc[start angle=90,end angle=270,x radius=\pv{r}*\pv{aspect},y radius=\pv{r}]
-- (\pv{h},-\pv{r}) to[out=180,in=-120]
(\pv{h},0) to[out=60,in=0] (\pv{h},\pv{r}) -- cycle;
\draw[fill=gray!60] (\pv{h},-\pv{r}) to[out=180,in=-120] (\pv{h},0)
to[out=-60,in=0] cycle;
\draw[fcylinder/finish] (0,\pv{r})
arc[start angle=90,end angle=-90,x radius=\pv{r}*\pv{aspect},y radius=\pv{r}];
}},fcylinder/.cd,r/.initial=5mm,h/.initial=1cm,aspect/.initial=1/3,
finish/.style={solid}]
\begin{scope}[local bounding box=Dirichlet]
\path[pattern={lines[line width=.8pt,angle=30]}]
(0,0) circle[x radius=5mm,y radius=1.5cm];
\path (0,0) pic{fcylinder={finish/.style=dashed}};
\end{scope}
%
\begin{scope}[xshift=3.5cm,local bounding box=Neumann]
\path (0,0) pic{fcylinder};
\draw[very thick,-stealth] (0,0) -- node[above] {$\bar N$}++ (-1,0);
\end{scope}
%
\begin{scope}[xshift=7cm,local bounding box=Robin]
\path[pattern={lines[line width=.8pt,angle=30]}]
(0,0) circle[x radius=5mm,y radius=1.5cm];
\path (1,0) pic{fcylinder};
\draw[thick,decorate,decoration={zigzag,segment length=1.5mm,amplitude=2mm,
pre length=2mm,post length=2mm}] (0,0) -- (1,0);
\end{scope}
%
\end{tikzpicture}
\end{document}