4

I wish the top of the carafe is not drawn like the picture.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
\begin{tikzpicture}[x=0.25cm,y=0.25cm, >=stealth]
    \draw[blue,fill=blue,opacity=0.1] (0,0)-- ++(16,0)-- ++(0,4)-- ++(-6,0)-- ++(0,6)-- ++(-4,0)-- ++(0,-6)-- ++(-6,0)--cycle ;
    \draw[thick,blue,rounded corners=3pt] (0,0)-- ++(16,0)-- ++(0,4)-- ++(-6,0)-- ++(0,12)-- ++(-4,0)-- ++(0,-12)-- ++(-6,0)--cycle ;
    \draw[thick,blue,dash pattern=on 3mm off 1mm](8,0)--(8,16) ;
    \draw[thick,<->](8,-1)--node[below]{8 cm} (16,-1) ;
    \draw[thick,<->](17,0)-- node[right]{4 cm} (17,4) ;
    \draw[thick,<->](12,4)-- node[right]{12 cm} (12,16) ;
    \draw[thick,->](0,10)-- node[above]{2 cm}(6,10) ;
    \draw[thick](6,10)--(8,10) ;
    \draw[thick,<-](8,10)--(8.8,10) ; 
\end{tikzpicture}
\end{document} 

enter image description here

enter image description here

2 Answers 2

4

Solution is simple: not draw this part of curve! Realization is more demanding: first you should find beginning and end of this segment and than redraw it:

Edit: With new definition of shape border you also can on similar way define area for it fill anf for this use command \fill.

\documentclass[ tikz,
                border=3mm]{standalone}
\usetikzlibrary{calc}

\begin{document}
    \begin{tikzpicture}[x=0.25cm,y=0.25cm, >=stealth]
\fill[blue,rounded corners=3pt,opacity=0.1]
    (6,10)|- ++(-6,-6) |- ++(16,-4) 
          |- ++(-6,4) -- ++ (0,6);
\draw[very thick,red,rounded corners=3pt]
    (6,16)|- ++(-6,-12) |- ++(16,-4) 
          |- ++(-6,4) -- ++ (0,12);
\draw[thick,blue,dash pattern=on 3mm off 1mm](8,0)--(8,16) ;
\draw[thick,<->](8,-1)--node[below]{8 cm} (16,-1) ;
\draw[thick,<->](17,0) -- node[below,sloped]{4 cm} (17,4) ;
\draw[thick,<->](12,4) -- node[below,sloped]{12 cm} (12,16) ;
\draw[thick,->](0,10)-- node[above]{2cm}(6,10) ;
\draw[thick](6,10)--(8,10) ;
\draw[thick,<-](8,10)--(8.8,10) ;
    \end{tikzpicture}
\end{document} 

enter image description here

2
  • Thank you. How to have the labels "4 cm" and "12 cm" as the image. With rotate = 90, the behavior is not as expected
    – Fabrice
    Oct 31, 2016 at 14:21
  • See edit of my answer. you need add to node options sloped option and change right to below.
    – Zarko
    Oct 31, 2016 at 14:35
4

The easiest way is probably to clip the path which draws the outline.

\documentclass[border=10pt,multi,tikz]{standalone}
\begin{document}
\begin{tikzpicture}[x=0.25cm,y=0.25cm, >=stealth]
    \draw[blue,fill=blue,opacity=0.1] (0,0)-- ++(16,0)-- ++(0,4)-- ++(-6,0)-- ++(0,6)-- ++(-4,0)-- ++(0,-6)-- ++(-6,0)--cycle ;
    \begin{scope}
      \clip ([xshift=-2pt,yshift=-2pt]0,0) |- (6,16) -| ++(2pt,-1) -| ([xshift=-2pt]10,16) -| ([yshift=-2pt]17,0) -- cycle;
      \draw[thick,blue,rounded corners=3pt] (0,0)-- ++(16,0)-- ++(0,4)-- ++(-6,0)-- ++(0,12)-- ++(-4,0)-- ++(0,-12)-- ++(-6,0)--cycle ;
    \end{scope}
    \draw[thick,blue,dash pattern=on 3mm off 1mm](8,0)--(8,16) ;
    \draw[thick,<->](8,-1)--node[below]{8 cm} (16,-1) ;
    \draw[thick,<->](17,0)-- node[right]{4 cm} (17,4) ;
    \draw[thick,<->](12,4)-- node[right]{12 cm} (12,16) ;
    \draw[thick,->](0,10)-- node[above]{2cm}(6,10) ;
    \draw[thick](6,10)--(8,10) ;
    \draw[thick,<-](8,10)--(8.8,10) ;
\end{tikzpicture}
\end{document}

open-top flask

If you don't want the rounded corners at the top, you can just leave a gap in the path. For example,

\documentclass[border=10pt,multi,tikz]{standalone}
\begin{document}
\begin{tikzpicture}[x=0.25cm,y=0.25cm, >=stealth]
    \draw[blue,fill=blue,opacity=0.1] (0,0)-- ++(16,0)-- ++(0,4)-- ++(-6,0)-- ++(0,6)-- ++(-4,0)-- ++(0,-6)-- ++(-6,0)--cycle ;
    \draw[thick,blue,rounded corners=3pt] (10,16) |- ++(6,-12) |- (0,0) |- ++(6,4)--  ++(0,12);
    \draw[thick,blue,dash pattern=on 3mm off 1mm](8,0)--(8,16) ;
    \draw[thick,<->](8,-1)--node[below]{8 cm} (16,-1) ;
    \draw[thick,<->](17,0)-- node[right]{4 cm} (17,4) ;
    \draw[thick,<->](12,4)-- node[right]{12 cm} (12,16) ;
    \draw[thick,->](0,10)-- node[above]{2cm}(6,10) ;
    \draw[thick](6,10)--(8,10) ;
    \draw[thick,<-](8,10)--(8.8,10) ;
\end{tikzpicture}
\end{document}

open with straight sides

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .