我怎样才能去除这幅 TikZ 图片中的阴影以进行白色填充?

我怎样才能去除这幅 TikZ 图片中的阴影以进行白色填充?

我想要纯白色填充,这样最上面的圆圈就不完整了。但图中出现了黑色阴影。有没有更简单的方法来实现这一点?

在此处输入图片描述

\documentclass{article}

\usepackage{tikz}

\begin{document}
\begin{figure}
\begin{center}
\begin{tikzpicture}[scale=1.0, ,transform shape]
\node [draw, thick, minimum size=1cm, circle] at (0,0) {};
\node [draw, thick, minimum size=1cm, circle] at (1,0) {};
\node [draw, thick, minimum size=1cm, circle] at (2,0) {};
\node [draw, thick, minimum size=1cm, circle] at (-1,0) {};

\node [draw, thick, minimum size=1cm, circle] at (1.5,-0.85) {};
\node [draw, thick, minimum size=1cm, circle] at (0.5,-0.85) {};
\node [draw, thick, minimum size=1cm, circle] at (-0.5,-0.85) {};

\node [draw, thick, minimum size=1cm, circle] at (1.5,0.85) {};
\node [draw, thick, minimum size=1cm, circle] at (0.5,0.85) {};
\node [draw, thick, minimum size=1cm, circle] at (-0.5,0.85) {};

\node [draw, thick, minimum size=1cm, circle] at (1.0,2*0.85) {};
\shade[fill=white!20!white, draw=white!40!black](-1.5,2.0)--(2.5,2.0)--(2.5,2.5)--(-1.5,2.5);

\draw[dotted,thin](-1.5,-2)--(-1.5,2.0)--(2.5,2.0)--(2.5,-2)--(-1.5,-2);

\end{tikzpicture}
\end{center}
\caption{hhhhhhhhh}
\label{figspahre}
\end{figure}

\end{document}

答案1

代替

\shade[fill=white!20!white, draw=white!40!black]-1.5,2.0)-`-(2.5,2.0)--(2.5,2.5)--(-1.5,2.5);

经过

\draw[draw=none,fill=white!20](-1.5,2.0)--(2.5,2.0)--(2.5,2.5)--(-1.5,2.5);

如果你想要上面的矩形,使用

\draw[draw=white!40!black,fill=white!20](-1.5,2.0)--(2.5,2.0)--(2.5,2.5)--(-1.5,2.5) -- cycle;

其他可能的命令是\fill\filldraw

代码

\documentclass[twoside]{article}
\usepackage{graphicx}
\usepackage{tikz}

\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}[scale=1.0, ,transform shape]
\node [draw, thick, minimum size=1cm, circle] at (0,0) {};
\node [draw, thick, minimum size=1cm, circle] at (1,0) {};
\node [draw, thick, minimum size=1cm, circle] at (2,0) {};
\node [draw, thick, minimum size=1cm, circle] at (-1,0) {};

\node [draw, thick, minimum size=1cm, circle] at (1.5,-0.85) {};
\node [draw, thick, minimum size=1cm, circle] at (0.5,-0.85) {};
\node [draw, thick, minimum size=1cm, circle] at (-0.5,-0.85) {};

\node [draw, thick, minimum size=1cm, circle] at (1.5,0.85) {};
\node [draw, thick, minimum size=1cm, circle] at (0.5,0.85) {};
\node [draw, thick, minimum size=1cm, circle] at (-0.5,0.85) {};

\node [draw, thick, minimum size=1cm, circle] at (1.0,2*0.85) {};
\draw[draw=none,fill=white!20](-1.5,2.0)--(2.5,2.0)--(2.5,2.5)--(-1.5,2.5);

\draw[dotted,thin](-1.5,-2)--(-1.5,2.0)--(2.5,2.0)--(2.5,-2)--(-1.5,-2);

\end{tikzpicture}
\caption{hhhhhhhhh}
\label{figspahre}
\end{figure}

\end{document}

在此处输入图片描述

附注:

颜色描述white!20!white毫无意义。它说的是 20% 的白色与 80% 的白色混合。

white!20!white... \end{center}不要使用,而要使用\centering。这将删除一些不需要的空白。

相关内容