其实是个问题。我找不到一个简单而优雅的答案。s 的使用arc
让我很沮丧。
\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}
\draw[name path=circles] (0,0) circle (4 and 2) circle (3 and 1);
\path[name path=line1] (0,0) -- (10:5);
\path[name path=line2] (0,0) -- (-10:5);
\draw[name intersections={of=circles and line1}] (0,0) -- (intersection-1);
\draw[name intersections={of=circles and line2}] (0,0) -- (intersection-1);
\end{tikzpicture}
\end{document}
答案1
\documentclass[tikz, border=1cm]{standalone}
\begin{document}
\begin{tikzpicture}
\begin{scope}
\clip (0,0) -- (10:5) -- (-10:5) -- cycle;
\fill[pink, even odd rule] (0,0) ellipse[x radius=4, y radius=2] ellipse[x radius=3, y radius=1];
\end{scope}
\draw (0,0) ellipse[x radius=4, y radius=2] ellipse[x radius=3, y radius=1];
\draw (0,0) -- (10:5) (0,0) -- (-10:5);
\end{tikzpicture}
\end{document}
答案2
下面是使用该库的答案spath3
,其工作原理是在椭圆和直线路径的相交处进行分割,然后通过将生成的路径的各个部分焊接在一起来构建一条新路径。
\documentclass{article}
%\url{https://tex.stackexchange.com/q/652890/86}
\usepackage{tikz}
\usetikzlibrary{intersections,spath3}
\begin{document}
\begin{tikzpicture}
\path[spath/save=circles] (0,0)
circle[x radius=4, y radius=2]
circle[x radius=3, y radius=1]
;
% the overlay key means that these don't add to the picture size,
% also, a single path here simplifies the code later
\path[spath/save=lines,overlay] (10:5) -- (0,0) -- (-10:5);
% split the paths where they overlap each other
\tikzset{
spath/split at intersections={circles}{lines},
% save the components of the paths
spath/get components of={circles}\circlesCpts,
spath/get components of={lines}\linesCpts,
}
\fill[
magenta,
% takes a little experimenting to get the order right ...
spath/use={\getComponentOf\circlesCpts{3}},
spath/use={\getComponentOf\linesCpts{2},weld},
spath/use={\getComponentOf\circlesCpts{6},reverse,weld},
spath/use={\getComponentOf\linesCpts{4},weld},
];
% draw the ellipses now so that they are over the top of the
% filled region
\draw[ultra thick, spath/use={circles}];
\end{tikzpicture}
\end{document}