# fill cylinder in latex

I want to fill the below cylinder same as picture

And my code

\begin{tikzpicture}
\def\a{1} % bán trục lớn = bán kính trụ
\def\b{0.3} % bán trục nhỏ
\def\h{3} % chiều cao trụ
\draw (\a,0)--(\a,\h) (-\a,0)--(-\a,\h);
\draw (0,\h) ellipse (\a cm and \b cm);
\end{tikzpicture}

\begin{tikzpicture}[rotate=-70]
\def\a{1} % bán trục lớn = bán kính trụ
\def\b{0.3} % bán trục nhỏ
\def\h{3} % chiều cao trụ
\draw (\a,0)--(\a,\h) (-\a,0)--(-\a,\h);
\tkzDefPoints{-\a/0/A,\a/0/B,-\a/\h/a}
\tkzDefMidPoint(A,B)\tkzGetPoint{O}
\coordinate(M) at ([shift={(O)}]-70:\a cm and \b cm);
\draw[draw=none,name path=elip] (O) ellipse (\a cm and \b cm);
\tkzDefPointBy[rotation=center O angle 180](M)\tkzGetPoint{N}
\coordinate(C) at ([shift={(O)}]0:\a cm and \b cm);
\tkzDefPointBy[translation=from A to a](C)\tkzGetPoint{C'}
\fill[color=gray!50, draw=none]
(O) -- (M) .. controls (0.8,1.6) and (1,2.8) .. (C');
\fill[color=gray!50, draw=none]
(O) -- (N) .. controls (0.6,2.6) and (0.8,3.3) .. (C');
\tkzFindAngle(B,O,M)\tkzGetAngle{angBOM}
\fill[color=gray!40, draw=none]
(M) .. controls (0.8,1.5) and (1,2.6) .. (C')--(B);
\fill[color=gray!40, draw=none]
\draw[dashed](M)--(N) (O)--(C');
\draw[name path=elip1] (M) .. controls (0.8,1.6) and (1,2.8) .. (C');
\draw[dashed,name path=elip2] (N) .. controls (0.6,2.6) and (0.8,3.3) .. (C');
\draw (0,\h) ellipse (\a cm and \b cm);
\end{tikzpicture}


This draws such partly filled, rotated cylinders. The top surface of the water level is an ellipse, which may get truncated by the top and/or bottom of the cylinder. The computation of the relevant angles is rather straightforward if one looks at suitable projections. I'd lie to thank minhthien_2016 for reminding me of this nice question.

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{tikz-3dplot}
\tikzset{pics/filled cylinder/.style={code={\tikzset{filled cylinder/.cd,#1}
\newcommand*{\pv}[1]{\pgfkeysvalueof{/tikz/filled cylinder/##1}}
\pgfmathsetmacro\angVis{atan(sin(\pv{rot})*cos(\tdplotmaintheta)/sin(\tdplotmaintheta))}% see tex.stackexchange.com/a/49589/
\pgfmathsetmacro{\angU}{ifthenelse(\alphaU>0,\alphaU,\angVis)}
\pgfmathsetmacro{\angL}{ifthenelse(\alphaL>0,180-\alphaL,\angVis+180)}
\ifdim\alphaU pt>0pt % distinguish between cut at top end and not
\path[fill=blue!50,fill opacity=0.5]
plot[variable=\t,domain=\angVis:-1*\angU,smooth]
plot[variable=\t,domain=\angU:\angL,smooth]
-- cycle;
\else
\path[fill=blue!50,fill opacity=0.5]
plot[variable=\t,domain=\angU:\angL,smooth]
-- cycle;
\fi
\draw[fill=blue,fill opacity=0.5]
plot[variable=\t,domain=\alphaU:180-\alphaL,smooth]
-- plot[variable=\t,domain=180+\alphaL:360-\alphaU,smooth]
-- cycle;
-sin(\pv{rot})*\pv{height}},
+cos(\pv{rot})*\pv{height}}) -- cycle;
}}}
\begin{document}
\tdplotsetmaincoords{110}{0}
\foreach \Angle in {-5,-10,...,-80,-75,-70,...,-10}
{\begin{tikzpicture}[tdplot_main_coords,
declare function={zprime(\x,\z,\a)=\z*cos(\a)-\x*sin(\a);
xprime(\x,\z,\a)=\x*cos(\a)+\z*sin(\a);},