我怎样才能像这张图片一样填充环?

我怎样才能像这张图片一样填充环?

我想填充一个像这张图片一样的圆环 在此处输入图片描述

使用 Geogebra,我通过绘图进行了尝试4<=x^2+y^2<=9,这是 Geogebra 中的代码

\documentclass[12pt]{standalone}
\usepackage{pgf,tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{patterns}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\clip(-3.3,-3.3) rectangle (3.3,3.3);
\draw [rotate around={0.:(0.,0.)},color=black] (0.,0.) ellipse (2.cm and 2.cm);
\draw [rotate around={0.:(0.,0.)},color=black,fill=black,fill opacity=0.1] (0.,0.) ellipse (3.cm and 3.cm);
\end{tikzpicture}
\end{document}

但是,我得到了 在此处输入图片描述

我怎样才能像第一张图片那样填充戒指?

答案1

执行此类操作的一种简单方法是充满中心圆fill=white,并使用以下方法获取十字填充图案pattern=crosshatch

在此处输入图片描述

代码

\documentclass[12pt]{standalone}
\usepackage{pgf,tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{patterns}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\clip(-3.3,-3.3) rectangle (3.3,3.3);
\draw [rotate around={0.:(0.,0.)},color=black] (0.,0.) ellipse (2.cm and 2.cm);
\draw [rotate around={0.:(0.,0.)},color=black,fill=black,fill opacity=0.1] (0.,0.) ellipse (3.cm and 3.cm);
\draw [rotate around={0.:(0.,0.)},color=black,fill=white] (0.,0.) ellipse (2.cm and 2.cm);
\end{tikzpicture}
% -------------------
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\clip(-3.3,-3.3) rectangle (3.3,3.3);
\draw [rotate around={0.:(0.,0.)},color=black] (0.,0.) ellipse (2.cm and 2.cm);
\draw [rotate around={0.:(0.,0.)},color=black,fill=black,fill opacity=0.5, pattern=crosshatch] (0.,0.) ellipse (3.cm and 3.cm);
\draw [rotate around={0.:(0.,0.)},color=black,fill=white] (0.,0.) ellipse (2.cm and 2.cm);
\end{tikzpicture}
\end{document}

答案2

为什么要打字?

\documentclass[border=5]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{patterns}
\begin{document}
\begin{tikzpicture}
\draw[fill=gray!30,even odd rule]  (0,0) circle (3cm)
                                   (0,0) circle (2cm);
\end{tikzpicture}
% -------------------
\begin{tikzpicture}
\draw[even odd rule,pattern=crosshatch]  (0,0) circle (3cm)
                                         (0,0) circle (2cm);
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容