![Tikz:如何填充两个圆弧的交点?](https://linux22.com/image/424011/Tikz%EF%BC%9A%E5%A6%82%E4%BD%95%E5%A1%AB%E5%85%85%E4%B8%A4%E4%B8%AA%E5%9C%86%E5%BC%A7%E7%9A%84%E4%BA%A4%E7%82%B9%EF%BC%9F.png)
我想填充两个圆弧的交点,像这样:
我写了一些代码并画出了形状:
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{shapes,backgrounds}
\usepackage{tikz,xcolor,color}
\usetikzlibrary{fit}
\usepackage{tkz-euclide}
\begin{tikzpicture}
\coordinate (A) at (-2,0);
\coordinate (B) at (2,0);
\coordinate (C) at (2, 4);
\coordinate (D) at (-2,4);
\draw (A)--(B)--(C)--(D)--(A);
%Draw the arcs
\draw[color=gray] (2,0) arc (0:90:4); % around A
\draw[color=gray] (-2,4) arc (180:270:4); % around C
\draw[color=gray] (2,4) arc (90:180:4); % around B
\draw[color=gray] (-2,0) arc (270:360:4); % around D
\end{tikzpicture}
这让我明白了:
我尝试了一下裁剪和填充,但没有效果。我该如何填充中间的交叉部分?
答案1
您只能填充封闭路径。我用一片封闭的叶子进行裁剪,然后填充另一片。之后再绘制线条 ---cycle
以便获得更美观的斜接。
\documentclass[tikz, border = 1cm]{standalone}
\begin{document}
\begin{tikzpicture}
\begin{scope}
\clip (2,0) arc (0:90:4) arc (180:270:4) -- cycle;
\fill[gray] (2,4) arc (90:180:4) arc (270:360:4) -- cycle;
\end{scope}
\draw (2,0) arc (0:90:4) arc (180:270:4) -- cycle;
\draw(2,4) arc (90:180:4) arc (270:360:4) -- cycle;
\end{tikzpicture}
\end{document}