“水纹”:机械系统

“水纹”:机械系统

我在读一本旧书,发现了一张图片,我用 Ti 复制了它Z.原文如下:

带水头机器示意图

这是我的尝试和 MWE:

在 TikZ 中复制图像

\documentclass[border=5pt,tikz]{standalone}
\usetikzlibrary{arrows,patterns}
\begin{document}
    \begin{tikzpicture}[thick,>=latex,every node/.style={font=\sf\em}]
        \draw[double distance=2mm] (3,1) --+ (.4,0);
        \draw[double distance=2mm] (3.7,1) --+ (.4,0);
%           \draw[xshift=5.1cm,yshift=-.385cm,double distance=2mm] (0,0) -- (2,0) -- (3,5);
                \draw[rounded corners] (0,0) rectangle (3,2);
                    \draw (.2,0) --+ (-.2,-.5);
                    \draw (2.8,0) --+ (.2,-.5);

                \draw[xshift=3.4cm,yshift=.75cm] (0,0) rectangle (.1,.5);
                \draw[xshift=3.6cm,yshift=.75cm] (0,0) rectangle (.1,.5);

                    \draw[xshift=4.1cm,yshift=-.5cm] (0,0) rectangle (1,3);
                    \draw[xshift=2.5cm,yshift=1cm,densely dotted] (0,0) -- (2,0);

        \draw[xshift=5.1cm,yshift=-.5cm] (0,0) -- (2,0) -- (3,5) --+ (2,0);
        \draw[xscale=.97,yscale=.957,xshift=5.1cm,yshift=-.3cm] (.15,0) -- (2,0) -- (3,5) --+ (0,1);

            \draw[xscale=.97,yscale=.957,xshift=5.1cm,yshift=-.3cm] (3,5) --+ (-1,0);
            \draw[xscale=.97,yscale=.957,xshift=7cm,yshift=-.3cm] (3,5) --+ (0,1);

        \draw[very thick,yshift=-.5cm] (0,0) -- (8,0);
        \draw[thin,yshift=-.5cm] (8,0) -- (9.9,0);

            \node (a) at (1.5,4) {Dieselmotor};
            \draw[->] (a) --+ (0,-1.5);

                \node (b) at (4.6,4) {Kreiselpumpe};
                \draw[->] (b) --+ (0,-1.5);

            \draw[<->] (9.9,-.5) -- (9.9,4.5) node[midway,fill=white] {$h$};

            \fill[pattern=north west lines,xshift=5.1cm,yshift=-.5cm] (0,0) -- (2,0) -- (3,5) -- (4.6,5) -- (4.6,5.6) -- (2.76,5.6) -- (2.75,5) -- (1.8,.2) -- (0,.2) -- cycle;
    \end{tikzpicture}
\end{document}

如何获得用于模拟罐内流体和管道的图案(参见原始图纸)?

PS:当然我可以使用pattern=north west linesTiZ 库patterns,但我想要另一种风格。我的 MWE 相当混乱(一如既往),所以不要怀疑有些事情可以做得更好。;)

答案1

以下是基于Ignasi 的回答

\documentclass[border=5pt,tikz]{standalone}
\usetikzlibrary{arrows,patterns}
\tikzset{ % https://tex.stackexchange.com/a/355345/121799
    fake water thickness/.store in=\fakewaterthickness,
    fake water thickness=0.3pt
    }

\makeatletter
\newdimen\FakeWaterScale
\FakeWaterScale=7pt
\newdimen\AuxScale
\AuxScale=\FakeWaterScale
\advance \AuxScale by -1.5pt
\pgfdeclarepatternformonly[\fakewaterthickness]{fake water}
{\pgfpoint{-1.5pt}{-1.5pt}}{\pgfpoint{\AuxScale}{\AuxScale}}
{\pgfpoint{\FakeWaterScale}{\FakeWaterScale}}
{
    \pgfsetcolor{\tikz@pattern@color}
    \pgfsetlinewidth{\fakewaterthickness}
    \pgfpathmoveto{\pgfpoint{0pt}{0.25\FakeWaterScale}}
    \pgfpathlineto{\pgfpoint{0.5\FakeWaterScale}{0.25\FakeWaterScale}}
    \pgfpathmoveto{\pgfpoint{0.5\FakeWaterScale}{0.5\FakeWaterScale}}
    \pgfpathlineto{\pgfpoint{\FakeWaterScale}{0.5\FakeWaterScale}}
    \pgfpathmoveto{\pgfpoint{0pt}{0.75\FakeWaterScale}}
    \pgfpathlineto{\pgfpoint{0.5\FakeWaterScale}{0.75\FakeWaterScale}}
    \pgfpathmoveto{\pgfpoint{0.5\FakeWaterScale}{\FakeWaterScale}}
    \pgfpathlineto{\pgfpoint{\FakeWaterScale}{\FakeWaterScale}}
    \pgfusepath{stroke}
}
\makeatother

\begin{document}
    \begin{tikzpicture}[thick,>=latex,every node/.style={font=\sf\em}]
        \draw[double distance=2mm] (3,1) --+ (.4,0);
        \draw[double distance=2mm] (3.7,1) --+ (.4,0);
%           \draw[xshift=5.1cm,yshift=-.385cm,double distance=2mm] (0,0) -- (2,0) -- (3,5);
                \draw[rounded corners] (0,0) rectangle (3,2);
                    \draw (.2,0) --+ (-.2,-.5);
                    \draw (2.8,0) --+ (.2,-.5);

                \draw[xshift=3.4cm,yshift=.75cm] (0,0) rectangle (.1,.5);
                \draw[xshift=3.6cm,yshift=.75cm] (0,0) rectangle (.1,.5);

                    \draw[xshift=4.1cm,yshift=-.5cm] (0,0) rectangle (1,3);
                    \draw[xshift=2.5cm,yshift=1cm,densely dotted] (0,0) -- (2,0);

        \draw[xshift=5.1cm,yshift=-.5cm] (0,0) -- (2,0) -- (3,5) --+ (2,0);
        \draw[xscale=.97,yscale=.957,xshift=5.1cm,yshift=-.3cm] (.15,0) -- (2,0) -- (3,5) --+ (0,1);

            \draw[xscale=.97,yscale=.957,xshift=5.1cm,yshift=-.3cm] (3,5) --+ (-1,0);
            \draw[xscale=.97,yscale=.957,xshift=7cm,yshift=-.3cm] (3,5) --+ (0,1);

        \draw[very thick,yshift=-.5cm] (0,0) -- (8,0);
        \draw[thin,yshift=-.5cm] (8,0) -- (9.9,0);

            \node (a) at (1.5,4) {Dieselmotor};
            \draw[->] (a) --+ (0,-1.5);

                \node (b) at (4.6,4) {Kreiselpumpe};
                \draw[->] (b) --+ (0,-1.5);

            \draw[<->] (9.9,-.5) -- (9.9,4.5) node[midway,fill=white] {$h$};

            \draw[pattern=fake water,xshift=5.1cm,yshift=-.5cm] (0,0) -- (2,0) -- (3,5) -- (4.6,5) -- (4.6,5.95) -- (2.76,5.95) -- (2.75,5) -- (1.8,.2) -- (0,.2) -- cycle;

            \draw[pattern=horizontal lines,xshift=5.1cm,yshift=-.5cm] (0,0) -- (2,0) 
            -- (3,5) -- (2.75,5) -- (1.8,.2) -- (0,.2) -- cycle;

    \end{tikzpicture}
\end{document}

在此处输入图片描述

旧答案

\documentclass[border=5pt,tikz]{standalone}
\usetikzlibrary{arrows,patterns}
\tikzset{ % https://tex.stackexchange.com/a/355345/121799
    fake water thickness/.store in=\fakewaterthickness,
    fake water thickness=0.3pt
    }

\makeatletter
\newdimen\FakeWaterScale
\FakeWaterScale=8pt
\newdimen\AuxScale
\AuxScale=\FakeWaterScale
\advance \AuxScale by -1pt
\pgfdeclarepatternformonly[\fakewaterthickness]{fake water}
{\pgfpoint{-1pt}{-1pt}}{\pgfpoint{\AuxScale}{\AuxScale}}
{\pgfpoint{\FakeWaterScale}{\FakeWaterScale}}
{
    \pgfsetcolor{\tikz@pattern@color}
    \pgfsetlinewidth{\fakewaterthickness}
    \pgfpathmoveto{\pgfpoint{0pt}{0.25\FakeWaterScale}}
    \pgfpathlineto{\pgfpoint{0.5\FakeWaterScale}{0.25\FakeWaterScale}}
    \pgfpathmoveto{\pgfpoint{0.5\FakeWaterScale}{0.5\FakeWaterScale}}
    \pgfpathlineto{\pgfpoint{\FakeWaterScale}{0.5\FakeWaterScale}}
    \pgfpathmoveto{\pgfpoint{0pt}{0.75\FakeWaterScale}}
    \pgfpathlineto{\pgfpoint{0.5\FakeWaterScale}{0.75\FakeWaterScale}}
    \pgfpathmoveto{\pgfpoint{0.5\FakeWaterScale}{\FakeWaterScale}}
    \pgfpathlineto{\pgfpoint{\FakeWaterScale}{\FakeWaterScale}}
    \pgfusepath{stroke}
}
\makeatother

\begin{document}
    \begin{tikzpicture}[thick,>=latex,every node/.style={font=\sf\em}]
        \draw[double distance=2mm] (3,1) --+ (.4,0);
        \draw[double distance=2mm] (3.7,1) --+ (.4,0);
%           \draw[xshift=5.1cm,yshift=-.385cm,double distance=2mm] (0,0) -- (2,0) -- (3,5);
                \draw[rounded corners] (0,0) rectangle (3,2);
                    \draw (.2,0) --+ (-.2,-.5);
                    \draw (2.8,0) --+ (.2,-.5);

                \draw[xshift=3.4cm,yshift=.75cm] (0,0) rectangle (.1,.5);
                \draw[xshift=3.6cm,yshift=.75cm] (0,0) rectangle (.1,.5);

                    \draw[xshift=4.1cm,yshift=-.5cm] (0,0) rectangle (1,3);
                    \draw[xshift=2.5cm,yshift=1cm,densely dotted] (0,0) -- (2,0);

        \draw[xshift=5.1cm,yshift=-.5cm] (0,0) -- (2,0) -- (3,5) --+ (2,0);
        \draw[xscale=.97,yscale=.957,xshift=5.1cm,yshift=-.3cm] (.15,0) -- (2,0) -- (3,5) --+ (0,1);

            \draw[xscale=.97,yscale=.957,xshift=5.1cm,yshift=-.3cm] (3,5) --+ (-1,0);
            \draw[xscale=.97,yscale=.957,xshift=7cm,yshift=-.3cm] (3,5) --+ (0,1);

        \draw[very thick,yshift=-.5cm] (0,0) -- (8,0);
        \draw[thin,yshift=-.5cm] (8,0) -- (9.9,0);

            \node (a) at (1.5,4) {Dieselmotor};
            \draw[->] (a) --+ (0,-1.5);

                \node (b) at (4.6,4) {Kreiselpumpe};
                \draw[->] (b) --+ (0,-1.5);

            \draw[<->] (9.9,-.5) -- (9.9,4.5) node[midway,fill=white] {$h$};

            \draw[pattern=fake water,xshift=5.1cm,yshift=-.5cm] (0,0) -- (2,0) -- (3,5) -- (4.6,5) -- (4.6,5.95) -- (2.76,5.95) -- (2.75,5) -- (1.8,.2) -- (0,.2) -- cycle;


            \clip[xshift=5.1cm,yshift=-.5cm] (0,0) -- (2,0) -- (3,5) -- (4.6,5) -- (4.6,5.95) -- (2.76,5.95) -- (2.75,5) -- (1.8,.2) -- (0,.2) -- cycle;
%           \fill[xshift=5.1cm,yshift=-.5cm,blue] (0,0) rectangle (4.6,6);
            \foreach \X in {1,...,1000}
            { \draw[xshift=5.1cm,yshift=-.5cm,line width=\fakewaterthickness]
            ({4.6*rand},{6*rand}) -- ++ (2pt,0); }
    \end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

使用 \clip 的选项

结果: 在此处输入图片描述

梅威瑟:

\documentclass[border=5pt,tikz]{standalone}
\usetikzlibrary{arrows,patterns}
\begin{document}
    \begin{tikzpicture}[thick,>=latex,every node/.style={font=\sf\em}]
        \draw[double distance=2mm] (3,1) --+ (.4,0);
        \draw[double distance=2mm] (3.7,1) --+ (.4,0);
%           \draw[xshift=5.1cm,yshift=-.385cm,double distance=2mm] (0,0) -- (2,0) -- (3,5);
                \draw[rounded corners] (0,0) rectangle (3,2);
                    \draw (.2,0) --+ (-.2,-.5);
                    \draw (2.8,0) --+ (.2,-.5);

                \draw[xshift=3.4cm,yshift=.75cm] (0,0) rectangle (.1,.5);
                \draw[xshift=3.6cm,yshift=.75cm] (0,0) rectangle (.1,.5);

                    \draw[xshift=4.1cm,yshift=-.5cm] (0,0) rectangle (1,3);
                    \draw[xshift=2.5cm,yshift=1cm,densely dotted] (0,0) -- (2,0);

        \draw[xshift=5.1cm,yshift=-.5cm] (0,0) -- (2,0) -- (3,5) --+ (2,0);
        \draw[xscale=.97,yscale=.957,xshift=5.1cm,yshift=-.3cm] (.15,0) -- (2,0) -- (3,5) --+ (0,1);

            \draw[xscale=.97,yscale=.957,xshift=5.1cm,yshift=-.3cm] (3,5) --+ (-1,0);
            \draw[xscale=.97,yscale=.957,xshift=7cm,yshift=-.3cm] (3,5) --+ (0,1);

        \draw[very thick,yshift=-.5cm] (0,0) -- (8,0);
        \draw[thin,yshift=-.5cm] (8,0) -- (9.9,0);

            \node (a) at (1.5,4) {Dieselmotor};
            \draw[->] (a) --+ (0,-1.5);

                \node (b) at (4.6,4) {Kreiselpumpe};
                \draw[->] (b) --+ (0,-1.5);

            \draw[<->] (9.9,-.5) -- (9.9,4.5) node[midway,fill=white] {$h$};

            \clip[xshift=5.1cm,yshift=-.5cm] (0,0) -- (2,0) -- (3,5) -- (4.6,5) -- (4.6,5.6) -- (2.76,5.6) -- (2.75,5) -- (1.8,.2) -- (0,.2) -- cycle;
            \draw(5,5) -- ++ (10,0);
            %\shade[bottom color=black!50, top color=white] (5,5) rectangle ++(10,-5.5);
            \foreach \n [count=\k from 1]in {0,1,...,100}{
                    \draw[line width = 0.5pt,dash pattern = on 4pt off 2pt on 4pt off 2pt](5,5-0.15*\n+0.15*\k*\n/100*0.5) -- ++ (10,0);
                    \draw[line width = 0.5pt,dash pattern = on 4pt off 2pt on 4pt off 2pt](5+2pt,5-0.15*\n+0.15*\k*\n/100*0.51-0.075) -- ++ (10,0);

                }
    \end{tikzpicture}
\end{document}

相关内容