我如何制作这个图形?

我如何制作这个图形?

目标人物:

在此处输入图片描述

让我填写区域。有人能帮我吗?我的 LaTeX 代码:

\documentclass[border=5mm]{standalone}

 \usepackage[svgnames,x11names,dvispnames]{xcolor}
\usepackage{tkz-base,tkz-euclide,tkz-fct}
  \begin{document}  
\begin{tikzpicture}
    \tkzDefPoints{0/0/A, 6/0/B}
    \tkzDefSquare(A,B)      \tkzGetPoints{C}{D}
    \tkzDrawPolygon(A,B,C,D)
    \tkzDefMidPoint(A,B)        \tkzGetPoint{M}
    \tkzDefMidPoint(A,D)        \tkzGetPoint{N}
    \tkzDefMidPoint(B,C)        \tkzGetPoint{O}
    \tkzDefMidPoint(C,D)        \tkzGetPoint{P}
    \tkzDrawSemiCircle(M,B)
    \tkzDrawSemiCircle(N,A)
    \tkzDrawSemiCircle(O,C)
    \tkzDrawSemiCircle(P,D)
    \tkzDrawPolygon(M,N,P,O)
    %\tkzLabelPoints(A,B,C,D,M,N,O,P)
\end{tikzpicture}
\end{document}

答案1

您可以使用even odd rule。一个重要的技巧是,较大的方块(bsq)被使用两次,以使相关区域着色。各种路径存储在样式中,以避免不必要的重复。

\documentclass[tikz,border=3mm]{standalone}
\begin{document}
\begin{tikzpicture}[declare function={a=2;},
    cs/.style={insert path={
     (-a,-a) arc[start angle=180,end angle=0,radius=a]
        arc[start angle=-90,end angle=-270,radius=a]
        arc[start angle=0,end angle=-180,radius=a]
        arc[start angle=90,end angle=-90,radius=a]
    }},
    sq/.style={insert path={[rotate=45] ({-a/sqrt(2)},{-a/sqrt(2)})
     rectangle ({a/sqrt(2)},{a/sqrt(2)})}},
    bsq/.style={insert path={(-a,-a) rectangle (a,a)}},thick]
 \fill[blue!20,even odd rule,bsq,bsq,cs,sq];
 \draw[orange,bsq];
 \draw[dashed,blue,cs];
 \draw[orange,sq,line join=round];
\end{tikzpicture}
\end{document}

在此处输入图片描述

人们可以进一步缩短代码。

\documentclass[tikz,border=3mm]{standalone}
\begin{document}
\begin{tikzpicture}[declare function={a=2;},
    cs/.style={insert path={
     (-a,-a) foreach \X in {0,...,3}
      {arc[start angle={180+\X*90},end angle={180+\X*90-180},radius=a]}
    }},
    sq/.style={insert path={(-a,-a) rectangle (a,a)}},thick]
 \fill[blue!20,even odd rule,sq,sq,cs,rotate=45,scale={1/sqrt(2)},sq];
 \draw[orange,sq];
 \draw[dashed,blue,cs];
 \draw[orange,line join=round,rotate=45,scale={1/sqrt(2)},sq];
\end{tikzpicture}
\end{document}

答案2

随着下一个版本tkz-euclidev 4.00

\tkzClipCircle[out]仅在版本 4 中。之前有tkzClipOutCircle

\documentclass[border=5mm]{standalone}
\usepackage{tkz-euclide}
 \begin{document} 
  \begin{tikzpicture}
\tkzInit[xmin=-6,xmax=6,ymin=-6,ymax=6]
    \tkzDefPoints{0/0/A, 6/0/B}
    \tkzDefSquare(A,B)      \tkzGetPoints{C}{D}
    \tkzDefMidPoint(A,B)        \tkzGetPoint{M}
    \tkzDefMidPoint(A,D)        \tkzGetPoint{N}
    \tkzDefMidPoint(B,C)        \tkzGetPoint{O}
    \tkzDefMidPoint(C,D)        \tkzGetPoint{P}

\begin{scope}
  \tkzClipCircle[out](M,B)% version 4
  \tkzClipCircle[out](P,D)% version 4
 \tkzFillPolygon[magenta!20](M,N,P,O)
\end{scope}
\begin{scope}
  \tkzClipCircle[out](N,A)% version 4
  \tkzClipCircle[out](O,C)% version 4
   \tkzFillPolygon[magenta!20](M,N,P,O)
\end{scope}
\begin{scope}
    \tkzClipCircle(P,C)     \tkzClipPolygon(N,P,D) 
    \tkzFillCircle[magenta!20](N,A) 
\end{scope}
\begin{scope}
    \tkzClipCircle(O,C)     \tkzClipPolygon(P,C,O) 
    \tkzFillCircle[magenta!20](P,C)   
\end{scope}
\begin{scope}
    \tkzClipCircle(M,B)     \tkzClipPolygon(O,B,M) 
    \tkzFillCircle[magenta!20](O,B) 
\end{scope}
\begin{scope}
    \tkzClipCircle(N,A)     \tkzClipPolygon(A,M,N) 
    \tkzFillCircle[magenta!20](M,A)   
\end{scope}
\tkzDrawPolygon(A,B,C,D)
\tkzDrawSemiCircle[dashed](M,B)
\tkzDrawSemiCircle[dashed](N,A)
\tkzDrawSemiCircle[dashed](O,C)
\tkzDrawSemiCircle[dashed](P,D)
%\tkzDrawSemiCircles[dashed](M,B N,A O,C P,D) version 4
\tkzDrawPolygon(M,N,P,O)
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容