在下面的代码中,我在一个圆中画了一个直径。沿着直径,我画了七个等距节点。最靠近中心但不在中心的两个节点被标记为B
和C
。我想在圆内获得某种阴影图案 - 灰色阴影。
步骤如下。首先,用灰色填充圆圈。(我选择了gray!30
。)其次,使用fill=white
选项得到一个白色半圆,圆心在B
直径上方,另一个白色半圆,圆心在C
直径下方。第三,画两个圆,用 填充,gray!30
半径为 1,圆心在(-2,0)
和(2,0)
。
这是我的代码。我收到错误 - 我使用的命令有问题fill
。
\documentclass{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections}
\begin{document}
\begin{tikzpicture}
\coordinate (O) at (0,0);
\draw[fill=gray!30] (O) circle (3);
\draw[fill] (-3,0) circle (1.5pt);
\draw[fill] (-2,0) circle (1.5pt);
\draw[fill] (-1,0) circle (1.5pt);
\draw[fill] (0,0) circle (1.5pt);
\draw[fill] (1,0) circle (1.5pt);
\draw[fill] (2,0) circle (1.5pt);
\draw[fill] (3,0) circle (1.5pt);
\draw (-3,0) -- (3,0);
\node[anchor=east] (A) at (-3,0) {$A$};
\node[anchor=south west] at (-1,0) {$B$};
\node[anchor=north east] at (1,0) {$C$};
\node [anchor=west] at (3,0) {$D$};
\draw[fill=white] (-1,0) circle (2);
\draw[fill=white] (1,0) circle (2);
\draw[fill=gray!30] (-2,0) circ (1);
\draw[fill=gray!30] (2,0) circ (1);
\end{tikzpicture}
\end{document}
答案1
\documentclass{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections}
\begin{document}
\begin{tikzpicture}
\coordinate (O) at (0,0);
\draw[fill=gray!30] (O) circle (3);
\draw[fill] (-3,0) circle (1.5pt);
\draw[fill] (-2,0) circle (1.5pt);
\draw[fill] (-1,0) circle (1.5pt);
\draw[fill] (0,0) circle (1.5pt);
\draw[fill] (1,0) circle (1.5pt);
\draw[fill] (2,0) circle (1.5pt);
\draw[fill] (3,0) circle (1.5pt);
\draw (-3,0) -- (3,0);
\node[anchor=east] (A) at (-3,0) {$A$};
\node[anchor=south west] at (-1,0) {$B$};
\node[anchor=north east] at (1,0) {$C$};
\node [anchor=west] at (3,0) {$D$};
\path[fill=white] (-3,0) arc (180:0:2) -- (-3,0) -- cycle;
\path[fill=white] (3,0) arc (360:180:2) -- (3,0) -- cycle;
\path[fill=gray!30] (-2,0) circle (1);
\path[fill=gray!30] (2,0) circle (1);
\end{tikzpicture}
\end{document}