3

From the answer to this question; I used the following code to draw another cross.

\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{verbatim}
\usepackage{tikz}
\begin{document}
\begin{frame}[t]
\frametitle{}
\begin{tikzpicture}[line join=round, line cap=round]
\def\edge{
(.5,.5) to [out=90,in=-90] ++ (0,1.05) to [out=0,in=-90] ++ (.52,.52) to [out=90,in=0] ++ (-.52,.52) to [out=90,in=0] ++ (-.52,.52) to [out=180,in=90] ++ (-.52,-.52) to [out=-180,in=90] ++ (-.52,-.52)  to [out=-90,in=180] ++ (.52,-.52) to [out=-90,in=90] ++ (0,-1.05)}
    \draw[line width=.1cm,blue, fill=blue!40!white, opacity=.6] (.5,.5) foreach \i in {0,90,180,270}{[rotate=\i] -- \edge} -- cycle;
\end{tikzpicture}
\end{frame}
\end{document}

I noticed that using [line join=round, line cap=round] produced an extended end of lines. Omitting this option produced less appealing line joins.

How can line join=round be used to produce rounded ends of lines, without producing the extended parts.

enter image description here

enter image description here

enter image description here

epR8GaYuh
  • 2,432
Hany
  • 4,709

3 Answers3

7

This is a simple calculation error in your code. Indeed, the path starts at the point (.5,.5) but your semicircles have a radius of .52, which does not end the first quarter of the cross at the coordinate point (-.5,.5). By replacing the radius of .52 by .5, the problem is solved. Notice that I have slightly simplified your code by removing some unnecessary to operations.

screenshot

\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{verbatim}
\usepackage{tikz}
\begin{document}
\begin{frame}[t]
\frametitle{}
\begin{tikzpicture}[line join=round, line cap=round]
\def\edge{
(.5,.5) -- ++ (0,1.05) to [out=0,in=-90] ++ (.5,.5) to [out=90,in=0] ++ (-.5,.5) to [out=90,in=0] ++ (-.5,.5) to [out=180,in=90] ++ (-.5,-.5) to [out=-180,in=90] ++ (-.5,-.5)  to [out=-90,in=180] ++ (.5,-.5) -- ++ (0,-1.05)}
\draw[line width=.1cm,blue, fill=blue!40!white, opacity=.6] (.5,.5) foreach \i in {0,90,180,270}{[rotate=\i] -- \edge}--cycle;
\end{tikzpicture}
\end{frame}
\end{document}
AndréC
  • 24,137
7

Your code for the \edge can be shortened very much, and this shortening automatically also fixes the issue. Also you probably want to use a transparency group in order to avoid that the boundary has two colors.

\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{verbatim}
\usepackage{tikz}
\begin{document}
\begin{frame}[t]
\frametitle{}
\begin{tikzpicture}[line join=round, line cap=round]
\def\edge{
(.5,.5) -- ++ (0,1.05)foreach \j in {0,90,180}  {to [out=\j,in=\j,looseness=1.6] ++ (\j+90:1)}}
\begin{scope}[transparency group,opacity=.6]
\draw[line width=.1cm,blue, fill=blue!40!white] (.5,.5) foreach \i in {0,90,180,270}{[rotate=\i] -- \edge} -- cycle;
\end{scope}
\end{tikzpicture}
\end{frame}
\end{document}

enter image description here

  • Thank you very much for your time and effort. – Hany Dec 09 '19 at 15:21
  • @Hany It is my pleasure (and it wasn't too difficult since after all I was involved in the creation of the original \edge command ;-) –  Dec 09 '19 at 23:06
3

Handmade shifts are evil! I'm sure there must be a most suitable solution (more maintainable) using labeling of nodes, but I'm not familiar enough with tikz to draw such a solution. Meanwhile, you can try:

\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{verbatim}
\usepackage{tikz}
\begin{document}
\begin{frame}[t]
\frametitle{}
\begin{tikzpicture}[line join=round, line cap=round]
\def\edge{
(.5,.5) to [out=90,in=-90] ++ (0,1.05) to [out=0,in=-90] ++ (.5,.5) to [out=90,in=0] ++ (-.5,.5) to [out=90,in=0] ++ (-.5,.5) to [out=180,in=90] ++ (-.5,-.5) to [out=-180,in=90] ++ (-.5,-.5)  to [out=-90,in=180] ++ (.5,-.5) to [out=-90,in=90] ++ (0,-1.05)}
    \draw[line width=.1cm,blue, fill=blue!40!white, opacity=.6] (.5,.5) foreach \i in {0,90,180,270}{[rotate=\i] -- \edge} -- cycle;
\end{tikzpicture}
\end{frame}
\end{document}

Which eliminates the overlaps. enter image description here

jchd
  • 533