# Drawing a half-full bottle in TikZ

I want to fill half of the bottle. I tried these kind of commands:

%\filldraw[color=black!100, fill=cyan!30, very thick](-3,-2.4) arc (180:230:2.5) .. controls (-2,-5) and (-1.9,-5.2) .. (-1.8,-5.5) ;

But I failed. Here is the bottle:

\documentclass[11pt,a4paper,oneside]{article}
\usepackage[a4paper,left=3cm,right=2cm,top=2.5cm,bottom=2.5cm]{geometry}
\usepackage[utf8x]{inputenc}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[xscale=1,yscale=1]

\draw[very thick](0,0) arc (0:180:1.5);
\draw[very thick] (-3,0) -- (-3,-2.5);
\draw[very thick] (0,0) -- (0,-2.5);
\draw[color=black!100,very thick](-3,-2.5) arc (180:235:3);
\draw[color=black!100,very thick](0,-2.5) arc (0:-55:3);
\draw[very thick] (-1.25,-4.95) -- (-1.25,-5.2) -- (-1.7,-5.2) -- (-1.7,-4.95);

\end{tikzpicture}
\end{document}


What I want:

• Simply draw the half bottle starting with the neck on the left side and ending with the neck on the right side. – AndréC Dec 31 '18 at 11:39
• And if I wanted to draw a half-empty bottle ;-) – Peter Wilson Dec 31 '18 at 18:53

\documentclass[border=5pt,tikz]{standalone}

\begin{document}
\begin{tikzpicture}[xscale=1,yscale=1]
\fill[blue!20] (0,-2.5) --+ (0,2.5) arc (0:180:1.5) -- (-3,-2.5) arc (180:235:3) --+ (0,-.25) --+ (.45,-.25) --+ (.45,.015) (0,-2.5) arc (0:-55:3);

\fill[white] (0,0) arc(0:180:1.5) --+ (0,-2) -| cycle;

\fill[blue!10] (-1.5,-2) circle ({1.5cm-0.4pt} and 0.5cm); % Thank you, marmot! ;)

\draw[very thick] (0,-2.5) --+ (0,2.5) arc (0:180:1.5) -- (-3,-2.5) arc (180:235:3) --+ (0,-.25) --+ (.45,-.25) --+ (.45,.015) (0,-2.5) arc (0:-55:3);
\end{tikzpicture}
\end{document}


Output: See below

Explanation:

Maybe beginners don't know the clip option and maybe the want just a type of "trivial" answer, so I had the following idea:

Let's fill the whole bottle with blue color and the just fill the upper part of it with white color. So we get at the end a bottle, which just a part is colored blue. The line

\fill[white] (0,0) arc(0:180:1.5) --+ (0,-2) -| cycle;


Does the following: It constructs the following path: It fills the arc at the top of the bottle, so we moved from point (-3,0) to the point (0,0). Now, we are going from the last point two cm down, but we want TikZ to calculate that point, so we write … (x_1,y_1) --+ (0,-2), which gives us the coordinate (x_1,y_1 + (-2)) = (x_1,y_1-2). Now we have got three points, and want to cycle the path. The option -| gives us the y coordinate from the point (x_1,y_1 + (-2)) = (x_1,y_1-2) and the x coordinate of the point (0,0). The word cycle means that we draw our path to the initial point.

P.S.: {1.5cm-0.4pt} (from the circle): in curly braces we let TikZ calculate the difference; 4pt is the thickness of the line of the bottle.

EDIT:

A little bit better solution:

\documentclass[border=5pt,tikz]{standalone}

\begin{document}
\begin{tikzpicture}[xscale=1,yscale=1]
\clip (0,-2.5) --+ (0,2.5) arc (0:180:1.5) -- (-3,-2.5) arc (180:235:3) --+ (0,-.25) --+ (.45,-.25) --+ (.45,.015) (0,-2.5) arc (0:-55:3);

\fill[blue!20] (-3,-5.5) rectangle ++(3,3.5);

\fill[blue!10] (-1.5,-2) circle ({1.5cm-0.4pt} and 0.5cm);

\draw[very thick] (0,-2.5) --+ (0,2.5) arc (0:180:1.5) -- (-3,-2.5) arc (180:235:3) --+ (0,-.25) --+ (.45,-.25) --+ (.45,.015) (0,-2.5) arc (0:-55:3);
\end{tikzpicture}
\end{document}


Explanation:

We can just "clip" the bottle: everything, what we draw, is now in the area of the bottle. Everything outside that area is invisible. So we just clip the bottle and fill a rectangle, such it fills a certain area of the bottle.

Output:

EDIT:

For Sebastiano:

\documentclass[border=5pt,tikz]{standalone}
\usetikzlibrary{decorations.text,backgrounds}
\definecolor{wine}{RGB}{216,198,62}
\definecolor{bottle}{RGB}{76,163,58}
\tikzset{
my/.style={
postaction={decorate},decoration={text along path,
text={#1},text align=center}
}
}
\begin{document}
\begin{tikzpicture}
\begin{scope}
\clip (0,-2.5) --+ (0,2.5) arc (0:180:1.5) -- (-3,-2.5) arc (180:235:3) --+ (0,-.25) --+ (.45,-.25) --+ (.45,.015) (0,-2.5) arc (0:-55:3);
\fill[inner color=bottle!50,outer color=bottle] (0,-2.5) --+ (0,2.5) arc (0:180:1.5) -- (-3,-2.5) arc (180:235:3) --+ (0,-.25) --+ (.45,-.25) --+ (.45,.015) (0,-2.5) arc (0:-55:3);
\fill[wine!60] (-3,-5.5) rectangle ++(3,3.5);
\fill[wine!40] (-1.5,-2) circle ({1.5cm-0.4pt} and 0.5cm);
\foreach \x in {-5,-4.9,...,5}
\foreach \y in {-5,...,-3}
{
\pgfmathsetmacro\opacity{random(1,10)*(1/10)}
}
\draw[very thick] (0,-2.5) --+ (0,2.5) arc (0:180:1.5) -- (-3,-2.5) arc (180:235:3) --+ (0,-.25) --+ (.45,-.25) --+ (.45,.015) (0,-2.5) arc (0:-55:3);
\path[my={The magic of Ti{\emph{\color{orange}k}}Z}] (-3.5,.5) arc(-180:0:2 and 1);
\end{scope}
\end{tikzpicture}
\end{document}


Output:

• I'm struggling to understand what does it mean: \fill[white] (0,0) arc(0:180:1.5) --+ (0,-2) -| cycle; . I understand the arc part, but I don't get how you link them each other by using (0,2) point, -|, and --+. – Rageful Dec 31 '18 at 13:44
• Maybe add \fill[blue!10] (-1.5,-2) circle ({1.5cm-0.4pt} and 0.5cm);. (+1) – marmot Dec 31 '18 at 15:47
• But inside the bottle there is normal water and it's not nice for the end of the year :-). The colour of the sparkling wine would be more appropriate :-) – Sebastiano Dec 31 '18 at 21:14

This looks like a code golfing challenge ;)

\documentclass[tikz,border=7pt]{standalone}
\usetikzlibrary{svg.path}
\begin{document}
\begin{tikzpicture}[scale=3]
\draw svg{M6 0V8A6 6 0 0 1-6 8V0};
\draw[fill=blue!20] svg{M6 0c0-9-3-11-5-13v-1h-2v1c-2 2-5 4-5 13};
\end{tikzpicture}
\end{document}