產生更具吸引力的圓形線端連接

產生更具吸引力的圓形線端連接

從答案到這個問題;我用下面的程式碼畫了另一個十字。

\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}

我注意到使用[line join=round, line cap=round]產生了延長的行尾。省略此選項會產生較不吸引人的線路連接。

如何line join=round用於生產線的圓形末端,而不生產延伸部分。

在此輸入影像描述

在此輸入影像描述

在此輸入影像描述

答案1

這是您的程式碼中的一個簡單的計算錯誤。事實上,路徑從該點開始(.5,.5),但半圓的半徑為.52,這確實沒有結束座標點處十字的第一個四分之一(-.5,.5).52將的半徑替換為.5,問題就解決了。請注意,我透過刪除一些不必要的操作稍微簡化了您的程式碼to

螢幕截圖

\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}

答案2

您的代碼\edge可以縮短非常多了,這種縮短也自動解決了這個問題。此外,您可能想要使用 atransparency group以避免邊界有兩種顏色。

\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}

在此輸入影像描述

答案3

手工變身是邪惡的!我確信一定有一個使用節點標籤的最合適的解決方案(更容易維護),但我還不夠熟悉,無法tikz得出這樣的解決方案。同時,您可以嘗試:

\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}

這消除了重疊。 在此輸入影像描述

相關內容