[Tex/LaTex] “Water–pattern”: a mechanical system

patterntikz-pgf

I was reading an old book and I found a picture which I reproduced with TikZ. Here is the original:

Diagram of machine with head of water

And here is my attempt and a MWE:

Reproduction of image done in 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}

How can get I the pattern which is used to simulate the fluid in the tank and the pipe (see original drawing)?

P.S.: Of course I could just use the pattern=north west lines from the TikZ library patterns, but I want another style. My MWE is pretty messy (as always), so don't wonder that some things could be done better. 😉

Best Answer

Here is a proposal based on an answer by 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}

enter image description here

OLDER ANSWER:

\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}

enter image description here