3

I used the following code

\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{tikz}
\begin{document}
\begin{frame}[t]
\frametitle{}
\begin{tikzpicture}
\draw[line width=.1cm,blue, fill=blue!40!white, opacity=.4, looseness=1, rounded corners=.4cm] (0,0) to [out=60,in=-150] ++ (2,2) to [out=150,in=-60] ++ (-2,2) to [out=-120,in=30] ++ (-2,-2) to [out=-30,in=120] ++ (2,-2) -- cycle;
\end{tikzpicture}
\end{frame}
\end{document}

to draw the following shape,

enter image description here

which produced an extended rounded corner.

enter image description here

From the answers to this question, I understood that this is due to either a calculation error or using rounded corners and paths of length 0, but I could not figure out how to get rid of it.

Hany
  • 4,709

1 Answers1

3

You use rounded corners on a path of length 0, for which you use in addition --, namely the -- cycle stretch. There are many ways of rectifying this, here is one of them which may not be the shortest, but which shows where the issue is.

\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{tikz}
\begin{document}
\begin{frame}[t]
\frametitle{}
\begin{tikzpicture}
\draw[line width=.1cm,blue, fill=blue!40!white, opacity=.4, looseness=1, rounded
corners=.4cm] (30:0.2) to [out=60,in=-150]  (2,2) to [out=150,in=-60] ++ (-2,2)
to [out=-120,in=30] ++ (-2,-2) [sharp corners] to [out=-30,in=120] (150:0.2)  
to[out=-60,in=-120] cycle;
\end{tikzpicture}
\end{frame}
\end{document}

enter image description here

However, I'd use a loop to draw that.

\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{tikz}
\begin{document}
\begin{frame}[t]
\frametitle{}
\begin{tikzpicture}
\begin{scope}[transparency group,opacity=.4,]
 \draw[line width=.1cm,blue, fill=blue!40!white,  looseness=1]
  (0,-2) foreach \X in {0,90,180,270}
  {[rotate=\X] -- (0,-2) to[out=0,in=-120] ++ (0.2,0.1) to[out=60,in=-150] ++ (1.7,1.7)
  to[out=30,in=-90] ++ (0.1,0.2)} -- cycle;
\end{scope}  
\end{tikzpicture}
\end{frame}
\end{document}

enter image description here

You can also use plot[smooth cycle] here. The diagram on the right is only to explain the parameters.

\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{tikz}
\begin{document}
\begin{frame}[t]
\frametitle{}
\begin{tikzpicture}[declare function={alpha=8;r1=2;r2=1.85;r3=1.2;}]
\begin{scope}[transparency group,opacity=.4]
 \draw[line width=.1cm,blue, fill=blue!40!white]
  plot[smooth cycle] coordinates
  {(0:r1) 
    (alpha:r2) (45:1.3) (90-alpha:r2) (90:r1)
   (alpha+90:r2) (45+90:1.3) (90-alpha+90:r2) (90+90:r1)
   (alpha+180:r2) (45+180:1.3) (90-alpha+180:r2) (90+180:r1)  
    (alpha+270:r2) (45+270:1.3) (90-alpha+270:r2) };
\end{scope}  
\begin{scope}[xshift=5cm,>=stealth]
 \begin{scope}[transparency group,opacity=.4]
 \draw[line width=.1cm,blue, fill=blue!40!white]
  plot[smooth cycle] coordinates
  {(0:r1) 
    (alpha:r2) (45:1.3) (90-alpha:r2) (90:r1)
   (alpha+90:r2) (45+90:1.3) (90-alpha+90:r2) (90+90:r1)
   (alpha+180:r2) (45+180:1.3) (90-alpha+180:r2) (90+180:r1)  
    (alpha+270:r2) (45+270:1.3) (90-alpha+270:r2) };    
 \end{scope}    
 \draw (2.4,0) -- (0,0) -- (alpha:2.4)
  (2.2,0) arc(0:alpha:2.2) (alpha/2:2.5) node{$\alpha$};
 \draw[<->] (0,0) --  node[right] {$r_1$}(90:r1);
 \draw[<->] (0,0) --  node[left] {$r_2$}(90+alpha:r2);
 \draw[<->] (0,0) --  node[below left] {$r_3$}(90+45:r3);
\end{scope}  
\end{tikzpicture}
\end{frame}
\end{document}

enter image description here

  • Thank you very much for your answer. – Hany Dec 18 '19 at 04:55
  • You are welcome! (Please note that you may also produce these shapes with plot[smooth cycle]. –  Dec 18 '19 at 05:39
  • Thank you for your suggestion. Would you please tell me how to use plot[smooth cycle] with my drawing. – Hany Dec 18 '19 at 05:47
  • 1
    @Hany I added an example. You may need to vary the parameters alpha, r1, r2 and r3 to get you favorite result. –  Dec 18 '19 at 06:06
  • Thank you very much for your time and concern. – Hany Dec 18 '19 at 06:13