下面的代码画了两个以原点为中心的同心圆,如何得到大圆在225度到315度之间,小圆外面的扇形区域?
\documentclass{amsart}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{tikz}
\usetikzlibrary{calc,positioning,intersections}
\begin{document}
\begin{tikzpicture}
%\draw[fill=gray!50] (225:{sqrt(3)}) -- (225:3) -- arc -- (-45:3) -- arc -- (-45:{sqrt(3)}) -- cycle;
\draw (0,0) circle (3);
\draw (0,0) circle ({sqrt(3)});
\draw (-3,0) -- (3,0);
\draw (225:3) -- (45:3);
\draw (0,-3) -- (0,3);
\draw (135:3) -- (-45:3);
\end{tikzpicture}
\end{document}
答案1
转换评论:
\shade (225:{sqrt(3)})
-- (225:3) arc (225:315:3)
-- (315:{sqrt(3)}) arc (315:225:{sqrt(3)});
完整示例:
\documentclass{amsart}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\shade (225:{sqrt(3)})
-- (225:3) arc (225:315:3)
-- (315:{sqrt(3)}) arc (315:225:{sqrt(3)});
\draw (0,0) circle (3)
(0,0) circle ({sqrt(3)})
(-3,0) -- (3,0)
(225:3) -- (45:3)
(0,-3) -- (0,3)
(135:3) -- (-45:3)
;
\end{tikzpicture}
\end{document}
结果:
这四行也可以通过\foreach
循环生成,例如:
\draw
% two circles
\foreach \i in {0, ..., 3} {
(\i*45:3) -- (\i*45 + 180:3)
}
;