仅使用一个象限绘制十字

仅使用一个象限绘制十字

为了画出这个十字,

在此处输入图片描述

我使用了以下非常长且耗时的代码。

我想过通过只绘制一个象限并使用保存框重复此操作来简化此代码。但我不知道如何精确地做到这一点并避免绘制内部不必要的线条。

在此处输入图片描述

在此处输入图片描述

\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{verbatim}
\usepackage{tikz}
\begin{document}
\begin{frame}[t]
\frametitle{Coptic Cross}
\includegraphics[width=6.6cm,keepaspectratio]{./cross_coptic.jpg}
\vskip -6.5cm
\hskip .04cm
\begin{tikzpicture}[scale=.9, transform shape]
\tikzset{pics/.cd,
crossa/.style n args={2}{code={
\node [red] at (0,0) (o){\bf .}
([shift={(90.:3.4cm)}]o.center) node [red] (t){\bf .}
([shift={(-90.:3.4cm)}]o.center) node [red] (b){\bf .}
([shift={(180.:3.38cm)}]o.center) node [red] (ol){\bf .}
([shift={(0:3.38cm)}]o.center) node [red] (or){\bf .}
([shift={(90.:.6cm)}]o.center) node [red] (oua){\bf .}%up 1 level
([shift={(180.:.6cm)}]oua.center) node [red] (oual){\bf .}
([shift={(0:.6cm)}]oua.center) node [red] (ouar){\bf .}
([shift={(180.:2.5cm)}]oua.center) node [red] (ouall){\bf .}
([shift={(0:2.5cm)}]oua.center) node [red] (ouarr){\bf .}
([shift={(90.:1.6cm)}]o.center) node [red] (ouaa){\bf .}%up 2 levels
([shift={(180.:2.12cm)}]ouaa.center) node [red] (ouaal){\bf .}
([shift={(0:2.12cm)}]ouaa.center) node [red] (ouaar){\bf .}
([shift={(90.:2.1cm)}]o.center) node [red] (ouaaa){\bf .}%up 3 levels
([shift={(180.:1.6cm)}]ouaaa.center) node [red] (ouaaal){\bf .}
([shift={(0:1.6cm)}]ouaaa.center) node [red] (ouaaar){\bf .}
([shift={(90.:2.45cm)}]o.center) node [red] (ouaaaa){\bf .}%up 4 levels
([shift={(180.:.6cm)}]ouaaaa.center) node [red] (ouaaaal){\bf .}
([shift={(0:.6cm)}]ouaaaa.center) node [red] (ouaaaar){\bf .}
([shift={(-90.:.6cm)}]o.center) node [red] (oda){\bf .}%down 1 level
([shift={(180.:.6cm)}]oda.center) node [red] (odal){\bf .}
([shift={(0:.6cm)}]oda.center) node [red] (odar){\bf .}
([shift={(180.:2.5cm)}]oda.center) node [red] (odall){\bf .}
([shift={(0:2.5cm)}]oda.center) node [red] (odarr){\bf .}
([shift={(-90.:1.6cm)}]o.center) node [red] (odaa){\bf .}%down 2 levels
([shift={(180.:2.12cm)}]odaa.center) node [red] (odaal){\bf .}
([shift={(0:2.12cm)}]odaa.center) node [red] (odaar){\bf .}
([shift={(-90.:2.1cm)}]o.center) node [red] (odaaa){\bf .}%down 3 levels
([shift={(180.:1.6cm)}]odaaa.center) node [red] (odaaal){\bf .}
([shift={(0:1.6cm)}]odaaa.center) node [red] (odaaar){\bf .}
([shift={(-90.:2.45cm)}]o.center) node [red] (odaaaa){\bf .}%down 4 levels
([shift={(180.:.6cm)}]odaaaa.center) node [red] (odaaaal){\bf .}
([shift={(0:.6cm)}]odaaaa.center) node [red] (odaaaar){\bf .}
;
}}}
\pic at (0,0) {crossa={1.4}{.4}};
\draw[line width=.1cm,red, fill=red!20!white, opacity=.5] (oual.center)
%upper left quadrant
 to [out=90,in=-20, looseness=1.] (ouaaal.center)
 to [out=50,in=180, looseness=1.] (ouaaaal.center)
 to [out=90,in=-150, looseness=1.] (t.center)
%upper right quadrant
 to [out=-30,in=90, looseness=1.] (ouaaaar.center)
 to [out=0,in=130, looseness=1.] (ouaaar.center)
 to [out=-160,in=90, looseness=1.] (ouar.center)
%right upper quadrant
 to [out=0,in=-110, looseness=1.] (ouaar.center)
 to [out=-40,in=90, looseness=1.] (ouarr.center)
 to [out=0,in=-240, looseness=1.] (or.center)
%right lower quadrant
 to [out=-120,in=0, looseness=1.] (odarr.center)
 to [out=-90,in=40, looseness=1.] (odaar.center)
 to [out=-250,in=0, looseness=1.] (odar.center)
%lower right quadrant
 to [out=-90,in=-200, looseness=1.] (odaaar.center)
 to [out=-130,in=0, looseness=1.] (odaaaar.center)
 to [out=-90,in=-330, looseness=1.] (b.center)
%lower left quadrant
 to [out=-220,in=-90, looseness=1.] (odaaaal.center)
 to [out=-180,in=-50, looseness=1.] (odaaal.center)
 to [out=-340,in=-90, looseness=1.] (odal.center)
%left lower quadrant
 to [out=180,in=70, looseness=1.] (odaal.center)
 to [out=140,in=270, looseness=1.] (odall.center)
 to [out=180,in=-60, looseness=1.] (ol.center)
%left upper quadrant
 to [out=60,in=180, looseness=1.] (ouall.center)
 to [out=90,in=220, looseness=1.] (ouaal.center)
 to [out=-70,in=180, looseness=1.] (oual.center)
 -- cycle
;
\end{tikzpicture}
\end{frame}
\begin{frame}[t]
\frametitle{Coptic Cross}
\includegraphics[width=6.6cm,keepaspectratio]{./cross_coptic.jpg}
\newsavebox{\s}
\savebox{\s}{
\begin{tikzpicture}[scale=.9, transform shape]
\node [red] at (0,0) (o){}
([shift={(90.:3.4cm)}]o.center) node [red] (t){}
([shift={(90.:.6cm)}]o.center) node [red] (oua){}
([shift={(180.:.6cm)}]oua.center) node [red] (oual){}
([shift={(90.:2.1cm)}]o.center) node [red] (ouaaa){}
([shift={(180.:1.6cm)}]ouaaa.center) node [red] (ouaaal){}
([shift={(90.:2.45cm)}]o.center) node [red] (ouaaaa){}
([shift={(180.:.6cm)}]ouaaaa.center) node [red] (ouaaaal){}
;
\draw[line width=.1cm,red, fill=red!30!white, opacity=.6, rounded corners=.05cm] (oual.center)
 to [out=90,in=-20, looseness=1.] (ouaaal.center)
 to [out=50,in=180, looseness=1.] (ouaaaal.center)
 to [out=90,in=-150, looseness=1.] (t.center)
 to [out=-90,in=90, looseness=1.] (o.center)
 to [out=180,in=0, looseness=1.] ([shift={(-90:.6)}]oual.center)
 -- cycle
;
\end{tikzpicture}
}
\vskip -3.64cm
\hskip 1.56cm
\begin{tikzpicture}
\usebox{\s};
\end{tikzpicture}
\end{frame}
\end{document}

答案1

来自我朋友的代码。

在此处输入图片描述

% Bui Quy
\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}[line join=round,line cap=round]
\def\edge{
(.5,.5)
to[out=90,in=-150] ++(1,2)
to[out=120,in=0] ++(-1,.5)
to[out=90,in=-30] ++(-.5,1)
to[out=-150,in=90] ++(-.5,-1)
to[out=180,in=60] ++(-1,-.5)
to[out=-30,in=90] ++(1,-2)
}

% Schrodinger's cat suggested this better code
\draw[fill=lime] (.5,.5) 
foreach \i in {0,90,180,270} {[rotate=\i]--\edge}
--cycle;
\end{tikzpicture}
\end{document}

答案2

这是我的建议,我修改了你的绘图并删除了节点并用绘图替换,它允许使用标记更改和转换

\documentclass{article}

\usepackage{verbatim}
\usepackage{tikz}
\begin{document}



\newcommand{\crossq}{

\def\coef{1}
\path[blue,thick,fill=red!30] (0,0) coordinate(O)
-- (180:0.6) coordinate(oual)
to [out=90,in=-10] coordinate[pos=0.23] (a1)++(-1,2.1)coordinate(a2)
to[out=50,in=180] ++(1,0.3)
to[out=90,in=-150] ++ (0.6,1)
-- cycle;

\draw[blue,thick] (a1)
to [out=90,in=-10] (a2)
to[out=50,in=180] ++(1,0.3)
to[out=90,in=-150] ++ (0.6,1);

\path[purple,thick,fill=red!30] (0,0) coordinate(O)
-- (0:0.6) coordinate(oual)
to [out=90,in=190] coordinate[pos=0.23] (b1)++(1,2.1)coordinate(b2)
to[out=130,in=0] ++(-1,0.3)
to[out=90,in=-30] ++ (-0.6,1)
-- cycle
;

\draw[purple,thick,fill=red!30] (b1)
to [out=90,in=190] (b2)
to[out=130,in=0] ++(-1,0.3)
to[out=90,in=-30] ++ (-0.6,1)
;

}



\begin{tikzpicture}
\begin{scope}
\crossq



\end{scope}
\begin{scope}[rotate=90]
\crossq
\end{scope}
\begin{scope}[rotate=-90]
\crossq
\end{scope}
\begin{scope}[rotate=180]
\crossq
\end{scope}

\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容