Drawing a half-full bottle in TikZ












11














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:



Drawing










share|improve this question
























  • 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
















11














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:



Drawing










share|improve this question
























  • 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














11












11








11


2





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:



Drawing










share|improve this question















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:



Drawing







tikz-pgf draw fill






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 31 '18 at 11:22









chrisma

906416




906416










asked Dec 31 '18 at 11:15









Rageful

1049




1049












  • 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


















  • 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
















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




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




And if I wanted to draw a half-empty bottle ;-)
– Peter Wilson
Dec 31 '18 at 18:53










2 Answers
2






active

oldest

votes


















19














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:



Screenshot



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}
{
pgfmathsetmacroopacity{random(1,10)*(1/10)}
pgfmathsetmacroradius{random(1,2)*(.05/2)}
fill[white,opacity=opacity] (x+1.3*rnd,y+1.4*rnd) circle(radius);
}
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:



Screenshot






share|improve this answer



















  • 2




    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








  • 1




    Maybe add fill[blue!10] (-1.5,-2) circle ({1.5cm-0.4pt} and 0.5cm);. (+1)
    – marmot
    Dec 31 '18 at 15:47






  • 3




    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



















9














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}


enter image description here






share|improve this answer





















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "85"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f468012%2fdrawing-a-half-full-bottle-in-tikz%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    19














    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:



    Screenshot



    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}
    {
    pgfmathsetmacroopacity{random(1,10)*(1/10)}
    pgfmathsetmacroradius{random(1,2)*(.05/2)}
    fill[white,opacity=opacity] (x+1.3*rnd,y+1.4*rnd) circle(radius);
    }
    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:



    Screenshot






    share|improve this answer



















    • 2




      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








    • 1




      Maybe add fill[blue!10] (-1.5,-2) circle ({1.5cm-0.4pt} and 0.5cm);. (+1)
      – marmot
      Dec 31 '18 at 15:47






    • 3




      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
















    19














    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:



    Screenshot



    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}
    {
    pgfmathsetmacroopacity{random(1,10)*(1/10)}
    pgfmathsetmacroradius{random(1,2)*(.05/2)}
    fill[white,opacity=opacity] (x+1.3*rnd,y+1.4*rnd) circle(radius);
    }
    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:



    Screenshot






    share|improve this answer



















    • 2




      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








    • 1




      Maybe add fill[blue!10] (-1.5,-2) circle ({1.5cm-0.4pt} and 0.5cm);. (+1)
      – marmot
      Dec 31 '18 at 15:47






    • 3




      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














    19












    19








    19






    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:



    Screenshot



    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}
    {
    pgfmathsetmacroopacity{random(1,10)*(1/10)}
    pgfmathsetmacroradius{random(1,2)*(.05/2)}
    fill[white,opacity=opacity] (x+1.3*rnd,y+1.4*rnd) circle(radius);
    }
    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:



    Screenshot






    share|improve this answer














    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:



    Screenshot



    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}
    {
    pgfmathsetmacroopacity{random(1,10)*(1/10)}
    pgfmathsetmacroradius{random(1,2)*(.05/2)}
    fill[white,opacity=opacity] (x+1.3*rnd,y+1.4*rnd) circle(radius);
    }
    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:



    Screenshot







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Dec 31 '18 at 22:15

























    answered Dec 31 '18 at 11:56









    current_user

    3,3601537




    3,3601537








    • 2




      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








    • 1




      Maybe add fill[blue!10] (-1.5,-2) circle ({1.5cm-0.4pt} and 0.5cm);. (+1)
      – marmot
      Dec 31 '18 at 15:47






    • 3




      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














    • 2




      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








    • 1




      Maybe add fill[blue!10] (-1.5,-2) circle ({1.5cm-0.4pt} and 0.5cm);. (+1)
      – marmot
      Dec 31 '18 at 15:47






    • 3




      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








    2




    2




    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






    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






    1




    1




    Maybe add fill[blue!10] (-1.5,-2) circle ({1.5cm-0.4pt} and 0.5cm);. (+1)
    – marmot
    Dec 31 '18 at 15:47




    Maybe add fill[blue!10] (-1.5,-2) circle ({1.5cm-0.4pt} and 0.5cm);. (+1)
    – marmot
    Dec 31 '18 at 15:47




    3




    3




    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




    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











    9














    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}


    enter image description here






    share|improve this answer


























      9














      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}


      enter image description here






      share|improve this answer
























        9












        9








        9






        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}


        enter image description here






        share|improve this answer












        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}


        enter image description here







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 31 '18 at 16:05









        Kpym

        15.7k23985




        15.7k23985






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f468012%2fdrawing-a-half-full-bottle-in-tikz%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Сан-Квентин

            8-я гвардейская общевойсковая армия

            Алькесар