我想填充两个圆弧的交点,像这样:
我写了一些代码并画出了形状:
\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}