我正在寻找使用以下代码通过 Tikz 绘制一些表格:
\begin{figure}
\centering
\shade[ball color=gray] (0,4) circle (5ex);
\shade[ball color=black] (1,4) circle (5ex);
\shade[ball color=gray] (7,4) circle (5ex);
\shade[ball color=black] (9,4) circle (5ex);
\shade[ball color=gray] (4,1) circle (5ex);
\shade[ball color=black] (5,1) circle (5ex);
\shade[ball color=gray!70] (4.5,0) circle (5ex);
\end{tikzpicture}
\label{fig1chap3}
\end{figure}
答案1
剪辑可以在这里提供很大帮助,这是一个起点:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[
radius=10mm,
]
\begin{scope}
\clip (0, 0) circle;
\fill[red] (0, 0) circle;
\fill[red!50!blue, overlay] (13mm, 0) circle;
\end{scope}
\end{tikzpicture}
\end{document}
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[
radius=10mm,
]
\begin{scope}[even odd rule]
\clip[overlay]
(-11mm, -11mm) rectangle (11mm, 11mm)
(13mm, 0) circle;
\fill[red] (0, 0) circle;
\end{scope}
\begin{scope}[xshift=4mm]
\clip (0, 0) circle;
\clip (13mm, 0) circle;
\fill[red!50!blue] (0, 0) circle;
\end{scope}
\begin{scope}[xshift=8mm, even odd rule]
\clip[overlay]
(13mm - 11mm, -11mm) rectangle (13mm + 11mm, 11mm)
(0, 0) circle;
\fill[blue] (13mm, 0) circle;
\end{scope}
\end{tikzpicture}
\end{document}
使用两个圆圈来剪辑前一个绘图的左侧或右侧是行不通的:
\begin{scope}[even odd rule]
\clip (0, 0) circle[]
(13mm, 0) circle;
\fill[red] (0, 0) circle;
\end{scope}
问题在于第一个圆的边界位于第二个圆的区域中。在那里,圆用一条模糊的线画出来。这个问题可以通过为第一个圆使用更大的区域来解决。
带阴影
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[
radius=10mm,
]
\begin{scope}[even odd rule]
\clip[overlay]
(-11mm, -11mm) rectangle (11mm, 11mm)
(13mm, 0) circle[];
;
\fill[shading=ball, ball color=red] (0, 0) circle;
\end{scope}
\begin{scope}[xshift=4mm]
\clip (0, 0) circle;
\clip (13mm, 0) circle;
\fill[shading=ball, ball color=red!50!blue] (0, 0) circle;
\end{scope}
\begin{scope}[xshift=8mm, even odd rule]
\clip[overlay]
(13mm - 11mm, -11mm) rectangle (13mm + 11mm, 11mm)
(0, 0) circle;
\fill[shading=ball, ball color=blue] (13mm, 0) circle;
\end{scope}
\end{tikzpicture}
\end{document}